feat: move RPC launch to add-ons (#11532)

This commit is contained in:
Arsenii Kulikov
2024-10-15 18:51:40 +04:00
committed by GitHub
parent a235f7214c
commit 6fb271036d
27 changed files with 547 additions and 518 deletions

View File

@ -7,15 +7,13 @@ use reth::{
args::{DiscoveryArgs, NetworkArgs, RpcServerArgs},
builder::{NodeBuilder, NodeConfig, NodeHandle},
network::PeersHandleProvider,
rpc::api::eth::{helpers::AddDevSigners, FullEthApiServer},
tasks::TaskManager,
};
use reth_chainspec::{EthChainSpec, EthereumHardforks};
use reth_db::{test_utils::TempDatabase, DatabaseEnv};
use reth_node_builder::{
components::NodeComponentsBuilder, rpc::EthApiBuilderProvider, FullNodeTypesAdapter, Node,
NodeAdapter, NodeAddOns, NodeComponents, NodeTypesWithDBAdapter, NodeTypesWithEngine,
RethFullAdapter,
components::NodeComponentsBuilder, rpc::RethRpcAddOns, FullNodeTypesAdapter, Node, NodeAdapter,
NodeComponents, NodeTypesWithDBAdapter, NodeTypesWithEngine, RethFullAdapter,
};
use reth_provider::providers::BlockchainProvider;
use tracing::{span, Level};
@ -56,10 +54,7 @@ where
TmpNodeAdapter<N>,
Components: NodeComponents<TmpNodeAdapter<N>, Network: PeersHandleProvider>,
>,
N::AddOns: NodeAddOns<
Adapter<N>,
EthApi: FullEthApiServer + AddDevSigners + EthApiBuilderProvider<Adapter<N>>,
>,
N::AddOns: RethRpcAddOns<Adapter<N>>,
{
let tasks = TaskManager::current();
let exec = tasks.executor();
@ -115,7 +110,8 @@ type TmpNodeAdapter<N> = FullNodeTypesAdapter<
BlockchainProvider<NodeTypesWithDBAdapter<N, TmpDB>>,
>;
type Adapter<N> = NodeAdapter<
/// Type alias for a `NodeAdapter`
pub type Adapter<N> = NodeAdapter<
RethFullAdapter<TmpDB, N>,
<<N as Node<TmpNodeAdapter<N>>>::ComponentsBuilder as NodeComponentsBuilder<
RethFullAdapter<TmpDB, N>,

View File

@ -18,7 +18,7 @@ use reth::{
},
};
use reth_chainspec::EthereumHardforks;
use reth_node_builder::{NodeAddOns, NodeTypesWithEngine};
use reth_node_builder::{rpc::RethRpcAddOns, NodeTypesWithEngine};
use reth_stages_types::StageId;
use tokio_stream::StreamExt;
@ -32,7 +32,7 @@ use crate::{
pub struct NodeTestContext<Node, AddOns>
where
Node: FullNodeComponents,
AddOns: NodeAddOns<Node>,
AddOns: RethRpcAddOns<Node>,
{
/// The core structure representing the full node.
pub inner: FullNode<Node, AddOns>,
@ -52,7 +52,7 @@ where
Node: FullNodeComponents,
Node::Types: NodeTypesWithEngine<ChainSpec: EthereumHardforks, Engine = Engine>,
Node::Network: PeersHandleProvider,
AddOns: NodeAddOns<Node>,
AddOns: RethRpcAddOns<Node>,
{
/// Creates a new test node
pub async fn new(node: FullNode<Node, AddOns>) -> eyre::Result<Self> {
@ -67,7 +67,7 @@ where
canonical_stream: node.provider.canonical_state_stream(),
_marker: PhantomData::<Engine>,
},
rpc: RpcTestContext { inner: node.rpc_registry },
rpc: RpcTestContext { inner: node.add_ons_handle.rpc_registry },
})
}