Skip to content

fix(anvil): canonicalize blob tx roots#15699

Merged
grandizzy merged 4 commits into
foundry-rs:masterfrom
mattsse:mattsse/fix-anvil-blob-tx-root
Jul 13, 2026
Merged

fix(anvil): canonicalize blob tx roots#15699
grandizzy merged 4 commits into
foundry-rs:masterfrom
mattsse:mattsse/fix-anvil-blob-tx-root

Conversation

@mattsse

@mattsse mattsse commented Jul 12, 2026

Copy link
Copy Markdown
Member

Closes #15132. This is a smaller alternative to #15133.

Anvil used the pooled EIP-4844 encoding both when building transaction trie leaves and when materializing mined RPC transactions. This keeps the pooled transaction in internal storage, where existing blob lookup and replay code already depend on its sidecar, but introduces canonical block-body encoding for trie calculation and drops the sidecar only from mined RPC views. The resulting transaction root and block hash are canonical, mined raw and full transaction responses no longer expose the sidecar, and the anvil_getBlobs* behavior remains intact.

This avoids a separate sidecar store and changes to execution, snapshots, reorgs, state serialization, and trace replay. Focused coverage checks both EIP-4844 and EIP-7594 roots, then exercises the mined RPC representation and blob retrieval end to end.

Developed with AI assistance under my direction and review.

Block construction encoded EIP-4844 sidecars into transaction trie leaves. Encode the inner signed transaction for block roots and omit sidecars from mined RPC views while retaining the pooled form internally for blob APIs and replay.
Comment thread crates/anvil/core/src/eth/block.rs
TxEnvelope::Eip2930(s) => AnyTxEnvelope::Ethereum(TxEnvelope::Eip2930(rehash(s, hash))),
TxEnvelope::Eip4844(s) => AnyTxEnvelope::Ethereum(TxEnvelope::Eip4844(rehash(s, hash))),
TxEnvelope::Eip4844(s) => {
let s = if block.is_some() { s.map(TxEip4844Variant::drop_sidecar) } else { s };

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only canonicalizes mined JSON transactions. Raw transactions/raw blocks still expose pooled sidecars, and block size is still measured from that pooled encoding.

…ding-1783918934

fix(anvil): canonicalize raw blob block encoding
@grandizzy grandizzy requested a review from mablr July 13, 2026 08:11
grandizzy
grandizzy previously approved these changes Jul 13, 2026

@grandizzy grandizzy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@grandizzy grandizzy enabled auto-merge (squash) July 13, 2026 08:12
Remove the duplicate TxEip4844Variant test import that causes the workspace Clippy job to fail with redundant-imports denied.

@mablr mablr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@grandizzy grandizzy merged commit 4cb181a into foundry-rs:master Jul 13, 2026
20 checks passed
@github-project-automation github-project-automation Bot moved this to Done in Foundry Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bug(anvil): mined blocks commit transactionsRoot over pooled (sidecarful) EIP-4844 encoding, not canonical execution payload

4 participants