Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 9 additions & 3 deletions crates/common/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -73,7 +73,13 @@ impl CommitBoostConfig {
/// Returns the path to the chain spec file if any
pub fn chain_spec_file(path: &str) -> Option<PathBuf> {
match load_from_file::<ChainConfig>(path) {
Ok(config) => Some(config.chain),
Ok(config) => {
if let ChainLoader::Path(path_buf) = config.chain {
Some(path_buf)
} else {
None
}
}
Err(_) => None,
}
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion crates/common/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl From<KnownChain> 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 },
Expand Down