chore(validator_client): Read genesis time and genesis validators root from eth2_network_config (#8638)

#5019


  If there is a known eth2_network_config, we read the genesis time and validators root from the config.


Co-Authored-By: Jimmy Chu <898091+jimmychu0807@users.noreply.github.com>
This commit is contained in:
Jimmy Chu
2026-01-14 14:25:07 +08:00
committed by GitHub
parent c91345782a
commit f584521e85
3 changed files with 36 additions and 5 deletions

View File

@@ -364,11 +364,22 @@ impl<E: EthSpec> ProductionValidatorClient<E> {
context.eth2_config.spec.clone(),
);
// Perform some potentially long-running initialization tasks.
let (genesis_time, genesis_validators_root) = tokio::select! {
tuple = init_from_beacon_node::<E>(&beacon_nodes, &proposer_nodes) => tuple?,
() = context.executor.exit() => return Err("Shutting down".to_string())
};
let (genesis_time, genesis_validators_root) =
if let Some(eth2_network_config) = context.eth2_network_config.as_ref() {
let time = eth2_network_config
.genesis_time::<E>()?
.ok_or("no genesis time")?;
let root = eth2_network_config
.genesis_validators_root::<E>()?
.ok_or("no genesis validators root")?;
(time, root)
} else {
// Perform some potentially long-running initialization tasks.
tokio::select! {
tuple = init_from_beacon_node::<E>(&beacon_nodes, &proposer_nodes) => tuple?,
() = context.executor.exit() => return Err("Shutting down".to_string()),
}
};
// Update the metrics server.
if let Some(ctx) = &validator_metrics_ctx {