fix(genesis): reject zero block gas limit - #327
Conversation
|
Reviewed at Verified
The reachability story is better than "could bypass"This isn't only theoretical. blockGasLimit: blockGasLimit ?? 30_000_000n,...where So an explicit Why this class of bug exists at all (stronger framing than the PR gives)The description says genesis "bypasses the same invariant enforced by normal protocol config updates." It's more absolute than that. Genesis never calls So none of the contract's This fixes one of three gapsComparing the contract's invariants against the genesis schema field by field:
The Not asking you to expand this PR — scoping it tightly is right. But it's worth a follow-up issue so the class gets closed rather than just this instance.
|
Summary
Fixes #321
This updates the genesis
ProtocolConfigschema soblockGasLimitmust be greater than zero.Previously, genesis validation accepted
blockGasLimit: 0n:blockGasLimit: schemaBigInt.min(0n).max(maxUint64)
but the runtime
ProtocolConfigAPI rejects zero block gas limits. That allowed genesis configuration to bypass the same invariant enforced by normal protocol config updates.Changes
blockGasLimitlower bound from0nto1n.blockGasLimit: 1nblockGasLimit: 0nblockGasLimitabove uint64Why
Genesis configuration should enforce the same basic invariant as runtime config updates. A zero block gas limit can create an unusable or inconsistent protocol configuration, and it should fail during genesis schema validation instead of being accepted.
Tests
Regression test before the fix:
Result before fix:
2 passing
1 failing
Failure:
AssertionError: expected [Function] to throw an error
After the fix:
Result:
3 passing
Formatting:
Result:
All matched files use Prettier code style!
Lint:
Result:
passed
Checklist
Risk & Impact
Low. The bound only rejects
blockGasLimit: 0n, which was already invalid per the runtimeProtocolConfigAPI — any genesis config using a positive gas limit is unaffected. Verified the regression test fails against the old schema and passes with the fix, confirming it exercises the actual invariant mismatch.Type: 🐛 Bug fix
Fixes: #321