fix(spec-specs): decode withdrawal amount as uint64 per EIP-4895#3186
Draft
skbaek wants to merge 1 commit into
Draft
fix(spec-specs): decode withdrawal amount as uint64 per EIP-4895#3186skbaek wants to merge 1 commit into
skbaek wants to merge 1 commit into
Conversation
EIP-4895 defines the withdrawal amount as a uint64 of Gwei, and clients type it accordingly, rejecting blocks whose RLP encodes a wider amount at decode time. EELS declared `Withdrawal.amount: U256`, decoding and applying oversized amounts and rejecting such blocks only via the state-root mismatch (exercised by ethereum/tests `withdrawalsAmountBounds.json`, whose expected exceptions include RLP_INVALID_FIELD_OVERFLOW_64). Change the field to `U64` in all withdrawal-carrying forks, widen to `U256` for the Gwei-to-Wei conversion in `process_withdrawals`, and enforce the bound at every JSON parse site that builds withdrawals without an RLP round-trip: the fixture loader, the sync tool's RPC block builder, and b11r. Add a codec regression test covering the maximum valid amount and the 2**64 overflow rejection. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
U64across Shanghai and later forks, matching the EIP-4895 consensus-layer type.U256explicitly before applying the Gwei-to-Wei multiplier.Why
EIP-4895 defines a withdrawal's
amountas auint64, but EELS modeled it asU256. As a result, RLP decoding could accept withdrawal amounts outside the consensus type's valid range. This change enforces the correct bound at decoding time while preserving the existing balance-update arithmetic.Impact
Withdrawal fixtures and blocks with valid 64-bit amounts continue to decode and process normally. Oversized withdrawal amounts are now rejected instead of being accepted by EELS.
Validation
uv run pytest tests/json_loader/test_withdrawal_codec.py(2 passed)just static(all checks passed)