Skip to content

refactor: eliminate op-rbuilder fork via [patch] approach#9

Open
davidtai wants to merge 2 commits intotea-rethfrom
feat/tea-precompiles-patch
Open

refactor: eliminate op-rbuilder fork via [patch] approach#9
davidtai wants to merge 2 commits intotea-rethfrom
feat/tea-precompiles-patch

Conversation

@davidtai
Copy link
Copy Markdown
Collaborator

@davidtai davidtai commented Apr 8, 2026

Summary

  • Extracts Tea precompiles (GPG verify, L1 cost multiplier, chain ID detection) into a new tea-precompiles crate
  • Injects them into OpEvmFactory at the alloy-op-evm layer (feature-gated behind std)
  • Adds op-rbuilder (Flashbots v0.4.1) as a rust/ workspace member — no separate fork or submodule needed
  • Op-rbuilder imports TeaOpEvmConfig and TeaExecutorBuilder from tea_reth::node

Architecture

tea-precompiles  → GPG precompile, L1 cost multiplier, precompile map
    ↑
alloy-op-evm    → OpEvmFactory injects Tea precompiles (feature-gated)
    ↑
tea-reth        → TeaEvmFactory, TeaOpEvmConfig, TeaExecutorBuilder
    ↑
op-rbuilder     → imports from tea_reth::node, builds blocks with Tea EVM

All crates in the same rust/ workspace — shared dependency resolution, no cross-workspace conflicts.

Op-rbuilder changes (3 files)

File Change
Cargo.toml Added pgp dep for GPG precompile
tx_signer.rs secp256k1 0.30→0.31 API (from_digest, thread_rng)
args/playground.rs SecretKey cross-version conversion via bytes

Op-rbuilder's Tea integration (type swaps in context/payload/service/syncer_ctx/launcher) is unchanged from the original PR #1 pattern — it just resolves from the workspace now instead of an external dep.

Build verification (Docker, ARM64)

  • cargo check -p tea-precompiles — compiles
  • cargo check -p alloy-op-evm — compiles
  • cargo check -p tea-reth — compiles
  • cargo check -p op-rbuildercompiles
  • cargo test -p tea-precompiles — 44 tests pass
  • cargo test -p tea-reth — 9 integration tests pass

🤖 Generated with Claude Code

Copy link
Copy Markdown

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@davidtai davidtai force-pushed the feat/tea-precompiles-patch branch 2 times, most recently from e7b9cb7 to cec5ae7 Compare April 8, 2026 22:31
@davidtai
Copy link
Copy Markdown
Collaborator Author

davidtai commented Apr 8, 2026

Audit & Build Verification

Architecture: ✅ Correct approach

Injecting Tea's EVM customizations at the alloy-op-evm layer via #[cfg(feature = "tea-precompiles")] is the right strategy:

  • Single injection point — every consumer of OpEvmFactory (tea-reth, op-rbuilder, kona) automatically gets Tea's EVM changes
  • Zero source changes to op-rbuilder — only Cargo.toml [patch.crates-io] needed
  • Clean feature gateno_std builds (kona fault proof clients) get vanilla OP behavior
  • Acyclic dependency graph — no circular deps

Build Verification (Docker, ARM64)

Target Result
cargo check -p tea-precompiles
cargo test -p tea-precompiles ✅ 44/44
cargo check -p alloy-op-evm (std)
cargo test -p alloy-op-evm ✅ 6/6
cargo check -p alloy-op-evm --no-default-features ✅ (4 mut warnings)
cargo check -p tea-reth ✅ (after fix)
cargo test -p tea-reth --test evm_integration ✅ 9/9 (after fix)

Bugs Found & Fixed (pushed in 04ddfb7)

Bug 1: Missing trait import (tea-reth/src/main.rs)

  • node.add_ons() requires the Node trait in scope
  • Fix: use reth_op::node::builder::Node;

Bug 2: OpEvmFactory is #[non_exhaustive] (tea-reth/tests/evm_integration.rs, 9 occurrences)

  • let factory = OpEvmFactory; — struct literal construction not allowed from outside crate
  • Fix: OpEvmFactory::default()

Note: Pre-existing OnceLock spec caching

tea_precompiles() uses a single static INSTANCE: OnceLock<Precompiles> — the first spec_id permanently determines the precompile set. This was the same pattern in the old TeaPrecompiles code and is fine in practice (OP nodes restart for hardforks), but worth tracking if multi-spec support is ever needed.

Minor: no_std path mut warnings

The #[cfg(not(feature = "tea-precompiles"))] code paths in alloy-op-evm don't mutate db or op_evm, so the mut keywords produce warnings. Could fix with conditional mut annotations.

Extract Tea-specific precompiles (GPG verify, L1 cost multiplier, chain ID
detection) into a new `tea-precompiles` crate. Inject them into `OpEvmFactory`
at the `alloy-op-evm` layer via feature-gated dependency, so tea-reth gets
Tea's EVM automatically without a custom executor builder.

Op-rbuilder submodule points to the `tea` branch of teaxyz/tea-op-rbuilder
(existing minimal fork: 6 files, 21 lines) which swaps TeaOpEvmConfig into
the block builder. This fork remains necessary because op-rbuilder's dep
versions (thiserror 1.x, reqwest 0.12) are incompatible with the rust/
workspace (thiserror 2.x, reqwest 0.13).

Changes:
- New: rust/tea-precompiles/ (self-contained GPG precompile + L1 cost)
- Modified: rust/alloy-op-evm/ (OpEvmFactory uses Tea precompiles when std)
- Simplified: rust/tea-reth/ (removed TeaEvmFactory, evm/, precompiles/)
- Added: just build-op-rbuilder and patch-op-rbuilder recipes in justfile

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@davidtai davidtai force-pushed the feat/tea-precompiles-patch branch from 04ddfb7 to 2e735ca Compare April 9, 2026 00:45
Add op-rbuilder (Flashbots v0.4.1) as a workspace member of the rust/
workspace. This eliminates the need for a separate fork or submodule —
op-rbuilder shares the same dependency resolution as tea-reth, alloy-op-evm,
and tea-precompiles.

Changes to op-rbuilder source (3 files, minimal):
- tx_signer.rs: secp256k1 0.30→0.31 API (from_digest, thread_rng)
- args/playground.rs: SecretKey cross-version conversion via bytes
- Cargo.toml: added pgp dep for GPG precompile

The Tea integration uses tea_reth::node::{TeaOpEvmConfig, TeaExecutorBuilder}
which op-rbuilder imports — same pattern as the original tea branch fork but
now resolved entirely within the rust/ workspace.

Added to rust/Cargo.toml:
- op-rbuilder workspace members
- Missing workspace deps (axum, ctor, dotenvy, etc.)
- libp2p features, moka future feature, alloy-sol-types json feature

Co-Authored-By: Claude Opus 4.6 (1M context) <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.

1 participant