Skip to content

refactor: move OP EVM code into alloy-op-evm newtypes#19536

Merged
theochap merged 2 commits intodevelopfrom
theo/op-evm-newtypes
Mar 17, 2026
Merged

refactor: move OP EVM code into alloy-op-evm newtypes#19536
theochap merged 2 commits intodevelopfrom
theo/op-evm-newtypes

Conversation

@theochap
Copy link
Member

Summary

  • Introduce OpTx and OpTxError newtype wrappers in alloy-op-evm to hold all OP-specific EVM implementations previously in alloy-evm's op module
  • Move spec ID mapping and EvmEnv constructors as free functions (evm_env_for_op_block, evm_env_for_op_next_block)
  • Add TryIntoTxEnv<OpTx> for OpTransactionRequest behind rpc feature
  • Add TransactionEnv impl for OpTx behind reth feature
  • Update op-reth, kona, and custom-node example to use new types
  • Remove alloy-evm op feature usage from kona crates

This is the companion PR to alloy-rs/evm#312 which removes the OP-specific code from alloy-evm. Together they decouple alloy-evm from Optimism, using newtype wrappers to satisfy Rust's orphan rule.

Test plan

  • cargo clippy passes with no warnings
  • cargo test -p alloy-op-evm — 24 tests pass
  • Full workspace cargo check passes

🤖 Generated with Claude Code

@theochap theochap requested a review from a team as a code owner March 13, 2026 18:25
@wiz-inc-a178a98b5d
Copy link

wiz-inc-a178a98b5d bot commented Mar 13, 2026

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities 2 High 1 Medium 2 Low
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings -
Software Management Finding Software Management Findings -
Total 2 High 1 Medium 2 Low

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

❌ Patch coverage is 39.38679% with 257 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.3%. Comparing base (8106d08) to head (b9c5431).
⚠️ Report is 15 commits behind head on develop.

Files with missing lines Patch % Lines
rust/kona/bin/client/src/fpvm_evm/tx.rs 0.0% 122 Missing ⚠️
rust/op-reth/crates/evm/src/tx.rs 32.6% 95 Missing ⚠️
rust/alloy-op-evm/src/env.rs 84.0% 18 Missing ⚠️
rust/alloy-op-evm/src/error.rs 22.2% 14 Missing ⚠️
rust/op-reth/crates/rpc/src/error.rs 0.0% 6 Missing ⚠️
rust/kona/bin/host/src/interop/handler.rs 0.0% 1 Missing ⚠️
rust/kona/crates/proof/executor/src/test_utils.rs 50.0% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #19536      +/-   ##
===========================================
  Coverage     75.3%    75.3%              
===========================================
  Files          194      485     +291     
  Lines        11276    60694   +49418     
===========================================
+ Hits          8493    45735   +37242     
- Misses        2639    14959   +12320     
+ Partials       144        0     -144     
Flag Coverage Δ
cannon-go-tests-64 ?
contracts-bedrock-tests ?
unit 75.3% <39.3%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
rust/alloy-op-evm/src/block/mod.rs 96.4% <100.0%> (ø)
rust/alloy-op-evm/src/lib.rs 91.3% <100.0%> (ø)
rust/kona/bin/client/src/fpvm_evm/factory.rs 0.0% <ø> (ø)
rust/kona/crates/proof/executor/src/db/mod.rs 96.5% <ø> (ø)
rust/op-reth/crates/evm/src/lib.rs 99.7% <100.0%> (ø)
rust/kona/bin/host/src/interop/handler.rs 38.1% <0.0%> (ø)
rust/kona/crates/proof/executor/src/test_utils.rs 22.6% <50.0%> (ø)
rust/op-reth/crates/rpc/src/error.rs 0.0% <0.0%> (ø)
rust/alloy-op-evm/src/error.rs 22.2% <22.2%> (ø)
rust/alloy-op-evm/src/env.rs 84.0% <84.0%> (ø)
... and 2 more

... and 667 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@theochap theochap force-pushed the theo/op-evm-newtypes branch from cf8487f to f441447 Compare March 13, 2026 18:42
@theochap theochap force-pushed the theo/op-evm-newtypes branch from f441447 to 676e25d Compare March 16, 2026 19:42
@theochap
Copy link
Member Author

Last commit moves the newtype to kona and op-reth to remove the dependency of alloy-op-evm on reth. We need to make the OpEvmFactory generic over the transaction type

@theochap theochap force-pushed the theo/op-evm-newtypes branch from 4f845f0 to f2fe1e3 Compare March 17, 2026 02:10
@theochap theochap requested a review from a team as a code owner March 17, 2026 02:10
@theochap theochap requested a review from axelKingsley March 17, 2026 02:10
@theochap theochap force-pushed the theo/op-evm-newtypes branch from f2fe1e3 to 4506d7a Compare March 17, 2026 02:11
Introduce OpTx and OpTxError newtype wrappers in alloy-op-evm to hold
all OP-specific EVM implementations that were previously in alloy-evm's
`op` module. This satisfies Rust's orphan rule while decoupling alloy-evm
from Optimism-specific dependencies.

Changes:
- Add OpTx newtype wrapping OpTransaction<TxEnv> with all necessary trait
  impls (Transaction, TransactionEnv, FromRecoveredTx, FromTxWithEncoded,
  IntoTxEnv, OpTxEnv, TryIntoTxEnv)
- Add OpTxError newtype wrapping OpTransactionError with InvalidTxError
  and map_op_err helper
- Move spec ID mapping and EvmEnv constructors as free functions
  (evm_env_for_op_block, evm_env_for_op_next_block, evm_env_for_op_payload)
- Add rpc module with TryIntoTxEnv<OpTx> for OpTransactionRequest
- Update all downstream crates (op-reth, kona, custom-node example)
- Remove alloy-evm "op" feature usage from kona crates

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@theochap theochap force-pushed the theo/op-evm-newtypes branch from 4506d7a to c85490d Compare March 17, 2026 02:18
@theochap theochap force-pushed the theo/op-evm-newtypes branch from c85490d to b9c5431 Compare March 17, 2026 20:06
@theochap theochap added this pull request to the merge queue Mar 17, 2026
Merged via the queue into develop with commit a992bbd Mar 17, 2026
281 of 283 checks passed
@theochap theochap deleted the theo/op-evm-newtypes branch March 17, 2026 21:17
ClaytonNorthey92 pushed a commit to hemilabs/optimism that referenced this pull request Mar 19, 2026
…ism#19536)

* refactor: move OP-specific EVM code into alloy-op-evm newtypes

Introduce OpTx and OpTxError newtype wrappers in alloy-op-evm to hold
all OP-specific EVM implementations that were previously in alloy-evm's
`op` module. This satisfies Rust's orphan rule while decoupling alloy-evm
from Optimism-specific dependencies.

Changes:
- Add OpTx newtype wrapping OpTransaction<TxEnv> with all necessary trait
  impls (Transaction, TransactionEnv, FromRecoveredTx, FromTxWithEncoded,
  IntoTxEnv, OpTxEnv, TryIntoTxEnv)
- Add OpTxError newtype wrapping OpTransactionError with InvalidTxError
  and map_op_err helper
- Move spec ID mapping and EvmEnv constructors as free functions
  (evm_env_for_op_block, evm_env_for_op_next_block, evm_env_for_op_payload)
- Add rpc module with TryIntoTxEnv<OpTx> for OpTransactionRequest
- Update all downstream crates (op-reth, kona, custom-node example)
- Remove alloy-evm "op" feature usage from kona crates

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* chore(rust): move newtypes to op-reth and kona

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
ClaytonNorthey92 pushed a commit to hemilabs/optimism that referenced this pull request Mar 23, 2026
…ism#19536)

* refactor: move OP-specific EVM code into alloy-op-evm newtypes

Introduce OpTx and OpTxError newtype wrappers in alloy-op-evm to hold
all OP-specific EVM implementations that were previously in alloy-evm's
`op` module. This satisfies Rust's orphan rule while decoupling alloy-evm
from Optimism-specific dependencies.

Changes:
- Add OpTx newtype wrapping OpTransaction<TxEnv> with all necessary trait
  impls (Transaction, TransactionEnv, FromRecoveredTx, FromTxWithEncoded,
  IntoTxEnv, OpTxEnv, TryIntoTxEnv)
- Add OpTxError newtype wrapping OpTransactionError with InvalidTxError
  and map_op_err helper
- Move spec ID mapping and EvmEnv constructors as free functions
  (evm_env_for_op_block, evm_env_for_op_next_block, evm_env_for_op_payload)
- Add rpc module with TryIntoTxEnv<OpTx> for OpTransactionRequest
- Update all downstream crates (op-reth, kona, custom-node example)
- Remove alloy-evm "op" feature usage from kona crates

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* chore(rust): move newtypes to op-reth and kona

---------

Co-authored-by: Claude Opus 4.6 <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.

3 participants