Skip to content

Commit

Permalink
Merge pull request #89 from gattaca-com/dvnet
Browse files Browse the repository at this point in the history
Dvnet
  • Loading branch information
0w3n-d authored Jun 6, 2024
2 parents 22e8356 + 253e40f commit a09af94
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 5 deletions.
9 changes: 9 additions & 0 deletions crates/api/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
20 changes: 16 additions & 4 deletions crates/common/src/chain_info.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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<Self, Error> {
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,
})
}
}
8 changes: 7 additions & 1 deletion crates/common/src/config.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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};
Expand Down
36 changes: 36 additions & 0 deletions crates/common/test_data/custom.yaml
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit a09af94

Please sign in to comment.