mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-25 00:38:22 +00:00
Merge latest master in v0.2.0
This commit is contained in:
93
lighthouse/environment/tests/environment_builder.rs
Normal file
93
lighthouse/environment/tests/environment_builder.rs
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
*
|
||||
* TODO: disabled until hardcoded testnet config is updated for v0.11
|
||||
*
|
||||
*
|
||||
#![cfg(test)]
|
||||
|
||||
use clap::ArgMatches;
|
||||
use environment::EnvironmentBuilder;
|
||||
use eth2_testnet_config::Eth2TestnetConfig;
|
||||
use std::path::PathBuf;
|
||||
use types::{Epoch, MainnetEthSpec, YamlConfig};
|
||||
|
||||
fn builder() -> EnvironmentBuilder<MainnetEthSpec> {
|
||||
EnvironmentBuilder::mainnet()
|
||||
.single_thread_tokio_runtime()
|
||||
.expect("should set runtime")
|
||||
.null_logger()
|
||||
.expect("should set logger")
|
||||
}
|
||||
|
||||
fn dummy_data_dir() -> PathBuf {
|
||||
PathBuf::from("./tests/datadir_that_does_not_exist")
|
||||
}
|
||||
|
||||
fn eth2_testnet_config() -> Eth2TestnetConfig<MainnetEthSpec> {
|
||||
Eth2TestnetConfig::hard_coded().expect("should decode hard_coded params")
|
||||
}
|
||||
|
||||
mod setup_eth2_config {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn returns_err_if_the_loaded_config_doesnt_match() {
|
||||
// `Minimal` spec
|
||||
let path_to_minimal_spec = PathBuf::from("./tests/minimal_spec");
|
||||
|
||||
// `Mainnet` spec
|
||||
let builder = builder();
|
||||
|
||||
let result = builder.setup_eth2_config(
|
||||
path_to_minimal_spec,
|
||||
eth2_testnet_config(),
|
||||
&ArgMatches::default(),
|
||||
);
|
||||
|
||||
assert!(result.is_err());
|
||||
assert_eq!(
|
||||
result.err().unwrap(),
|
||||
"Eth2 config loaded from disk does not match client spec version. Got minimal expected mainnet"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn update_slot_time() {
|
||||
// testnet
|
||||
let cli_args =
|
||||
beacon_node::cli_app().get_matches_from(vec!["app", "testnet", "--slot-time", "999"]);
|
||||
|
||||
let environment = builder()
|
||||
.setup_eth2_config(dummy_data_dir(), eth2_testnet_config(), &cli_args)
|
||||
.expect("should setup eth2_config")
|
||||
.build()
|
||||
.expect("should build environment");
|
||||
|
||||
assert_eq!(environment.eth2_config.spec.milliseconds_per_slot, 999);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn update_spec_with_yaml_config() {
|
||||
let config_yaml = PathBuf::from("./tests/testnet_dir/config.yaml");
|
||||
|
||||
let mut eth2_testnet_config = eth2_testnet_config();
|
||||
eth2_testnet_config.yaml_config =
|
||||
Some(YamlConfig::from_file(config_yaml.as_path()).expect("should load yaml config"));
|
||||
|
||||
let environment = builder()
|
||||
.setup_eth2_config(
|
||||
dummy_data_dir(),
|
||||
eth2_testnet_config,
|
||||
&ArgMatches::default(),
|
||||
)
|
||||
.expect("should setup eth2_config")
|
||||
.build()
|
||||
.expect("should build environment");
|
||||
|
||||
assert_eq!(
|
||||
environment.eth2_config.spec.far_future_epoch,
|
||||
Epoch::new(999) // see testnet_dir/config.yaml
|
||||
);
|
||||
}
|
||||
}
|
||||
*/
|
||||
42
lighthouse/environment/tests/minimal_spec/eth2-spec.toml
Normal file
42
lighthouse/environment/tests/minimal_spec/eth2-spec.toml
Normal file
@@ -0,0 +1,42 @@
|
||||
spec_constants = "minimal" # for testing
|
||||
|
||||
[spec]
|
||||
genesis_slot = 0
|
||||
base_rewards_per_epoch = 4
|
||||
deposit_contract_tree_depth = 32
|
||||
max_committees_per_slot = 64
|
||||
target_committee_size = 128
|
||||
min_per_epoch_churn_limit = 4
|
||||
churn_limit_quotient = 65536
|
||||
shuffle_round_count = 90
|
||||
min_genesis_active_validator_count = 16384
|
||||
min_genesis_time = 1578009600
|
||||
min_deposit_amount = 1000000000
|
||||
max_effective_balance = 32000000000
|
||||
ejection_balance = 16000000000
|
||||
effective_balance_increment = 1000000000
|
||||
genesis_fork_version = "0x00000000"
|
||||
bls_withdrawal_prefix_byte = "0x00"
|
||||
min_genesis_delay = 86400
|
||||
milliseconds_per_slot = 12000
|
||||
min_attestation_inclusion_delay = 1
|
||||
min_seed_lookahead = 1
|
||||
max_seed_lookahead = 4
|
||||
min_epochs_to_inactivity_penalty = 4
|
||||
min_validator_withdrawability_delay = 256
|
||||
persistent_committee_period = 2048
|
||||
base_reward_factor = 64
|
||||
whistleblower_reward_quotient = 512
|
||||
proposer_reward_quotient = 8
|
||||
inactivity_penalty_quotient = 33554432
|
||||
min_slashing_penalty_quotient = 32
|
||||
domain_beacon_proposer = 0
|
||||
domain_beacon_attester = 1
|
||||
domain_randao = 2
|
||||
domain_deposit = 3
|
||||
domain_voluntary_exit = 4
|
||||
safe_slots_to_update_justified = 8
|
||||
eth1_follow_distance = 1024
|
||||
seconds_per_eth1_block = 14
|
||||
boot_nodes = []
|
||||
network_id = 1
|
||||
56
lighthouse/environment/tests/testnet_dir/config.yaml
Normal file
56
lighthouse/environment/tests/testnet_dir/config.yaml
Normal file
@@ -0,0 +1,56 @@
|
||||
FAR_FUTURE_EPOCH: 999 # for testing
|
||||
BASE_REWARDS_PER_EPOCH: 4
|
||||
DEPOSIT_CONTRACT_TREE_DEPTH: 32
|
||||
MAX_COMMITTEES_PER_SLOT: 64
|
||||
TARGET_COMMITTEE_SIZE: 128
|
||||
MIN_PER_EPOCH_CHURN_LIMIT: 4
|
||||
CHURN_LIMIT_QUOTIENT: 65536
|
||||
SHUFFLE_ROUND_COUNT: 90
|
||||
MIN_GENESIS_ACTIVE_VALIDATOR_COUNT: 4096
|
||||
MIN_GENESIS_TIME: 0
|
||||
MIN_GENESIS_DELAY: 3600
|
||||
MIN_DEPOSIT_AMOUNT: 10000000
|
||||
MAX_EFFECTIVE_BALANCE: 3200000000
|
||||
EJECTION_BALANCE: 1600000000
|
||||
EFFECTIVE_BALANCE_INCREMENT: 100000000
|
||||
GENESIS_SLOT: 0
|
||||
GENESIS_FORK_VERSION: 0x01030307
|
||||
BLS_WITHDRAWAL_PREFIX: 0x00
|
||||
SECONDS_PER_SLOT: 12
|
||||
MIN_ATTESTATION_INCLUSION_DELAY: 1
|
||||
MIN_SEED_LOOKAHEAD: 1
|
||||
MAX_SEED_LOOKAHEAD: 4
|
||||
MIN_EPOCHS_TO_INACTIVITY_PENALTY: 4
|
||||
MIN_VALIDATOR_WITHDRAWABILITY_DELAY: 256
|
||||
PERSISTENT_COMMITTEE_PERIOD: 2048
|
||||
BASE_REWARD_FACTOR: 64
|
||||
WHISTLEBLOWER_REWARD_QUOTIENT: 512
|
||||
PROPOSER_REWARD_QUOTIENT: 8
|
||||
INACTIVITY_PENALTY_QUOTIENT: 33554432
|
||||
MIN_SLASHING_PENALTY_QUOTIENT: 32
|
||||
SAFE_SLOTS_TO_UPDATE_JUSTIFIED: 8
|
||||
DOMAIN_BEACON_PROPOSER: 0x00000000
|
||||
DOMAIN_BEACON_ATTESTER: 0x01000000
|
||||
DOMAIN_RANDAO: 0x02000000
|
||||
DOMAIN_DEPOSIT: 0x03000000
|
||||
DOMAIN_VOLUNTARY_EXIT: 0x04000000
|
||||
JUSTIFICATION_BITS_LENGTH: 0x04000000
|
||||
MAX_VALIDATORS_PER_COMMITTEE: 2048
|
||||
GENESIS_EPOCH: 0
|
||||
SLOTS_PER_EPOCH: 32
|
||||
SLOTS_PER_ETH1_VOTING_PERIOD: 1024
|
||||
SLOTS_PER_HISTORICAL_ROOT: 8192
|
||||
EPOCHS_PER_HISTORICAL_VECTOR: 65536
|
||||
EPOCHS_PER_SLASHINGS_VECTOR: 8192
|
||||
HISTORICAL_ROOTS_LIMIT: 16777216
|
||||
VALIDATOR_REGISTRY_LIMIT: 1099511627776
|
||||
MAX_PROPOSER_SLASHINGS: 16
|
||||
MAX_ATTESTER_SLASHINGS: 1
|
||||
MAX_ATTESTATIONS: 128
|
||||
MAX_DEPOSITS: 16
|
||||
MAX_VOLUNTARY_EXITS: 16
|
||||
ETH1_FOLLOW_DISTANCE: 16
|
||||
TARGET_AGGREGATORS_PER_COMMITTEE: 0
|
||||
RANDOM_SUBNETS_PER_VALIDATOR: 0
|
||||
EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION: 0
|
||||
SECONDS_PER_ETH1_BLOCK: 14
|
||||
Reference in New Issue
Block a user