From fbca1ccf9d8093661bce259898c7420226b054df Mon Sep 17 00:00:00 2001 From: ltitanb Date: Thu, 10 Oct 2024 16:32:53 +0100 Subject: [PATCH] fix false loader path --- config.example.toml | 2 +- crates/common/src/config/mod.rs | 12 +++++++++--- crates/common/src/types.rs | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/config.example.toml b/config.example.toml index 93b9e11f..6334aae1 100644 --- a/config.example.toml +++ b/config.example.toml @@ -2,7 +2,7 @@ # Some fields are optional and can be omitted, in which case the default value, if present, will be used. # Chain spec ID. Supported values: -# A network ID. Supported values: Mainnet, Holesky, Helder. +# A network ID. Supported values: Mainnet, Holesky, Sepolia, Helder. # A path to a chain spec file, either in .json format (e.g., as returned by the beacon endpoint /eth/v1/config/spec), or in .yml format (see examples in tests/data). # A custom object, e.g., chain = { genesis_time_secs = 1695902400, slot_time_secs = 12, genesis_fork_version = "0x01017000" }. chain = "Holesky" diff --git a/crates/common/src/config/mod.rs b/crates/common/src/config/mod.rs index a025740f..fa3fb560 100644 --- a/crates/common/src/config/mod.rs +++ b/crates/common/src/config/mod.rs @@ -3,7 +3,7 @@ use std::path::PathBuf; use eyre::Result; use serde::{Deserialize, Serialize}; -use crate::types::{load_chain_from_file, Chain}; +use crate::types::{load_chain_from_file, Chain, ChainLoader}; mod constants; mod log; @@ -73,7 +73,13 @@ impl CommitBoostConfig { /// Returns the path to the chain spec file if any pub fn chain_spec_file(path: &str) -> Option { match load_from_file::(path) { - Ok(config) => Some(config.chain), + Ok(config) => { + if let ChainLoader::Path(path_buf) = config.chain { + Some(path_buf) + } else { + None + } + } Err(_) => None, } } @@ -82,7 +88,7 @@ impl CommitBoostConfig { /// Helper struct to load the chain spec file #[derive(Deserialize)] struct ChainConfig { - chain: PathBuf, + chain: ChainLoader, } /// Helper struct to load the rest of the config diff --git a/crates/common/src/types.rs b/crates/common/src/types.rs index a7aeba58..c49323a6 100644 --- a/crates/common/src/types.rs +++ b/crates/common/src/types.rs @@ -161,7 +161,7 @@ impl From for Chain { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -enum ChainLoader { +pub enum ChainLoader { Known(KnownChain), Path(PathBuf), Custom { genesis_time_secs: u64, slot_time_secs: u64, genesis_fork_version: Bytes },