Skip to content

refactor: migrate engine validation to reth main hooks#140

Open
panos-xyz wants to merge 4 commits into
mainfrom
codex/reth-main-upgrade
Open

refactor: migrate engine validation to reth main hooks#140
panos-xyz wants to merge 4 commits into
mainfrom
codex/reth-main-upgrade

Conversation

@panos-xyz

@panos-xyz panos-xyz commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Pin reth to main snapshot f0a41795 (post-v2.3.0) and remove morph-engine-tree-ext, replacing the vendored payload validator with official StateRootStrategy + a thin MorphTreeEngineValidator wrapper.
  • Preserve Morph consensus rules: pre-Jade trusts header ZK-trie root while still persisting real MPT trie updates; post-Jade uses upstream strict state-root validation; parent-aware L1 message index and withdraw-trie-root CL cross-checks remain.
  • Clear withdraw-trie-root expectations on the L1-index early-reject path in validate_payload so failed payloads do not leave stale cache entries until LRU eviction.

Test plan

  • cargo check --workspace
  • cargo clippy --all --all-targets -- -D warnings
  • cargo nextest run --workspace (598 passed)
  • cargo nextest run -p morph-node --features test-utils -E 'binary(it)' (97 passed)
  • cargo test -p morph-node --lib validator::tests
  • Full Hoodi / mainnet historical replay against morph-geth canonical chain before merge

Summary by CodeRabbit

  • New Features

    • Added transaction pool submission and Ethereum subscription support to the RPC API.
    • Improved Ethereum transaction simulation state-root handling.
    • Updated payload building to align with current execution and state-root workflows.
  • Bug Fixes

    • Strengthened block validation with enhanced state-root and withdraw-trie-root consistency checks.
    • Improved EVM instruction error handling and gas/DB failure propagation.
    • Preserved correct Morph refund behavior for supported hardforks.
  • Compatibility

    • Updated the Rust toolchain and core dependencies; refreshed consensus and validation wiring.

panos-xyz and others added 2 commits July 13, 2026 21:48
validate_payload already registered an expectation in convert_payload_to_block;
clearing it on the early L1-index reject path matches the inner-failure cleanup
and avoids a stale cache entry until LRU eviction.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

Claude Code Review is paused for this repository. To reconnect it, an admin of this repository's GitHub organization (or the account owner, for personal repositories) who can also manage your Claude organization's Code Review settings needs to re-link GitHub in Code Review settings. This is a one-time step.

Tip: disable this comment in your organization's Code Review settings.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The workspace now targets Rust 1.95 and newer Reth, Revm, Alloy, and Vergen APIs. Morph engine-tree validation is implemented locally, payload building uses state-root handles, custom EVM instructions return execution results, and RPC and consensus integrations are updated.

Changes

Workspace and API upgrade

Layer / File(s) Summary
Workspace and dependency migration
Cargo.toml, crates/*/Cargo.toml, crates/node/build.rs, deny.toml
Rust, workspace membership, Reth/Revm/Alloy/Vergen versions, build metadata APIs, dependencies, and advisory ignores are updated.
Consensus and factory compatibility
crates/consensus/src/validation.rs, crates/evm/src/evm.rs
Consensus post-execution validation and EVM database error bounds match newer interfaces.

Tree validator migration

Layer / File(s) Summary
Morph tree validator integration
crates/node/src/validator.rs
Morph validation wraps BasicEngineValidator, enforces strict state-root validation, checks Jade-gated L1 queue state, and validates withdraw-trie-root expectations.
Validator coverage
crates/node/tests/it/engine.rs
Integration coverage verifies block-input imports without a registered withdraw-root expectation.

Payload and state-root flow

Layer / File(s) Summary
Payload builder state-root wiring
crates/payload/builder/src/builder.rs, crates/engine-api/src/builder.rs
Payload construction uses state_root_handle, updates state-hook management, and emits revised executed-block data.
Payload contracts and builders
crates/payload/types/*, crates/node/src/node.rs, crates/node/src/test_utils.rs, crates/node/tests/it/helpers.rs
Payload attributes initialize target_gas_limit, payload conversion accepts the new argument, and test builders use the updated request shape.

EVM execution compatibility

Layer / File(s) Summary
Block execution and environment updates
crates/evm/src/block/mod.rs, crates/evm/src/context.rs
Executor-owned state hooks are removed and block overrides are forwarded into pending environment construction.
Revm instruction and precompile APIs
crates/revm/src/evm.rs, crates/revm/src/precompiles.rs
Morph opcode handlers return InstructionExecResult, and precompile warm addresses use AddressSet.

RPC and hardfork updates

Layer / File(s) Summary
Hardfork semantics tests
crates/chainspec/src/hardfork.rs
EIP-7702 gas and refund assertions use updated GasParams accessors.
Ethereum RPC traits
crates/rpc/src/eth/*
Morph RPC support adds state-root simulation delegation, pool transaction forwarding, and subscription trait implementation.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

Suggested reviewers: anylots

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: migrating engine validation to Reth main hooks.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/reth-main-upgrade

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Format the L1-index cleanup path, upgrade crossbeam-epoch to 0.9.20, and
drop advisory ignores that no longer match after the reth main bump.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/node/src/validator.rs`:
- Around line 225-240: Update the L1 message validation loop in the block
validation method around expected so the first transaction’s queue_index must
equal parent.next_l1_msg_index before advancing expected; continue requiring
each subsequent queue index to match the current expected value, then increment
it with checked_add. Add a regression case covering a first queue index that
differs from the parent index and ensure validation rejects it.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 498f00c1-6109-49e9-859e-f7eb7c9ddf3c

📥 Commits

Reviewing files that changed from the base of the PR and between 43c3e59 and 204c2ce.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (28)
  • Cargo.toml
  • crates/chainspec/src/hardfork.rs
  • crates/consensus/src/validation.rs
  • crates/engine-api/src/builder.rs
  • crates/engine-tree-ext/Cargo.toml
  • crates/engine-tree-ext/src/gate.rs
  • crates/engine-tree-ext/src/lib.rs
  • crates/engine-tree-ext/src/payload_validator.rs
  • crates/engine-tree-ext/src/trie_updates.rs
  • crates/engine-tree-ext/tests/jade_boundary.rs
  • crates/evm/Cargo.toml
  • crates/evm/src/block/mod.rs
  • crates/evm/src/context.rs
  • crates/evm/src/evm.rs
  • crates/node/Cargo.toml
  • crates/node/build.rs
  • crates/node/src/node.rs
  • crates/node/src/test_utils.rs
  • crates/node/src/validator.rs
  • crates/node/tests/it/engine.rs
  • crates/node/tests/it/helpers.rs
  • crates/payload/builder/src/builder.rs
  • crates/payload/types/src/attributes.rs
  • crates/payload/types/src/lib.rs
  • crates/revm/src/evm.rs
  • crates/revm/src/precompiles.rs
  • crates/rpc/src/eth/call.rs
  • crates/rpc/src/eth/mod.rs
💤 Files with no reviewable changes (6)
  • crates/engine-tree-ext/src/lib.rs
  • crates/engine-tree-ext/src/gate.rs
  • crates/engine-tree-ext/tests/jade_boundary.rs
  • crates/engine-tree-ext/Cargo.toml
  • crates/engine-tree-ext/src/trie_updates.rs
  • crates/engine-tree-ext/src/payload_validator.rs

Comment thread crates/node/src/validator.rs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
Cargo.toml (1)

102-161: 🩺 Stability & Availability | 🔵 Trivial

Ensure thorough historical replay testing for the revm/reth upgrade.

The upgraded reth v2.4.0 and underlying revm dependencies introduce changes to core execution APIs. As highlighted by the provided context snippets, downstream paths—such as ExecutionResult log handling in receipt building, EvmFactory type bounds, and RPC gas allowance error mapping—rely closely on the specific semantics of these upgraded traits.

As per the PR objectives, full mainnet historical replay remains pending. It is critical to complete this replay to verify that the new dependency APIs do not introduce subtle consensus or runtime deviations before release.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Cargo.toml` around lines 102 - 161, Complete full mainnet historical replay
testing for the reth v2.4.0/revm upgrade, covering receipt construction through
ExecutionResult log handling, EvmFactory trait-bound paths, and RPC
gas-allowance error mapping. Validate replayed results against expected
consensus behavior and resolve any compatibility or runtime deviations before
release.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@Cargo.toml`:
- Around line 102-161: Complete full mainnet historical replay testing for the
reth v2.4.0/revm upgrade, covering receipt construction through ExecutionResult
log handling, EvmFactory trait-bound paths, and RPC gas-allowance error mapping.
Validate replayed results against expected consensus behavior and resolve any
compatibility or runtime deviations before release.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9b6edf28-c7f4-42a4-8a6f-8f2033f2191a

📥 Commits

Reviewing files that changed from the base of the PR and between 204c2ce and f1c0cac.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • Cargo.toml
  • crates/node/src/validator.rs
  • deny.toml
💤 Files with no reviewable changes (1)
  • deny.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/node/src/validator.rs

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