From 5b39f65e43e50b9fb814fa9c2ea4606cd2fc0dbb Mon Sep 17 00:00:00 2001 From: Wulder Date: Thu, 6 Jun 2024 02:05:34 +0100 Subject: [PATCH 1/2] wip --- custom.yaml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 custom.yaml diff --git a/custom.yaml b/custom.yaml new file mode 100644 index 00000000..d69e35a0 --- /dev/null +++ b/custom.yaml @@ -0,0 +1,36 @@ +PRESET_BASE: mainnet +CONFIG_NAME: mainnet +TERMINAL_TOTAL_DIFFICULTY: "0xc70d808a128d7380000" +TERMINAL_BLOCK_HASH: "0x0000000000000000000000000000000000000000000000000000000000000000" +TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH: 18446744073709551615 +MIN_GENESIS_ACTIVE_VALIDATOR_COUNT: 16384 +MIN_GENESIS_TIME: 1606824000 +GENESIS_FORK_VERSION: "0x00000000" +GENESIS_DELAY: 604800 +ALTAIR_FORK_VERSION: "0x01000000" +ALTAIR_FORK_EPOCH: 74240 +BELLATRIX_FORK_VERSION: "0x02000000" +BELLATRIX_FORK_EPOCH: 144896 +CAPELLA_FORK_VERSION: "0x03000000" +CAPELLA_FORK_EPOCH: 194048 +DENEB_FORK_VERSION: "0x04000000" +DENEB_FORK_EPOCH: 269568 +ELECTRA_FORK_VERSION: "0x05000000" +ELECTRA_FORK_EPOCH: 18446744073709551615 +SECONDS_PER_SLOT: 12 +SECONDS_PER_ETH1_BLOCK: 14 +MIN_VALIDATOR_WITHDRAWABILITY_DELAY: 256 +SHARD_COMMITTEE_PERIOD: 256 +ETH1_FOLLOW_DISTANCE: 2048 +INACTIVITY_SCORE_BIAS: 4 +INACTIVITY_SCORE_RECOVERY_RATE: 16 +EJECTION_BALANCE: 16000000000 +MIN_PER_EPOCH_CHURN_LIMIT: 4 +MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT: 8 +CHURN_LIMIT_QUOTIENT: 65536 +MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA: 128000000000 +MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT: 256000000000 +PROPOSER_SCORE_BOOST: 40 +DEPOSIT_CHAIN_ID: 1 +DEPOSIT_NETWORK_ID: 1 +DEPOSIT_CONTRACT_ADDRESS: "0x00000000219ab540356cbb839cbe05303d7705fa" From 253e40fe8a89c89fdb18ee2010c8d44c649aa919 Mon Sep 17 00:00:00 2001 From: owen Date: Thu, 6 Jun 2024 13:05:46 +0100 Subject: [PATCH 2/2] support for custom network config --- crates/api/src/service.rs | 9 +++++++++ crates/common/src/chain_info.rs | 20 +++++++++++++++---- crates/common/src/config.rs | 8 +++++++- .../common/test_data/custom.yaml | 0 4 files changed, 32 insertions(+), 5 deletions(-) rename custom.yaml => crates/common/test_data/custom.yaml (100%) diff --git a/crates/api/src/service.rs b/crates/api/src/service.rs index b4030ae8..b7678164 100644 --- a/crates/api/src/service.rs +++ b/crates/api/src/service.rs @@ -75,6 +75,15 @@ impl ApiService { NetworkConfig::Goerli => ChainInfo::for_goerli(), NetworkConfig::Sepolia => ChainInfo::for_sepolia(), NetworkConfig::Holesky => ChainInfo::for_holesky(), + NetworkConfig::Custom { ref dir_path, ref genesis_validator_root, genesis_time } => { + match ChainInfo::for_custom(dir_path.clone(), genesis_validator_root.clone(), genesis_time) { + Ok(chain_info) => chain_info, + Err(err) => { + error!("Failed to load custom chain info: {:?}", err); + std::process::exit(1); + } + } + }, }); let housekeeper = diff --git a/crates/common/src/chain_info.rs b/crates/common/src/chain_info.rs index 6dc2544e..ddd90e1a 100644 --- a/crates/common/src/chain_info.rs +++ b/crates/common/src/chain_info.rs @@ -1,7 +1,6 @@ use ethereum_consensus::{ clock::{ - for_goerli, for_holesky, for_mainnet, for_sepolia, Clock, SystemTimeProvider, - GOERLI_GENESIS_TIME, HOLESKY_GENESIS_TIME, MAINNET_GENESIS_TIME, SEPOLIA_GENESIS_TIME, + for_goerli, for_holesky, for_mainnet, for_sepolia, from_system_time, Clock, SystemTimeProvider, GOERLI_GENESIS_TIME, HOLESKY_GENESIS_TIME, MAINNET_GENESIS_TIME, SEPOLIA_GENESIS_TIME }, configs, primitives::Root, @@ -134,7 +133,20 @@ impl ChainInfo { } } - pub fn for_custom(_config: String) -> Self { - panic!("custom network not supported yet"); + pub fn for_custom(config: String, genesis_validators_root: Node, genesis_time_in_secs: u64) -> Result { + let context = Context::try_from_file(&config)?; + let network = Network::Custom(config.clone()); + let clock = from_system_time(genesis_time_in_secs, context.seconds_per_slot, context.slots_per_epoch); + let genesis_time_in_secs = genesis_time_in_secs; + let seconds_per_slot = context.seconds_per_slot; + + Ok(Self { + network, + genesis_validators_root, + context, + clock, + genesis_time_in_secs, + seconds_per_slot, + }) } } diff --git a/crates/common/src/config.rs b/crates/common/src/config.rs index 8b354d39..5f44ba09 100644 --- a/crates/common/src/config.rs +++ b/crates/common/src/config.rs @@ -1,5 +1,6 @@ use crate::{api::*, ValidatorPreferences}; use clap::Parser; +use ethereum_consensus::ssz::prelude::Node; use helix_utils::request_encoding::Encoding; use serde::{Deserialize, Serialize}; use std::{collections::HashSet, fs::File}; @@ -91,6 +92,11 @@ pub enum NetworkConfig { Goerli, Sepolia, Holesky, + Custom { + dir_path: String, + genesis_validator_root: Node, + genesis_time: u64, + }, } #[derive(Default, Serialize, Deserialize, Clone)] @@ -251,7 +257,7 @@ fn test_config() { config.broadcasters.push(BroadcasterConfig::BeaconClient(BeaconClientConfig { url: "http://localhost:8080".to_string(), })); - config.network_config = NetworkConfig::Mainnet; + config.network_config = NetworkConfig::Custom { dir_path: "test".to_string(), genesis_validator_root: Default::default(), genesis_time: 1 }; config.logging = LoggingConfig::File { dir_path: "hello".to_string(), file_name: "test".to_string() }; config.validator_preferences = ValidatorPreferences { filtering: Filtering::Regional, trusted_builders: None, header_delay: true}; diff --git a/custom.yaml b/crates/common/test_data/custom.yaml similarity index 100% rename from custom.yaml rename to crates/common/test_data/custom.yaml