Motivation and Problem
CTxMemPoolEntry::GetTxSize()
returns the larger of two values: the BIP 141 virtual size (vsize) and the “sigop-adjusted size.” This sigop-adjusted size is used by mempool validation and mining algorithms as a safeguard to prevent overfilling blocks with transactions that approach both the weight and signature operation (sigop) limits in a way that could exploit block space efficiency.
In the current implementation, the sigop-adjusted size is reported as the “vsize” in RPCs that provide mempool transaction data, such as getmempoolentry
, getrawmempool
, testmempoolaccept
, and submitpackage
. However, the documentation for these RPCs typically describes this value simply as the “virtual transaction size as defined in BIP 141,” without acknowledging the sigop adjustment. Since the reported size may differ from the pure BIP 141 definition, this confuses people as in this tweet, discrepancy can be misleading, as the reported size may differ from the pure BIP 141 definition.
Proposed Solution
To resolve this, all mempool-related RPCs now return two separate fields:
vsize: the sigop-adjusted size, i.e. max(BIP 141 vsize, sigop-adjusted size), which reflects the value previously returned under the vsize label and continues to drive mempool acceptance and block template scoring.
vsize_bip141: the pure BIP 141 virtual size, strictly ceil(weight/4)
, matching the consensus definition and now reported separately for clarity.
This preserves the behavior for clients that depend on the mempool policy size being reported as vsize while making the consensus size explicitly accessible under vsize_bip141.
Additionally, this PR updates the relevant RPC help text to clearly document the distinction between these two sizes, and adds supporting documentation doc/policy/feerates-and-vsize.md
to better explain fee rates, virtual size calculations, sigop adjustments, and the mempool policy heuristics.
A new field, sigopsize, has also been added to the getrawtransaction RPC result when input information (transaction is in the mempool) is available. This field explicitly reports the sigop-adjusted size as calculated by ceil(sigop cost * bytes_per_sigop / WITNESS_SCALE_FACTOR)
. Exposing this value provides users with more precise insight into how the transaction’s sigops impact its effective size for policy and fee estimation.
Note: This picks up work from the closed #27591 Fixes #32775