diff --git a/rust/op-reth/crates/node/src/node.rs b/rust/op-reth/crates/node/src/node.rs index 669b54422b7..7ba5fc027f5 100644 --- a/rust/op-reth/crates/node/src/node.rs +++ b/rust/op-reth/crates/node/src/node.rs @@ -52,8 +52,12 @@ use reth_optimism_rpc::{ }; use reth_optimism_storage::OpStorage; use reth_optimism_txpool::{OpPool, OpPooledTx, supervisor::SupervisorClient}; +use reth_primitives_traits::header::HeaderMut; use reth_provider::{CanonStateSubscriptions, providers::ProviderFactoryBuilder}; -use reth_rpc_api::{DebugApiServer, L2EthApiExtServer, eth::RpcTypes}; +use reth_rpc_api::{ + DebugApiServer, EthConfigApiServer, L2EthApiExtServer, + eth::{RpcTypes, helpers::config::EthConfigHandler}, +}; use reth_rpc_server_types::RethRpcModule; use reth_tracing::tracing::{debug, info}; use reth_transaction_pool::{ @@ -590,7 +594,10 @@ impl NodeAddOns for OpAddOns where N: FullNodeComponents< - Types: NodeTypes, + Types: NodeTypes< + ChainSpec: OpHardforks + Hardforks, + Primitives: OpPayloadPrimitives<_Header: HeaderMut>, + >, Evm: ConfigureEvm< NextBlockEnvCtx: BuildNextEnv< OpPayloadBuilderAttributes>, @@ -623,6 +630,9 @@ where .. } = self; + let eth_config = + EthConfigHandler::new(ctx.node.provider().clone(), ctx.node.evm_config().clone()); + let maybe_pre_bedrock_historical_rpc = historical_rpc .and_then(|historical_rpc| { ctx.node @@ -676,6 +686,8 @@ where let reth_node_builder::rpc::RpcModuleContainer { modules, auth_module, registry } = container; + modules.merge_if_module_configured(RethRpcModule::Eth, eth_config.into_rpc())?; + debug!(target: "reth::cli", "Installing debug payload witness rpc endpoint"); modules.merge_if_module_configured(RethRpcModule::Debug, debug_ext.into_rpc())?; @@ -715,7 +727,10 @@ impl RethRpcAddOns for OpAddOns where N: FullNodeComponents< - Types: NodeTypes, + Types: NodeTypes< + ChainSpec: OpHardforks + Hardforks, + Primitives: OpPayloadPrimitives<_Header: HeaderMut>, + >, Evm: ConfigureEvm< NextBlockEnvCtx: BuildNextEnv< OpPayloadBuilderAttributes>, diff --git a/rust/op-reth/crates/node/tests/it/rpc.rs b/rust/op-reth/crates/node/tests/it/rpc.rs index 5818a2c7a03..fea6bfe3d19 100644 --- a/rust/op-reth/crates/node/tests/it/rpc.rs +++ b/rust/op-reth/crates/node/tests/it/rpc.rs @@ -8,7 +8,7 @@ use reth_node_core::{ }; use reth_optimism_chainspec::BASE_MAINNET; use reth_optimism_node::OpNode; -use reth_rpc_api::servers::AdminApiServer; +use reth_rpc_api::{EthConfigApiClient, servers::AdminApiServer}; use reth_tasks::Runtime; // @@ -41,3 +41,27 @@ async fn test_admin_external_ip() -> eyre::Result<()> { Ok(()) } + +#[tokio::test] +async fn test_eth_config_endpoint_exists() -> eyre::Result<()> { + reth_tracing::init_test_tracing(); + + let exec = Runtime::test(); + + // Node setup + let mut network_args = NetworkArgs::default().with_unused_ports(); + network_args.discovery.discv5_port = 0; + network_args.discovery.discv5_port_ipv6 = 0; + let node_config = NodeConfig::test() + .map_chain(BASE_MAINNET.clone()) + .with_network(network_args) + .with_rpc(RpcServerArgs::default().with_unused_ports().with_http()); + + let NodeHandle { node, node_exit_future: _ } = + NodeBuilder::new(node_config).testing_node(exec).node(OpNode::default()).launch().await?; + + let client = node.add_ons_handle.rpc_server_handles().rpc.http_client().unwrap(); + let _config = client.config().await?; + + Ok(()) +} diff --git a/rust/op-reth/examples/custom-node/src/primitives/header.rs b/rust/op-reth/examples/custom-node/src/primitives/header.rs index 049f655c6a4..29b634baf1c 100644 --- a/rust/op-reth/examples/custom-node/src/primitives/header.rs +++ b/rust/op-reth/examples/custom-node/src/primitives/header.rs @@ -2,7 +2,7 @@ use alloy_consensus::Header; use alloy_primitives::{Address, B64, B256, BlockNumber, Bloom, Bytes, Sealable, U256}; use alloy_rlp::{Encodable, RlpDecodable, RlpEncodable}; use reth_codecs::Compact; -use reth_primitives_traits::{BlockHeader, InMemorySize}; +use reth_primitives_traits::{BlockHeader, InMemorySize, header::HeaderMut}; use revm_primitives::keccak256; use serde::{Deserialize, Serialize}; @@ -34,6 +34,28 @@ pub struct CustomHeader { pub extension: u64, } +impl HeaderMut for CustomHeader { + fn set_parent_hash(&mut self, hash: alloy_primitives::BlockHash) { + self.inner.parent_hash = hash; + } + + fn set_block_number(&mut self, number: BlockNumber) { + self.inner.number = number; + } + + fn set_timestamp(&mut self, timestamp: u64) { + self.inner.timestamp = timestamp; + } + + fn set_state_root(&mut self, state_root: B256) { + self.inner.state_root = state_root; + } + + fn set_difficulty(&mut self, difficulty: U256) { + self.inner.difficulty = difficulty; + } +} + impl From
for CustomHeader { fn from(value: Header) -> Self { CustomHeader { inner: value, extension: 0 }