chore(rpc): expose ethapi in node builder for op customisation (#9444)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Emilia Hane
2024-07-16 15:53:03 +02:00
committed by GitHub
parent fcc6307ada
commit 2aa94e9aee
53 changed files with 1117 additions and 664 deletions

View File

@ -46,7 +46,8 @@ use reth_node_api::{
};
use reth_node_core::{args::RpcServerArgs, node_config::NodeConfig};
use reth_node_ethereum::node::{
EthereumConsensusBuilder, EthereumExecutorBuilder, EthereumNetworkBuilder, EthereumPoolBuilder,
EthereumAddOns, EthereumConsensusBuilder, EthereumExecutorBuilder, EthereumNetworkBuilder,
EthereumPoolBuilder,
};
use reth_payload_builder::{
error::PayloadBuilderError, EthBuiltPayload, EthPayloadBuilderAttributes, PayloadBuilderHandle,
@ -212,8 +213,9 @@ where
EthereumExecutorBuilder,
EthereumConsensusBuilder,
>;
type AddOns = EthereumAddOns;
fn components_builder(self) -> Self::ComponentsBuilder {
fn components_builder(&self) -> Self::ComponentsBuilder {
ComponentsBuilder::default()
.node_types::<N>()
.pool(EthereumPoolBuilder::default())

View File

@ -22,7 +22,7 @@ use reth_chainspec::{Chain, ChainSpec, Head};
use reth_evm_ethereum::EthEvmConfig;
use reth_node_api::{ConfigureEvm, ConfigureEvmEnv, FullNodeTypes};
use reth_node_core::{args::RpcServerArgs, node_config::NodeConfig};
use reth_node_ethereum::{EthExecutorProvider, EthereumNode};
use reth_node_ethereum::{node::EthereumAddOns, EthExecutorProvider, EthereumNode};
use reth_primitives::{
revm_primitives::{AnalysisKind, CfgEnvWithHandlerCfg, TxEnv},
Address, Header, TransactionSigned, U256,
@ -180,6 +180,7 @@ async fn main() -> eyre::Result<()> {
.with_types::<EthereumNode>()
// use default ethereum components but with our executor
.with_components(EthereumNode::components().executor(MyExecutorBuilder::default()))
.with_add_ons::<EthereumAddOns>()
.launch()
.await
.unwrap();

View File

@ -10,7 +10,7 @@ use reth::{
blobstore::InMemoryBlobStore, EthTransactionPool, TransactionValidationTaskExecutor,
},
};
use reth_node_ethereum::EthereumNode;
use reth_node_ethereum::{node::EthereumAddOns, EthereumNode};
use reth_tracing::tracing::{debug, info};
use reth_transaction_pool::PoolConfig;
@ -23,6 +23,7 @@ fn main() {
// Configure the components of the node
// use default ethereum components but use our custom pool
.with_components(EthereumNode::components().pool(CustomPoolBuilder::default()))
.with_add_ons::<EthereumAddOns>()
.launch()
.await?;

View File

@ -20,7 +20,7 @@ use reth::{
transaction_pool::TransactionPool,
};
use reth_basic_payload_builder::BasicPayloadJobGeneratorConfig;
use reth_node_ethereum::{EthEngineTypes, EthereumNode};
use reth_node_ethereum::{node::EthereumAddOns, EthEngineTypes, EthereumNode};
use reth_payload_builder::PayloadBuilderService;
pub mod generator;
@ -78,6 +78,7 @@ fn main() {
.with_components(
EthereumNode::components().payload(CustomPayloadBuilder::default()),
)
.with_add_ons::<EthereumAddOns>()
.launch()
.await?;

View File

@ -19,6 +19,7 @@ use reth::{
providers::{BlockchainProvider, StaticFileProvider},
ProviderFactory,
},
rpc::eth::EthApi,
utils::open_db_read_only,
};
use reth_chainspec::ChainSpecBuilder;
@ -27,7 +28,7 @@ use reth_db_api::models::ClientVersion;
// Bringing up the RPC
use reth::rpc::builder::{
EthApiBuild, RethRpcModule, RpcModuleBuilder, RpcServerConfig, TransportRpcModuleConfig,
RethRpcModule, RpcModuleBuilder, RpcServerConfig, TransportRpcModuleConfig,
};
// Configuring the network parts, ideally also wouldn't need to think about this.
use myrpc_ext::{MyRpcExt, MyRpcExtApiServer};
@ -70,7 +71,7 @@ async fn main() -> eyre::Result<()> {
// Pick which namespaces to expose.
let config = TransportRpcModuleConfig::default().with_http([RethRpcModule::Eth]);
let mut server = rpc_builder.build(config, EthApiBuild::build);
let mut server = rpc_builder.build(config, Box::new(EthApi::with_spawner));
// Add a custom rpc namespace
let custom_rpc = MyRpcExt { provider };

View File

@ -21,7 +21,7 @@ use reth::{
use reth_chainspec::{Chain, ChainSpec};
use reth_node_api::{ConfigureEvm, ConfigureEvmEnv, FullNodeTypes};
use reth_node_core::{args::RpcServerArgs, node_config::NodeConfig};
use reth_node_ethereum::{EthEvmConfig, EthExecutorProvider, EthereumNode};
use reth_node_ethereum::{node::EthereumAddOns, EthEvmConfig, EthExecutorProvider, EthereumNode};
use reth_primitives::{
revm_primitives::{SpecId, StatefulPrecompileMut},
Header, TransactionSigned,
@ -244,6 +244,7 @@ async fn main() -> eyre::Result<()> {
.with_types::<EthereumNode>()
// use default ethereum components but with our executor
.with_components(EthereumNode::components().executor(MyExecutorBuilder::default()))
.with_add_ons::<EthereumAddOns>()
.launch()
.await
.unwrap();