Skip to content

fix(spec-specs): decode withdrawal amount as uint64 per EIP-4895#3186

Draft
skbaek wants to merge 1 commit into
ethereum:forks/amsterdamfrom
skbaek:fix/eip4895-withdrawal-amount-u64
Draft

fix(spec-specs): decode withdrawal amount as uint64 per EIP-4895#3186
skbaek wants to merge 1 commit into
ethereum:forks/amsterdamfrom
skbaek:fix/eip4895-withdrawal-amount-u64

Conversation

@skbaek

@skbaek skbaek commented Jul 17, 2026

Copy link
Copy Markdown

What changed

  • Model withdrawal amounts as U64 across Shanghai and later forks, matching the EIP-4895 consensus-layer type.
  • Convert withdrawal amounts to U256 explicitly before applying the Gwei-to-Wei multiplier.
  • Update fixture-loading and spec-tool paths to use the corrected type.
  • Add codec coverage for the maximum valid withdrawal amount and rejection of values larger than 64 bits.

Why

EIP-4895 defines a withdrawal's amount as a uint64, but EELS modeled it as U256. 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)

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant