5

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?

4

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.

Virtual transaction size is merely provided as a convenient way of comparing segwit's effective transaction size to current 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 serialised 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.

  • 1
    I am not sure what "not used in segwit" means. :) It is used in bitcoin-core. For example, bitcoind returns vsize - virtual size - from RPC, not weight. – Karel Bílek May 22 '17 at 22:39
  • 1
    @KarelBílek: Then my answer was wrong and you shouldn't have accepted it. ;) You better wait for someone that actually knows what he's talking about such as PWuille. – Murch May 22 '17 at 22:40
  • 3
    Murch is right. vsize has no meaning except for humans. It's there to provide a smooth transition between transaction sizes and weights (which have a different scale). For example, feerates are currently expressed in satoshi/byte. In order to make comparison possible, I expect satoshi/vbyte to be used rather than satoshi/weight (which would be a drastic number change to mean the same thing). – Pieter Wuille May 23 '17 at 21:23
  • In that case, why doesn't bitcoin only define virtual size and not block weight limit, but virtual size limit, which would be 4 times smaller and mean the same thing, without defining two terms that are almost equivalent? maybe I am nitpicking too much, but I see no reason for the concept of weight. – Karel Bílek May 23 '17 at 23:31
  • 2
    Because virtual size is fractional when computed accurately. Weight is an integer. We only use integers in consensus code. – Pieter Wuille Jun 17 '17 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.