Skip to content

Commit

Permalink
update configs
Browse files Browse the repository at this point in the history
  • Loading branch information
ncitron committed Oct 28, 2024
1 parent 863db64 commit 2507c7f
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 73 deletions.
2 changes: 1 addition & 1 deletion ethereum/consensus-core/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use tree_hash::TreeHash;

use crate::{
consensus_spec::ConsensusSpec,
types::{BeaconBlockHeader, ExecutionPayloadHeader, SyncCommittee, Forks},
types::{BeaconBlockHeader, ExecutionPayloadHeader, Forks, SyncCommittee},
};

pub fn is_finality_proof_valid(
Expand Down
7 changes: 3 additions & 4 deletions ethereum/src/config/checkpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,9 @@ impl CheckpointFallback {
Self {
services: Default::default(),
networks: vec![
networks::Network::MAINNET,
networks::Network::GOERLI,
networks::Network::SEPOLIA,
networks::Network::HOLESKY,
networks::Network::Mainnet,
networks::Network::Sepolia,
networks::Network::Holesky,
],
}
}
Expand Down
135 changes: 67 additions & 68 deletions ethereum/src/config/networks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ use crate::config::types::ChainConfig;
Debug, Clone, Copy, Serialize, Deserialize, EnumIter, Hash, Eq, PartialEq, PartialOrd, Ord,
)]
pub enum Network {
MAINNET,
GOERLI,
SEPOLIA,
HOLESKY,
Mainnet,
Sepolia,
Holesky,
PectraDevnet,
}

impl FromStr for Network {
type Err = eyre::Report;

fn from_str(s: &str) -> Result<Self> {
match s {
"mainnet" => Ok(Self::MAINNET),
"goerli" => Ok(Self::GOERLI),
"sepolia" => Ok(Self::SEPOLIA),
"holesky" => Ok(Self::HOLESKY),
"mainnet" => Ok(Self::Mainnet),
"sepolia" => Ok(Self::Sepolia),
"holesky" => Ok(Self::Holesky),
"pectra-devnet" => Ok(Self::PectraDevnet),
_ => Err(eyre::eyre!("network not recognized")),
}
}
Expand All @@ -42,10 +42,10 @@ impl FromStr for Network {
impl Display for Network {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let str = match self {
Self::MAINNET => "mainnet",
Self::GOERLI => "goerli",
Self::SEPOLIA => "sepolia",
Self::HOLESKY => "holesky",
Self::Mainnet => "mainnet",
Self::Sepolia => "sepolia",
Self::Holesky => "holesky",
Self::PectraDevnet => "pectra-devnet",
};

f.write_str(str)
Expand All @@ -55,19 +55,18 @@ impl Display for Network {
impl Network {
pub fn to_base_config(&self) -> BaseConfig {
match self {
Self::MAINNET => mainnet(),
Self::GOERLI => goerli(),
Self::SEPOLIA => sepolia(),
Self::HOLESKY => holesky(),
Self::Mainnet => mainnet(),
Self::Sepolia => sepolia(),
Self::Holesky => holesky(),
Self::PectraDevnet => pectra_devnet(),
}
}

pub fn from_chain_id(id: u64) -> Result<Self> {
match id {
1 => Ok(Network::MAINNET),
5 => Ok(Network::GOERLI),
11155111 => Ok(Network::SEPOLIA),
17000 => Ok(Network::HOLESKY),
1 => Ok(Network::Mainnet),
11155111 => Ok(Network::Sepolia),
17000 => Ok(Network::Holesky),
_ => Err(eyre::eyre!("chain id not known")),
}
}
Expand Down Expand Up @@ -113,52 +112,7 @@ pub fn mainnet() -> BaseConfig {
},
max_checkpoint_age: 1_209_600, // 14 days
#[cfg(not(target_arch = "wasm32"))]
data_dir: Some(data_dir(Network::MAINNET)),
..std::default::Default::default()
}
}

pub fn goerli() -> BaseConfig {
BaseConfig {
default_checkpoint: b256!(
"f6e9d5fdd7c406834e888961beab07b2443b64703c36acc1274ae1ce8bb48839"
),
rpc_port: 8545,
consensus_rpc: None,
chain: ChainConfig {
chain_id: 5,
genesis_time: 1616508000,
genesis_root: b256!("043db0d9a83813551ee2f33450d23797757d430911a9320530ad8a0eabc43efb"),
},
forks: Forks {
genesis: Fork {
epoch: 0,
fork_version: fixed_bytes!("00001020"),
},
altair: Fork {
epoch: 36660,
fork_version: fixed_bytes!("01001020"),
},
bellatrix: Fork {
epoch: 112260,
fork_version: fixed_bytes!("02001020"),
},
capella: Fork {
epoch: 162304,
fork_version: fixed_bytes!("03001020"),
},
deneb: Fork {
epoch: 231680,
fork_version: fixed_bytes!("04001020"),
},
electra: Fork {
epoch: u64::MAX,
fork_version: fixed_bytes!("05001020"),
},
},
max_checkpoint_age: 1_209_600, // 14 days
#[cfg(not(target_arch = "wasm32"))]
data_dir: Some(data_dir(Network::GOERLI)),
data_dir: Some(data_dir(Network::Mainnet)),
..std::default::Default::default()
}
}
Expand Down Expand Up @@ -203,7 +157,7 @@ pub fn sepolia() -> BaseConfig {
},
max_checkpoint_age: 1_209_600, // 14 days
#[cfg(not(target_arch = "wasm32"))]
data_dir: Some(data_dir(Network::SEPOLIA)),
data_dir: Some(data_dir(Network::Sepolia)),
..std::default::Default::default()
}
}
Expand Down Expand Up @@ -248,7 +202,52 @@ pub fn holesky() -> BaseConfig {
},
max_checkpoint_age: 1_209_600, // 14 days
#[cfg(not(target_arch = "wasm32"))]
data_dir: Some(data_dir(Network::HOLESKY)),
data_dir: Some(data_dir(Network::Holesky)),
..std::default::Default::default()
}
}

pub fn pectra_devnet() -> BaseConfig {
BaseConfig {
default_checkpoint: b256!(
"4fd68b5777c1369adc2ddc7faf53a8ba8482390f8e0239fbd60b1bf1a66f0c5a"
),
rpc_port: 8545,
consensus_rpc: None,
chain: ChainConfig {
chain_id: 1,
genesis_time: 1729268862,
genesis_root: b256!("e3218d56569ba80b24d8c5d442b7a13c5fbf5d5e740dd986272f67b525e0e1e7"),
},
forks: Forks {
genesis: Fork {
epoch: 0,
fork_version: fixed_bytes!("10357071"),
},
altair: Fork {
epoch: 0,
fork_version: fixed_bytes!("20357071"),
},
bellatrix: Fork {
epoch: 0,
fork_version: fixed_bytes!("30357071"),
},
capella: Fork {
epoch: 0,
fork_version: fixed_bytes!("40357071"),
},
deneb: Fork {
epoch: 0,
fork_version: fixed_bytes!("50357071"),
},
electra: Fork {
epoch: 5,
fork_version: fixed_bytes!("60357071"),
},
},
max_checkpoint_age: 1_209_600, // 14 days
#[cfg(not(target_arch = "wasm32"))]
data_dir: Some(data_dir(Network::PectraDevnet)),
..std::default::Default::default()
}
}
Expand Down

0 comments on commit 2507c7f

Please sign in to comment.