← Back to Pull requests

fix(l2): normalize legacy omitted-withdrawals bodies read from trusted history #7106

Closed
unknown closed this pull request without merging on Aug 20, 2026 19:26 UTC
View on GitHub
unknown unknown commented on Aug 04, 2026 18:31 UTC
Author

Motivation

Older ethrex versions stored post-Shanghai blocks with withdrawals: None while the header committed to the empty-withdrawals root. validate_block_body rejects that shape, so re-reading such a block from local history fails with WithdrawalsRootNotMatch.

The normalization helper and its first call sites already reached main by another route, so what remains here are the follow-ups that came out of review, and one of them is load-bearing for a failure that only shows up inside the prover:

generate_batch_prover_input hands ProverInputData.blocks to the guest, and the guest re-encodes those exact blocks and KZG-checks the result against the committed blob (crates/guest-program/src/l2/blobs.rs). BlockBody::encode uses encode_optional_field, so an absent withdrawals field is omitted while an empty one writes 0xc0. Because prepare_batch_from_block normalizes before generate_blobs_bundle, the blob for a batch containing legacy blocks holds the canonical encoding — so a prover-input path that did not normalize would differ by one byte and fail as InvalidBlobProof inside the zkVM. That is the concrete failure behind the review comment asking for generate_batch_prover_input to normalize too.

Description

  • One read path for stored blocks. read_trusted_block (crates/l2/sequencer/utils.rs) is now the only place a block is read from the store and normalized, and both prepare_batch_from_block and fetch_blocks_with_respective_fee_configs go through it. Previously the two duplicated the store read and each carried its own normalization call, so correctness depended on two sites staying identical with nothing pinning them together — and the penalty for drift is a one-byte RLP mismatch surfacing as a KZG failure inside the guest. Routing both through one helper makes the coupling structural. It returns Ok(None) for a missing body, preserving the committer's "no new block to commit" loop exit instead of turning it into an error.

  • Going through the helper also covers the reads that feed witness generation and the based-mode commit calldata, which previously read the store directly.

  • The helper's doc comment states the real invariant. It previously claimed the point was agreeing on the canonical body the header commits to; for the prover-input path canonicality is incidental and the requirement is byte-equality with the bodies that went into the published blob. Stating the weaker property invited exactly the simplification the blob check punishes.

  • ethrex import deliberately left strict. It still rejects legacy bodies, so an RLP export from a pre-upgrade node cannot be re-imported. That is the mirror image of the reconstruct blob-dir case, which this work does normalize, and the asymmetry is intentional: reconstruct reads blobs the node itself published to L1 and re-checks them against the committed root, whereas import takes an arbitrary file whose provenance the node cannot establish. Widening that boundary should be its own change with its own argument, not a side effect of this one.

  • Upgrade test now exercises the case. Step 2 drains commits before the swap, so if block production stops there too, no batch ever spans blocks written by the old version and committed by the new one — the only situation where this normalization changes anything, meaning the test passed without touching it. Step 2.1 now leaves uncommitted blocks behind on purpose and records the L2 head; a new step 4.3 waits for a batch covering that head to be verified rather than merely committed, since committing only shows the sequencer accepted the blocks while the encoding is what the prover checks.
  • Noted while reviewing, not addressed here: the based follower applies L1-calldata blocks through blockchain.add_block (crates/l2/based/block_fetcher.rs), which never calls validate_block_body — that path is unaffected by any of this, but it also body-validates nothing today.

    Checklist

  • Updated STORE_SCHEMA_VERSION (crates/storage/lib.rs) if the PR includes breaking changes to the Store requiring a re-sync. — n/a, no Store changes
  • Diff: 521 lines (+390 / -131) across 6 files Reviewer: ElFantasma Review duration: 23094m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 521 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.374
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #7106"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.8% (MEDIUM) · Higher = larger blast radius
    47.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.9% · Safe to merge
    18.9%