feat(rpc): integrate eth cache and task executor in pipeline (#1596)

This commit is contained in:
Matthias Seitz
2023-03-01 23:46:57 +01:00
committed by GitHub
parent ad0ce8cf1a
commit 626c076c85
14 changed files with 239 additions and 76 deletions

View File

@ -11,6 +11,7 @@ use reth_rpc_builder::{
RpcServerHandle, ServerBuilder, TransportRpcModuleConfig,
};
use reth_rpc_engine_api::EngineApiHandle;
use reth_tasks::TaskSpawner;
use reth_transaction_pool::TransactionPool;
use std::{
net::{IpAddr, Ipv4Addr, SocketAddr},
@ -103,11 +104,12 @@ impl RpcServerArgs {
}
/// Convenience function for starting a rpc server with configs which extracted from cli args.
pub(crate) async fn start_rpc_server<Client, Pool, Network>(
pub(crate) async fn start_rpc_server<Client, Pool, Network, Tasks>(
&self,
client: Client,
pool: Pool,
network: Network,
executor: Tasks,
) -> Result<RpcServerHandle, RpcError>
where
Client: BlockProvider
@ -115,9 +117,11 @@ impl RpcServerArgs {
+ StateProviderFactory
+ EvmEnvProvider
+ Clone
+ Unpin
+ 'static,
Pool: TransactionPool + Clone + 'static,
Network: NetworkInfo + Peers + Clone + 'static,
Tasks: TaskSpawner + Clone + 'static,
{
reth_rpc_builder::launch(
client,
@ -125,16 +129,18 @@ impl RpcServerArgs {
network,
self.transport_rpc_module_config(),
self.rpc_server_config(),
executor,
)
.await
}
/// Create Engine API server.
pub(crate) async fn start_auth_server<Client, Pool, Network>(
pub(crate) async fn start_auth_server<Client, Pool, Network, Tasks>(
&self,
client: Client,
pool: Pool,
network: Network,
executor: Tasks,
handle: EngineApiHandle,
) -> Result<ServerHandle, RpcError>
where
@ -143,16 +149,27 @@ impl RpcServerArgs {
+ StateProviderFactory
+ EvmEnvProvider
+ Clone
+ Unpin
+ 'static,
Pool: TransactionPool + Clone + 'static,
Network: NetworkInfo + Peers + Clone + 'static,
Tasks: TaskSpawner + Clone + 'static,
{
let socket_address = SocketAddr::new(
self.auth_addr.unwrap_or(IpAddr::V4(Ipv4Addr::UNSPECIFIED)),
self.auth_port.unwrap_or(constants::DEFAULT_AUTH_PORT),
);
let secret = self.jwt_secret().map_err(|err| RpcError::Custom(err.to_string()))?;
reth_rpc_builder::auth::launch(client, pool, network, handle, socket_address, secret).await
reth_rpc_builder::auth::launch(
client,
pool,
network,
executor,
handle,
socket_address,
secret,
)
.await
}
/// Creates the [TransportRpcModuleConfig] from cli args.

View File

@ -160,7 +160,12 @@ impl Command {
let _rpc_server = self
.rpc
.start_rpc_server(shareable_db.clone(), test_transaction_pool.clone(), network.clone())
.start_rpc_server(
shareable_db.clone(),
test_transaction_pool.clone(),
network.clone(),
ctx.task_executor.clone(),
)
.await?;
info!(target: "reth::cli", "Started RPC server");
@ -174,6 +179,7 @@ impl Command {
shareable_db,
test_transaction_pool,
network.clone(),
ctx.task_executor.clone(),
engine_api_handle,
)
.await?;