Why does BIP 141 (segwit) define both virtual transaction size and weight?
Weight seems to be just four times virtual transaction size (or vice versa, depending on what you define first). Why are both needed?
Bitcoin Stack Exchange is a question and answer site for Bitcoin users, developers, and enthusiasts. It only takes a minute to sign up.
Sign up to join this communityWhy does BIP 141 (segwit) define both virtual transaction size and weight?
Weight seems to be just four times virtual transaction size (or vice versa, depending on what you define first). Why are both needed?
The transaction limit under segwit is derived solely from the transaction weight and the block weight limit of 4,000,000 weight units.
Virtual transaction size was not used for the limit calculation because it is fractional when computed accurately. Bitcoin Core only uses integers in the consensus code and thus transitioned to transaction weight with the activation of segwit.
Virtual transaction size is merely provided as a convenient way of comparing segwit's effective transaction size to pre-segwit transaction sizes.
Adding a quote of the section to clarify: BIP141 specifies the following terms in regard to transaction size:
Transaction weight
is defined as Base transaction size * 3 + Total transaction size (ie. the same method as calculating Block weight from Base size and Total size).Virtual transaction size
is defined as Transaction weight / 4 (rounded up to the next integer).Base transaction size
is the size of the transaction serialized with the witness data stripped.Total transaction size
is the transaction size in bytes serialized as described in BIP144, including base data and witness data.
vsize
- virtual size - from RPC, not weight.
May 22, 2017 at 22:39