diff --git a/Cargo.lock b/Cargo.lock index 0a2a51eb6..8984f0280 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6916,6 +6916,7 @@ dependencies = [ "reth-primitives-traits", "reth-provider", "reth-revm", + "reth-rpc-eth-api", "reth-rpc-layer", "reth-testing-utils", "reth-transaction-pool", diff --git a/crates/op-rbuilder/Cargo.toml b/crates/op-rbuilder/Cargo.toml index 16ac91cbb..fd73b3d8e 100644 --- a/crates/op-rbuilder/Cargo.toml +++ b/crates/op-rbuilder/Cargo.toml @@ -40,6 +40,8 @@ reth-payload-util.workspace = true reth-transaction-pool.workspace = true reth-testing-utils.workspace = true reth-optimism-forks.workspace = true +reth-rpc-eth-api.workspace = true + alloy-primitives.workspace = true alloy-consensus.workspace = true alloy-eips.workspace = true diff --git a/crates/op-rbuilder/src/engine_api_ext.rs b/crates/op-rbuilder/src/engine_api_ext.rs new file mode 100644 index 000000000..ca0c214d2 --- /dev/null +++ b/crates/op-rbuilder/src/engine_api_ext.rs @@ -0,0 +1,56 @@ +//! Odyssey rpc logic. +//! +//! `eth_` namespace overrides: +//! +//! - `eth_getProof` will _ONLY_ return the storage proofs _WITHOUT_ an account proof _IF_ targeting +//! the withdrawal contract. Otherwise, it fallbacks to default behaviour. + +use alloy_eips::BlockId; +use alloy_primitives::{Address, B256}; +use alloy_rpc_types_engine::{ExecutionPayloadV3, PayloadStatus}; +use alloy_rpc_types_eth::EIP1186AccountProofResponse; +use jsonrpsee::{ + core::{async_trait, RpcResult}, + proc_macros::rpc, +}; +use reth_rpc_eth_api::helpers::FullEthApi; +use tracing::trace; + +#[rpc(server, client, namespace = "eth")] +pub trait EthApiOverride { + #[method(name = "newPayloadV3")] + async fn new_payload_v3( + &self, + payload: ExecutionPayloadV3, + versioned_hashes: Vec, + parent_beacon_block_root: B256, + ) -> RpcResult; +} + +/// Implementation of the `eth_` namespace override +#[derive(Debug)] +pub struct EthApiExt { + eth_api: Eth, +} + +impl EthApiExt { + /// Create a new `EthApiExt` module. + pub const fn new(eth_api: E) -> Self { + Self { eth_api } + } +} + +#[async_trait] +impl EthApiOverrideServer for EthApiExt +where + Eth: FullEthApi + Send + Sync + 'static, +{ + async fn new_payload_v3( + &self, + payload: ExecutionPayloadV3, + versioned_hashes: Vec, + parent_beacon_block_root: B256, + ) -> RpcResult { + panic!("Not implemented"); + } +} diff --git a/crates/op-rbuilder/src/main.rs b/crates/op-rbuilder/src/main.rs index 62eea9f4a..a76cf2975 100644 --- a/crates/op-rbuilder/src/main.rs +++ b/crates/op-rbuilder/src/main.rs @@ -5,6 +5,7 @@ use reth_optimism_cli::{chainspec::OpChainSpecParser, Cli}; use reth_optimism_node::node::OpAddOnsBuilder; use reth_optimism_node::OpNode; +use crate::engine_api_ext::EthApiOverrideServer; #[cfg(feature = "flashblocks")] use payload_builder::CustomOpPayloadBuilder; #[cfg(not(feature = "flashblocks"))] @@ -12,6 +13,8 @@ use payload_builder_vanilla::CustomOpPayloadBuilder; /// CLI argument parsing. pub mod args; +mod engine_api_ext; +use engine_api_ext::EthApiExt; pub mod generator; #[cfg(test)] mod integration; @@ -60,6 +63,13 @@ fn main() { Ok(()) }) + .extend_rpc_modules(move |ctx| { + ctx.modules.replace_configured( + EthApiExt::new(ctx.registry.eth_api().clone()).into_rpc(), + )?; + + Ok(()) + }) .launch() .await?;