feat(sync): beacon consensus engine (#1845)

This commit is contained in:
Roman Krasiuk
2023-03-23 20:18:19 +02:00
committed by GitHub
parent 84af91737d
commit ce40bea46e
27 changed files with 1918 additions and 1141 deletions

View File

@@ -1,6 +1,7 @@
pub use jsonrpsee::server::ServerBuilder;
use jsonrpsee::{core::Error as RpcError, server::ServerHandle, RpcModule};
use reth_network_api::{NetworkInfo, Peers};
use reth_primitives::ChainSpec;
use reth_provider::{BlockProvider, EvmEnvProvider, HeaderProvider, StateProviderFactory};
use reth_rpc::{
eth::cache::EthStateCache, AuthLayer, EngineApi, EthApi, JwtAuthValidator, JwtSecret,
@@ -9,14 +10,16 @@ use reth_rpc_api::servers::*;
use reth_rpc_engine_api::EngineApiHandle;
use reth_tasks::TaskSpawner;
use reth_transaction_pool::TransactionPool;
use std::net::SocketAddr;
use std::{net::SocketAddr, sync::Arc};
/// Configure and launch an auth server with `engine` and a _new_ `eth` namespace.
#[allow(clippy::too_many_arguments)]
pub async fn launch<Client, Pool, Network, Tasks>(
client: Client,
pool: Pool,
network: Network,
executor: Tasks,
chain_spec: Arc<ChainSpec>,
handle: EngineApiHandle,
socket_addr: SocketAddr,
secret: JwtSecret,
@@ -35,13 +38,20 @@ where
{
// spawn a new cache task
let eth_cache = EthStateCache::spawn_with(client.clone(), Default::default(), executor);
launch_with_eth_api(EthApi::new(client, pool, network, eth_cache), handle, socket_addr, secret)
.await
launch_with_eth_api(
EthApi::new(client, pool, network, eth_cache),
chain_spec,
handle,
socket_addr,
secret,
)
.await
}
/// Configure and launch an auth server with existing EthApi implementation.
pub async fn launch_with_eth_api<Client, Pool, Network>(
eth_api: EthApi<Client, Pool, Network>,
chain_spec: Arc<ChainSpec>,
handle: EngineApiHandle,
socket_addr: SocketAddr,
secret: JwtSecret,
@@ -59,7 +69,7 @@ where
{
// Configure the module and start the server.
let mut module = RpcModule::new(());
module.merge(EngineApi::new(handle).into_rpc()).expect("No conflicting methods");
module.merge(EngineApi::new(chain_spec, handle).into_rpc()).expect("No conflicting methods");
module.merge(eth_api.into_rpc()).expect("No conflicting methods");
// Create auth middleware.