# How does Segwit achieve backwards compatibility in terms of the block size? [duplicate]

If SegWit results in production of blocks that are larger than 1MB, how do old nodes see them as valid, instead of rejecting them due to exceeding the maximal allowed size of 1MB?

• there are some very genius people (aka sipa), who designed the blocks, which contain transactions in a way that particular parts of this transaction goes into a separate (segregated) area. This does not violate the validity of a tx. With the given space in a block, one can "bring in" more transactions in a block, which is roughly 1.8 tx more on average (a specific block reached up to 4 times more). So effectivly blocksize remains the same, it can just hold more tx, than before. Aug 13, 2017 at 18:02
• @pebwindcraft Maybe I misunderstand you (comments are so short...), but Segwit absolutely increases the size of blocks - it's not just using the same space more efficiently. Old nodes however don't see part of the blocks, and as a result, it does not violate their consensus rules. Aug 13, 2017 at 20:08
– Murch
Aug 15, 2017 at 15:17

Segwit changes the definition of a maximum block size to be something called block weight. The maximum block weight is 4000000 weight units. We use the following formula to calculate the block weight:

``````3 * (size of non-witness data) + (size of everything including witness data)
``````

So we can do some math here to figure out if the size of non-witness data will ever be more than 1 MB.

``````Let x = size of non-witness data
Let y = size of just witnesses
4000000 >= 3x + (x + y)
4000000 >= 4x + y
4000000 - 4x >= y
``````

Since this is just a downwards sloping line, the point at which `y = 0` is where `x` will be the greatest. So setting y to 0:

``````4000000 - 4x >= 0
-4x >= -4000000
x <= 1000000
``````

Thus the largest the non-witness data can be is 1 MB, which is exactly the maximum block size for non-segwit nodes. Since non-segwit nodes will only see the non-witness data, segwit is backwards compatible as blocks would still be within the size limit.