In BlockAssembler::CreateNewBlock
, we initiate nBlockWeight
to 4000 WU, reserving space for
coinbase transaction.
Latter on, while iterating on transactions for block inclusion in addPackagesTxs
, we verify that candidate package doesn’t overflow the max block weight. This check is done in TestPackage
against nBlockMaxWeight
. However, default value is DEFAULT_BLOCK_MAX_WEIGHT which is equal to MAX_BLOCK_WEIGHT - 4000 (L20 in src/policy/policy.cpp
). So block weight assembled is starting at 4000 WU and can’t overflow 3996000 WU.
Do we have duplicated coinbase transaction space reservation ? I can see this a safety margin to avoid creating invalid blocks if you create inflated coinbase transaction, at the price of few weight units leftover.
If so, maybe we should leave it as it is but document this behavior, I was surprised hitting this while scratching unrelated tests.