Add consensus block size limit - #110
Conversation
CheckBlock() validated block size against MAX_SIZE, the serializer's generic 32 MB guard rather than a block rule; MAX_BLOCK_SIZE did not exist in this tree at all, because Bitcoin's 1 MB cap arrived in 0.3.x, after the 0.1.0 this fork came from. A miner could produce a 32 MB block and every node would download, verify and store it. Original work by mtg0001 in #110, rebased over #109 with the self-test conflict resolved, plus a comment explaining why the inherited count-against-bytes test stays. Measured before choosing the number: 5709 blocks read from blk0001.dat give a largest block of 34,290 bytes and a median of 216, so 1 MB leaves 29x of headroom and rejects nothing that exists. A node built from this branch then synced genesis to 5706 on the live network with zero size-limit rejections and zero CheckBlock errors -- the same test that caught BIP30 rejecting a real block at height 859.
|
Merged as #111 — your commit, rebased over #109 with the self-test conflict resolved (both PRs add a self-test and a line to each makefile's The resync is the part I want on the record, since this is consensus. A node built from the rebased branch synced genesis → 5706 on the live network: zero size-limit rejections, zero CheckBlock errors. And the cap was checked against the chain before trusting the number — 5709 blocks read out of One thing I did not take: Closing this one in favour of #111. Thanks — this and #109 both landed today. |
Summary
MAX_BLOCK_SIZE = 1000000as the consensus block-size ceiling.CBlock::CheckBlock()validate serialized block size against that ceiling instead of the generic 32 MB serializer limit.CBlock::CheckSizeLimits()so the rule is tested directly.consensus-limitsself-test and include it in both Windows and Linux test targets.Why
MAX_SIZEis the serializer safety limit, not a block consensus rule. This tree comes from Bitcoin 0.1.0, before Bitcoin added the later 1 MB block cap, so Bitflash had no real block-size ceiling beyond 32 MB.The current chain audit found the largest real block at 34 KB across 5,709 blocks. A 1 MB cap leaves wide room for existing usage while preventing oversized blocks from becoming valid consensus history.
Consensus warning
This is a consensus rule change. Do not merge only from unit tests. Before merging, run a full validation from genesis with the proposed rule, for example a fresh sync or a full
-checkblocks=0validation against the current chain, and confirm no existing block is rejected.I did not run that against the production data directory in this workspace because doing so would touch the local node/wallet state. This PR is prepared for audit.
Testing
git diff --checkmake -f makefile.mingw testsfrom MSYS2 UCRT64 insrc/