Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions rust/op-reth/crates/node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -590,7 +594,10 @@ impl<N, EthB, PVB, EB, EVB, RpcMiddleware> NodeAddOns<N>
for OpAddOns<N, EthB, PVB, EB, EVB, RpcMiddleware>
where
N: FullNodeComponents<
Types: NodeTypes<ChainSpec: OpHardforks, Primitives: OpPayloadPrimitives>,
Types: NodeTypes<
ChainSpec: OpHardforks + Hardforks,
Primitives: OpPayloadPrimitives<_Header: HeaderMut>,
>,
Evm: ConfigureEvm<
NextBlockEnvCtx: BuildNextEnv<
OpPayloadBuilderAttributes<TxTy<N::Types>>,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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())?;

Expand Down Expand Up @@ -715,7 +727,10 @@ impl<N, EthB, PVB, EB, EVB, RpcMiddleware> RethRpcAddOns<N>
for OpAddOns<N, EthB, PVB, EB, EVB, RpcMiddleware>
where
N: FullNodeComponents<
Types: NodeTypes<ChainSpec: OpHardforks, Primitives: OpPayloadPrimitives>,
Types: NodeTypes<
ChainSpec: OpHardforks + Hardforks,
Primitives: OpPayloadPrimitives<_Header: HeaderMut>,
>,
Evm: ConfigureEvm<
NextBlockEnvCtx: BuildNextEnv<
OpPayloadBuilderAttributes<TxTy<N::Types>>,
Expand Down
26 changes: 25 additions & 1 deletion rust/op-reth/crates/node/tests/it/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

// <https://github.com/paradigmxyz/reth/issues/19765>
Expand Down Expand Up @@ -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(())
}
24 changes: 23 additions & 1 deletion rust/op-reth/examples/custom-node/src/primitives/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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<Header> for CustomHeader {
fn from(value: Header) -> Self {
CustomHeader { inner: value, extension: 0 }
Expand Down
Loading