Skip to content

fix(txpool): enforce EIP-3860 max initcode size in mempool #121

Closed

Description

@panos-xyz

Background

QA finding X1: morph-reth's txpool accepts contract-creation transactions whose initcode exceeds the EIP-3860 limit (49 152 B), while morph-geth correctly rejects them.

geth reth (before fix)
50 000 B initcode -32000 max initcode size exceeded: code size 50000 limit 49152 accepts, returns hash, tx sits forever in pending

Root Cause

morph-mainnet / hoodi genesis use morph-geth's non-standard shanghaiBlock field (inherited from scroll-tech's go-ethereum). alloy's Genesis parser only recognises the upstream timestamp-based shanghaiTime, so MorphChainSpec.is_shanghai_active_at_timestamp returns false everywhere, and reth's EthTransactionValidator silently skips the EIP-3860 size guard at reth_transaction_pool::validate::eth.rs:468.

Functional Description

Reject contract-creation transactions whose initcode exceeds 49 152 B at the txpool layer in MorphTransactionValidator, independent of reth's Shanghai fork-activation check.

Why not just activate Shanghai in the chainspec?

Force-activating Shanghai/Cancun would flip is_shanghai_active_at_timestamp for every consumer in reth, most notably EthStorage::read_block_bodies, which would start filling body.withdrawals with Some(vec![]) after activation. morph-geth's Body has no withdrawals slot, so RPC responses would diverge byte-for-byte. We would also need to override MorphPayloadAttributesBuilder to keep withdrawals / parent_beacon_block_root pinned to None.

Enforcing the bound directly in MorphTransactionValidator keeps:

  • chainspec untouched
  • RPC output bit-identical to morph-geth
  • the size cap correctly enforced

This mirrors morph's existing pattern of managing fork semantics outside reth's standard fork path (e.g. MorphHardfork -> SpecId mapping in crates/chainspec/src/hardfork.rs).

EIP-3860 Intrinsic-Gas Surcharge

Already covered. Morph registers Prague at Viridian time, so reth's ensure_intrinsic_gas lands on SpecId::PRAGUE (PRAGUE ⊃ SHANGHAI), which includes initcode_cost. The only window where this would not hold is during cold-sync of pre-Viridian blocks on a fresh node — but mempool admission is not active during sync.

Acceptance Criteria

  • 49 153 B initcode → rejected with ExceedsMaxInitCodeSize
  • 49 152 B initcode → not blocked by EIP-3860
  • cargo nextest run --workspace passes
  • cargo nextest run -p morph-node --features test-utils -E 'binary(it)' passes
  • cargo clippy --all --all-targets -- -D warnings clean
  • cargo fmt --all -- --check clean
  • No regressions in existing txpool / RPC behavior

Related

Activity

  1. added
    bug
    on Jun 5, 2026
  2. self-assigned this
    on Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions