Block Weights

Monero's blockchain, unlike other blockchains, has dynamic block sizes which means blocks expand to handle demand. However Monero does not allow unrestricted block growth, miners will face a penalty for expanding blocks and miners are restricted by how much they can expand a block.

Index

  1. Penalty Free Zone
  2. Blocks Weight
  3. Long Term Block Weight
  4. Effective Median Weight
  5. Median Weight For Coinbase Checks

Penalty Free Zone

Monero sets a minimum max block weight so that miners don't get punished for expanding small blocks.

For hf 1 this is 20000 bytes, for hf 2-4 this is 60000 and from 5 onwards this is 300000 bytes1.

Blocks Weight

A blocks weight is the sum of all the transactions weights in a block, including the miner transaction. The block header and transaction hashes are not included2.

Long Term Block Weight

The block's long term weight is the block's weight adjusted with previous block's weights.

Calculating A Blocks Long Term Weight

Up until hard-fork 10, the blocks long term weight is just the block's weight3.

From hard-fork 10 onwards we first get the median long term weight over the last 100,000 blocks, if this is less than the penalty free zone then set the median long term weight to this instead4.

Now we need to set a shot term constraint and adjusted block weight, the way we do this is different depending on the hard-fork.

From hard-fork 10 to 145:

\(adjustedBlockWeight = blockWeight\)

\(shortTermConstraint = medianLongTermWeight * 1.4\)

From 15 onwards6:

\(adjustedBlockWeight = max(blockWeight, \frac{medianLongTermWeight}{1.7})\)

\(shortTermConstraint = medianLongTermWeight * 1.7\)

Now the long term weight is defined as min(adjustedBlockWeight, shortTermConstraint)7.

Effective Median Weight

The effective median weight is used to calculate block reward and to limit block size.

Calculating Effective Median Weight

For any hard-fork the minimum this can be is the penalty free zone8.

Up until hard-fork 10, this is done by just getting the median block weight over the last 100 blocks9, if there are less than 100 blocks just get the median over all the blocks.

For hf 10 onwards, we first get the median long term weight over the last 100,000 blocks10, if this median is less than the hf 5 penalty free zone set the median to that, this is the long term median.

Now get the median block weight over the last 100 blocks, this is the short term median.

Now we can calculate the effective median, for hard-forks 10 to 14 this is done by11:

\(effectiveMedian = min(max(hf5PenaltyFreeZone, shortTermMedian), 50 * longTermMedian) \)

From 15 onwards this is done by:

\(effectiveMedian = min(max(longTermMedian, shortTermMedian), 50 * longTermMedian) \)

Median Weight For Coinbase Checks

When checking coinbase transactions and block weight Monero uses yet another median weight :).

Calculating Median Weight For Coinbase Checks

Before hf 12 this is the median block weight over the last 100 blocks12.

From hf 12 this is the effective median weight13