Skip to content

Commit d449d22

Browse files
authored
fix: false loader path (#153)
1 parent 5b51899 commit d449d22

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

config.example.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Some fields are optional and can be omitted, in which case the default value, if present, will be used.
33

44
# Chain spec ID. Supported values:
5-
# A network ID. Supported values: Mainnet, Holesky, Helder.
5+
# A network ID. Supported values: Mainnet, Holesky, Sepolia, Helder.
66
# 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).
77
# A custom object, e.g., chain = { genesis_time_secs = 1695902400, slot_time_secs = 12, genesis_fork_version = "0x01017000" }.
88
chain = "Holesky"

crates/common/src/config/mod.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::path::PathBuf;
33
use eyre::Result;
44
use serde::{Deserialize, Serialize};
55

6-
use crate::types::{load_chain_from_file, Chain};
6+
use crate::types::{load_chain_from_file, Chain, ChainLoader};
77

88
mod constants;
99
mod log;
@@ -73,7 +73,13 @@ impl CommitBoostConfig {
7373
/// Returns the path to the chain spec file if any
7474
pub fn chain_spec_file(path: &str) -> Option<PathBuf> {
7575
match load_from_file::<ChainConfig>(path) {
76-
Ok(config) => Some(config.chain),
76+
Ok(config) => {
77+
if let ChainLoader::Path(path_buf) = config.chain {
78+
Some(path_buf)
79+
} else {
80+
None
81+
}
82+
}
7783
Err(_) => None,
7884
}
7985
}
@@ -82,7 +88,7 @@ impl CommitBoostConfig {
8288
/// Helper struct to load the chain spec file
8389
#[derive(Deserialize)]
8490
struct ChainConfig {
85-
chain: PathBuf,
91+
chain: ChainLoader,
8692
}
8793

8894
/// Helper struct to load the rest of the config

crates/common/src/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl From<KnownChain> for Chain {
161161

162162
#[derive(Debug, Clone, Serialize, Deserialize)]
163163
#[serde(untagged)]
164-
enum ChainLoader {
164+
pub enum ChainLoader {
165165
Known(KnownChain),
166166
Path(PathBuf),
167167
Custom { genesis_time_secs: u64, slot_time_secs: u64, genesis_fork_version: Bytes },

0 commit comments

Comments
 (0)