Thread execution layer into ClientBuilder

This commit is contained in:
Paul Hauner
2021-09-25 11:49:12 +10:00
parent 95ef497e7b
commit 81a62e33d7
4 changed files with 20 additions and 0 deletions

1
Cargo.lock generated
View File

@@ -900,6 +900,7 @@ dependencies = [
"eth2_config", "eth2_config",
"eth2_libp2p", "eth2_libp2p",
"eth2_ssz", "eth2_ssz",
"execution_layer",
"futures", "futures",
"genesis", "genesis",
"http_api", "http_api",

View File

@@ -47,3 +47,5 @@ http_metrics = { path = "../http_metrics" }
slasher = { path = "../../slasher" } slasher = { path = "../../slasher" }
slasher_service = { path = "../../slasher/service" } slasher_service = { path = "../../slasher/service" }
monitoring_api = {path = "../../common/monitoring_api"} monitoring_api = {path = "../../common/monitoring_api"}
sensitive_url = { path = "../../common/sensitive_url" }
execution_layer = { path = "../execution_layer" }

View File

@@ -17,6 +17,7 @@ use eth2::{
BeaconNodeHttpClient, Error as ApiError, Timeouts, BeaconNodeHttpClient, Error as ApiError, Timeouts,
}; };
use eth2_libp2p::NetworkGlobals; use eth2_libp2p::NetworkGlobals;
use execution_layer::ExecutionLayer;
use genesis::{interop_genesis_state, Eth1GenesisService}; use genesis::{interop_genesis_state, Eth1GenesisService};
use monitoring_api::{MonitoringHttpClient, ProcessType}; use monitoring_api::{MonitoringHttpClient, ProcessType};
use network::{NetworkConfig, NetworkMessage, NetworkService}; use network::{NetworkConfig, NetworkMessage, NetworkService};
@@ -146,6 +147,19 @@ where
None None
}; };
let execution_layer = if let Some(execution_endpoints) = config.execution_endpoints {
let context = runtime_context.service_context("exec".into());
let execution_layer = ExecutionLayer::from_urls(
execution_endpoints,
context.executor.clone(),
context.log().clone(),
)
.map_err(|e| format!("unable to start execution layer endpoints: {:?}", e))?;
Some(execution_layer)
} else {
None
};
let builder = BeaconChainBuilder::new(eth_spec_instance) let builder = BeaconChainBuilder::new(eth_spec_instance)
.logger(context.log().clone()) .logger(context.log().clone())
.store(store) .store(store)
@@ -154,6 +168,7 @@ where
.disabled_forks(disabled_forks) .disabled_forks(disabled_forks)
.graffiti(graffiti) .graffiti(graffiti)
.event_handler(event_handler) .event_handler(event_handler)
.execution_layer(execution_layer)
.monitor_validators( .monitor_validators(
config.validator_monitor_auto, config.validator_monitor_auto,
config.validator_monitor_pubkeys.clone(), config.validator_monitor_pubkeys.clone(),

View File

@@ -74,6 +74,7 @@ pub struct Config {
pub network: network::NetworkConfig, pub network: network::NetworkConfig,
pub chain: beacon_chain::ChainConfig, pub chain: beacon_chain::ChainConfig,
pub eth1: eth1::Config, pub eth1: eth1::Config,
pub execution_endpoints: Option<Vec<SensitiveUrl>>,
pub http_api: http_api::Config, pub http_api: http_api::Config,
pub http_metrics: http_metrics::Config, pub http_metrics: http_metrics::Config,
pub monitoring_api: Option<monitoring_api::Config>, pub monitoring_api: Option<monitoring_api::Config>,
@@ -94,6 +95,7 @@ impl Default for Config {
dummy_eth1_backend: false, dummy_eth1_backend: false,
sync_eth1_chain: false, sync_eth1_chain: false,
eth1: <_>::default(), eth1: <_>::default(),
execution_endpoints: None,
disabled_forks: Vec::new(), disabled_forks: Vec::new(),
graffiti: Graffiti::default(), graffiti: Graffiti::default(),
http_api: <_>::default(), http_api: <_>::default(),