From e692d204ed97add40f6fa5baea4477f9b28f9c49 Mon Sep 17 00:00:00 2001 From: Julian Eager Date: Wed, 18 Dec 2024 16:59:55 +0800 Subject: [PATCH] refactor: bake defaults into test builders (#12618) closes #12585 --- core/chain-configs/src/test_genesis.rs | 533 ++++++++---------- .../tests/client/features/in_memory_tries.rs | 1 - 2 files changed, 233 insertions(+), 301 deletions(-) diff --git a/core/chain-configs/src/test_genesis.rs b/core/chain-configs/src/test_genesis.rs index fccec7ffad4..a77fc646ff5 100644 --- a/core/chain-configs/src/test_genesis.rs +++ b/core/chain-configs/src/test_genesis.rs @@ -17,30 +17,39 @@ use near_primitives::version::PROTOCOL_VERSION; use near_time::{Clock, FakeClock}; use num_rational::Rational32; -use crate::{Genesis, GenesisConfig, GenesisContents, GenesisRecords}; +use crate::{ + Genesis, GenesisConfig, GenesisContents, GenesisRecords, FISHERMEN_THRESHOLD, + PROTOCOL_UPGRADE_STAKE_THRESHOLD, +}; -/// Builder for constructing `EpochConfig` for testing. -/// -/// Defaults -/// * single shard -/// * single block and chunk producer -/// * epoch_length: 5 -/// * block_producer_kickout_threshold: 0 -/// * chunk_producer_kickout_threshold: 0 -/// * chunk_validator_only_kickout_threshold: 0 -#[derive(Debug, Clone, Default)] +#[derive(Debug, Clone)] pub struct TestEpochConfigBuilder { - epoch_length: Option, - shard_layout: Option, - validators_spec: Option, - target_validator_mandates_per_shard: Option, - block_producer_kickout_threshold: Option, - chunk_producer_kickout_threshold: Option, - chunk_validator_only_kickout_threshold: Option, - // validator selection - minimum_stake_ratio: Option, - minimum_validators_per_shard: Option, - shuffle_shard_assignment_for_chunk_producers: Option, + epoch_length: BlockHeightDelta, + shard_layout: ShardLayout, + num_block_producer_seats: NumSeats, + num_chunk_producer_seats: NumSeats, + num_chunk_validator_seats: NumSeats, + target_validator_mandates_per_shard: NumSeats, + avg_hidden_validator_seats_per_shard: Vec, + minimum_validators_per_shard: NumSeats, + block_producer_kickout_threshold: u8, + chunk_producer_kickout_threshold: u8, + chunk_validator_only_kickout_threshold: u8, + validator_max_kickout_stake_perc: u8, + online_min_threshold: Rational32, + online_max_threshold: Rational32, + fishermen_threshold: Balance, + protocol_upgrade_stake_threshold: Rational32, + minimum_stake_divisor: u64, + minimum_stake_ratio: Rational32, + chunk_producer_assignment_changes_limit: NumSeats, + shuffle_shard_assignment_for_chunk_producers: bool, + + // not used any more + num_block_producer_seats_per_shard: Vec, + // TODO (#11267): deprecate after StatelessValidationV0 is in place. + // Use 300 for older protocol versions. + num_chunk_only_producer_seats: NumSeats, } /// A builder for constructing a valid genesis for testing. @@ -54,23 +63,36 @@ pub struct TestEpochConfigBuilder { /// since the validator selection algorithm is rather tricky, the builder /// provides an option to specify exactly which accounts should be block and /// chunk-only producers. -#[derive(Default, Clone, Debug)] +#[derive(Clone, Debug)] pub struct TestGenesisBuilder { - chain_id: Option, - genesis_time: Option>, - protocol_version: Option, - genesis_height: Option, + chain_id: String, + protocol_version: ProtocolVersion, // TODO: remove when epoch length is no longer controlled by genesis - epoch_length: Option, - min_max_gas_price: Option<(Balance, Balance)>, - gas_limit: Option, - transaction_validity_period: Option, - validators_spec: Option, - protocol_treasury_account: Option, - max_inflation_rate: Option, - user_accounts: Vec, + epoch_length: BlockHeightDelta, // TODO: remove when shard layout is no longer controlled by genesis - shard_layout: Option, + shard_layout: ShardLayout, + validators_spec: ValidatorsSpec, + genesis_time: chrono::DateTime, + genesis_height: BlockHeight, + min_gas_price: Balance, + max_gas_price: Balance, + gas_limit: Gas, + transaction_validity_period: NumBlocks, + protocol_treasury_account: String, + max_inflation_rate: Rational32, + dynamic_resharding: bool, + fishermen_threshold: Balance, + online_min_threshold: Rational32, + online_max_threshold: Rational32, + gas_price_adjustment_rate: Rational32, + num_blocks_per_year: NumBlocks, + protocol_reward_rate: Rational32, + max_kickout_stake_perc: u8, + num_chunk_only_producer_seats: NumSeats, + minimum_stake_divisor: u64, + protocol_upgrade_stake_threshold: Rational32, + chunk_producer_assignment_changes_limit: NumSeats, + user_accounts: Vec, } #[derive(Debug, Clone)] @@ -94,33 +116,69 @@ struct UserAccount { access_keys: Vec, } +impl Default for TestEpochConfigBuilder { + // NOTE: The hardcoded defaults below are meticulously chosen for the purpose of testing. If you + // want to override any of them, add corresponding functions to set the field. DO NOT just + // modify the defaults. + fn default() -> Self { + Self { + epoch_length: 5, + shard_layout: ShardLayout::single_shard(), + num_block_producer_seats: 1, + num_chunk_producer_seats: 1, + num_chunk_validator_seats: 1, + target_validator_mandates_per_shard: 68, + avg_hidden_validator_seats_per_shard: vec![], + minimum_validators_per_shard: 1, + block_producer_kickout_threshold: 0, + chunk_producer_kickout_threshold: 0, + chunk_validator_only_kickout_threshold: 0, + validator_max_kickout_stake_perc: 100, + online_min_threshold: Rational32::new(90, 100), + online_max_threshold: Rational32::new(99, 100), + fishermen_threshold: FISHERMEN_THRESHOLD, + protocol_upgrade_stake_threshold: PROTOCOL_UPGRADE_STAKE_THRESHOLD, + minimum_stake_divisor: 10, + minimum_stake_ratio: Rational32::new(160i32, 1_000_000i32), + chunk_producer_assignment_changes_limit: 5, + shuffle_shard_assignment_for_chunk_producers: false, + // consider them ineffective + num_block_producer_seats_per_shard: vec![1], + num_chunk_only_producer_seats: 300, + } + } +} + impl TestEpochConfigBuilder { pub fn new() -> Self { Default::default() } pub fn epoch_length(mut self, epoch_length: BlockHeightDelta) -> Self { - self.epoch_length = Some(epoch_length); + self.epoch_length = epoch_length; self } pub fn shard_layout(mut self, shard_layout: ShardLayout) -> Self { - self.shard_layout = Some(shard_layout); + self.shard_layout = shard_layout; self } pub fn validators_spec(mut self, validators_spec: ValidatorsSpec) -> Self { - self.validators_spec = Some(validators_spec); - self - } - - pub fn minimum_stake_ratio(mut self, minimum_stake_ratio: Rational32) -> Self { - self.minimum_stake_ratio = Some(minimum_stake_ratio); + let DerivedValidatorSetup { + validators: _, + num_block_producer_seats, + num_chunk_producer_seats, + num_chunk_validator_seats, + } = derive_validator_setup(validators_spec); + self.num_block_producer_seats = num_block_producer_seats; + self.num_chunk_producer_seats = num_chunk_producer_seats; + self.num_chunk_validator_seats = num_chunk_validator_seats; self } pub fn minimum_validators_per_shard(mut self, minimum_validators_per_shard: NumSeats) -> Self { - self.minimum_validators_per_shard = Some(minimum_validators_per_shard); + self.minimum_validators_per_shard = minimum_validators_per_shard; self } @@ -128,141 +186,103 @@ impl TestEpochConfigBuilder { mut self, target_validator_mandates_per_shard: NumSeats, ) -> Self { - self.target_validator_mandates_per_shard = Some(target_validator_mandates_per_shard); + self.target_validator_mandates_per_shard = target_validator_mandates_per_shard; self } - pub fn shuffle_shard_assignment_for_chunk_producers(mut self, shuffle: bool) -> Self { - self.shuffle_shard_assignment_for_chunk_producers = Some(shuffle); + pub fn shuffle_shard_assignment_for_chunk_producers( + mut self, + shuffle_shard_assignment_for_chunk_producers: bool, + ) -> Self { + self.shuffle_shard_assignment_for_chunk_producers = + shuffle_shard_assignment_for_chunk_producers; self } // Validators with performance below 80% are kicked out, similarly to // mainnet as of 28 Jun 2024. pub fn kickouts_standard_80_percent(mut self) -> Self { - self.block_producer_kickout_threshold = Some(80); - self.chunk_producer_kickout_threshold = Some(80); - self.chunk_validator_only_kickout_threshold = Some(80); + self.block_producer_kickout_threshold = 80; + self.chunk_producer_kickout_threshold = 80; + self.chunk_validator_only_kickout_threshold = 80; self } // Only chunk validator-only nodes can be kicked out. pub fn kickouts_for_chunk_validators_only(mut self) -> Self { - self.block_producer_kickout_threshold = Some(0); - self.chunk_producer_kickout_threshold = Some(0); - self.chunk_validator_only_kickout_threshold = Some(50); + self.block_producer_kickout_threshold = 0; + self.chunk_producer_kickout_threshold = 0; + self.chunk_validator_only_kickout_threshold = 50; self } pub fn build(self) -> EpochConfig { - let epoch_length = self.epoch_length.unwrap_or_else(|| { - let default = 5; - tracing::warn!( - "Epoch config epoch_length not explicitly set, defaulting to {:?}.", - default - ); - default - }); - let shard_layout = self.shard_layout.unwrap_or_else(|| { - let default = ShardLayout::single_shard(); - tracing::warn!( - "Epoch config shard_layout not explicitly set, defaulting to {:?}.", - default - ); - default - }); - let validators_spec = self.validators_spec.unwrap_or_else(|| { - let default = ValidatorsSpec::DesiredRoles { + let epoch_config = EpochConfig { + epoch_length: self.epoch_length, + shard_layout: self.shard_layout, + num_block_producer_seats: self.num_block_producer_seats, + num_chunk_producer_seats: self.num_chunk_producer_seats, + num_chunk_validator_seats: self.num_chunk_validator_seats, + target_validator_mandates_per_shard: self.target_validator_mandates_per_shard, + avg_hidden_validator_seats_per_shard: self.avg_hidden_validator_seats_per_shard, + minimum_validators_per_shard: self.minimum_validators_per_shard, + block_producer_kickout_threshold: self.block_producer_kickout_threshold, + chunk_producer_kickout_threshold: self.chunk_producer_kickout_threshold, + chunk_validator_only_kickout_threshold: self.chunk_validator_only_kickout_threshold, + validator_max_kickout_stake_perc: self.validator_max_kickout_stake_perc, + online_min_threshold: self.online_min_threshold, + online_max_threshold: self.online_max_threshold, + fishermen_threshold: self.fishermen_threshold, + protocol_upgrade_stake_threshold: self.protocol_upgrade_stake_threshold, + minimum_stake_divisor: self.minimum_stake_divisor, + minimum_stake_ratio: self.minimum_stake_ratio, + chunk_producer_assignment_changes_limit: self.chunk_producer_assignment_changes_limit, + shuffle_shard_assignment_for_chunk_producers: self + .shuffle_shard_assignment_for_chunk_producers, + num_block_producer_seats_per_shard: self.num_block_producer_seats_per_shard, + num_chunk_only_producer_seats: self.num_chunk_only_producer_seats, + }; + tracing::debug!("Epoch config: {:#?}", epoch_config); + epoch_config + } +} + +impl Default for TestGenesisBuilder { + // NOTE: The hardcoded defaults below are meticulously chosen for the purpose of testing. If you + // want to override any of them, add corresponding functions to set the field. DO NOT just + // modify the defaults. + fn default() -> Self { + Self { + chain_id: "test".to_string(), + protocol_version: PROTOCOL_VERSION, + epoch_length: 100, + shard_layout: ShardLayout::single_shard(), + validators_spec: ValidatorsSpec::DesiredRoles { block_and_chunk_producers: vec!["validator0".to_string()], chunk_validators_only: vec![], - }; - tracing::warn!( - "Epoch config validators_spec not explicitly set, defaulting to {:?}.", - default - ); - default - }); - - let DerivedValidatorSetup { - validators: _, - num_block_producer_seats, - num_chunk_producer_seats, - num_chunk_validator_seats, - } = derive_validator_setup(validators_spec); - - let mut epoch_config = - Genesis::test_epoch_config(num_block_producer_seats, shard_layout, epoch_length); - epoch_config.block_producer_kickout_threshold = 0; - epoch_config.chunk_producer_kickout_threshold = 0; - epoch_config.chunk_validator_only_kickout_threshold = 0; - epoch_config.num_chunk_producer_seats = num_chunk_producer_seats; - epoch_config.num_chunk_validator_seats = num_chunk_validator_seats; - - if let Some(target_validator_mandates_per_shard) = self.target_validator_mandates_per_shard - { - epoch_config.target_validator_mandates_per_shard = target_validator_mandates_per_shard; - } else { - tracing::warn!( - "Epoch config target_validator_mandates_per_shard not explicitly set, defaulting to {:?}.", - epoch_config.target_validator_mandates_per_shard - ); - } - if let Some(block_producer_kickout_threshold) = self.block_producer_kickout_threshold { - epoch_config.block_producer_kickout_threshold = block_producer_kickout_threshold; - } else { - tracing::warn!( - "Epoch config block_producer_kickout_threshold not explicitly set, defaulting to {:?}.", - epoch_config.block_producer_kickout_threshold - ); - } - if let Some(chunk_producer_kickout_threshold) = self.chunk_producer_kickout_threshold { - epoch_config.chunk_producer_kickout_threshold = chunk_producer_kickout_threshold; - } else { - tracing::warn!( - "Epoch config chunk_producer_kickout_threshold not explicitly set, defaulting to {:?}.", - epoch_config.chunk_producer_kickout_threshold - ); - } - if let Some(chunk_validator_only_kickout_threshold) = - self.chunk_validator_only_kickout_threshold - { - epoch_config.chunk_validator_only_kickout_threshold = - chunk_validator_only_kickout_threshold; - } else { - tracing::warn!( - "Epoch config chunk_validator_only_kickout_threshold not explicitly set, defaulting to {:?}.", - epoch_config.chunk_validator_only_kickout_threshold - ); - } - if let Some(minimum_stake_ratio) = self.minimum_stake_ratio { - epoch_config.minimum_stake_ratio = minimum_stake_ratio; - } else { - tracing::warn!( - "Epoch config minimum_stake_ratio not explicitly set, defaulting to {:?}.", - epoch_config.minimum_stake_ratio - ); - } - if let Some(minimum_validators_per_shard) = self.minimum_validators_per_shard { - epoch_config.minimum_validators_per_shard = minimum_validators_per_shard; - } else { - tracing::warn!( - "Epoch config minimum_validators_per_shard not explicitly set, defaulting to {:?}.", - epoch_config.minimum_validators_per_shard - ); - } - if let Some(shuffle_shard_assignment_for_chunk_producers) = - self.shuffle_shard_assignment_for_chunk_producers - { - epoch_config.shuffle_shard_assignment_for_chunk_producers = - shuffle_shard_assignment_for_chunk_producers; - } else { - tracing::warn!( - "Epoch config shuffle_shard_assignment_for_chunk_producers not explicitly set, defaulting to {:?}.", - epoch_config.shuffle_shard_assignment_for_chunk_producers - ); + }, + genesis_time: chrono::Utc::now(), + genesis_height: 1, + min_gas_price: 0, + max_gas_price: 0, + gas_limit: 1_000_000_000_000_000, + transaction_validity_period: 100, + protocol_treasury_account: "near".to_string().parse().unwrap(), + max_inflation_rate: Rational32::new(1, 1), + user_accounts: vec![], + dynamic_resharding: false, + fishermen_threshold: 0, + online_min_threshold: Rational32::new(90, 100), + online_max_threshold: Rational32::new(99, 100), + gas_price_adjustment_rate: Rational32::new(0, 1), + num_blocks_per_year: 86400, + protocol_reward_rate: Rational32::new(0, 1), + max_kickout_stake_perc: 100, + num_chunk_only_producer_seats: 0, + minimum_stake_divisor: 10, + protocol_upgrade_stake_threshold: Rational32::new(8, 10), + chunk_producer_assignment_changes_limit: 5, } - - epoch_config } } @@ -272,72 +292,68 @@ impl TestGenesisBuilder { } pub fn chain_id(mut self, chain_id: String) -> Self { - self.chain_id = Some(chain_id); + self.chain_id = chain_id; self } pub fn genesis_time(mut self, genesis_time: chrono::DateTime) -> Self { - self.genesis_time = Some(genesis_time); + self.genesis_time = genesis_time; self } pub fn genesis_time_from_clock(mut self, clock: &Clock) -> Self { - self.genesis_time = Some(from_timestamp(clock.now_utc().unix_timestamp_nanos() as u64)); + self.genesis_time = from_timestamp(clock.now_utc().unix_timestamp_nanos() as u64); self } pub fn protocol_version(mut self, protocol_version: ProtocolVersion) -> Self { - self.protocol_version = Some(protocol_version); + self.protocol_version = protocol_version; self } pub fn genesis_height(mut self, genesis_height: BlockHeight) -> Self { - self.genesis_height = Some(genesis_height); + self.genesis_height = genesis_height; self } pub fn epoch_length(mut self, epoch_length: BlockHeightDelta) -> Self { - self.epoch_length = Some(epoch_length); + self.epoch_length = epoch_length; self } pub fn shard_layout(mut self, shard_layout: ShardLayout) -> Self { - self.shard_layout = Some(shard_layout); + self.shard_layout = shard_layout; self } pub fn gas_prices(mut self, min: Balance, max: Balance) -> Self { - self.min_max_gas_price = Some((min, max)); - self - } - - pub fn gas_prices_free(mut self) -> Self { - self.min_max_gas_price = Some((0, 0)); + self.min_gas_price = min; + self.max_gas_price = max; self } pub fn gas_limit(mut self, gas_limit: Gas) -> Self { - self.gas_limit = Some(gas_limit); + self.gas_limit = gas_limit; self } pub fn gas_limit_one_petagas(mut self) -> Self { - self.gas_limit = Some(1_000_000_000_000_000); + self.gas_limit = 1_000_000_000_000_000; self } pub fn transaction_validity_period(mut self, transaction_validity_period: NumBlocks) -> Self { - self.transaction_validity_period = Some(transaction_validity_period); + self.transaction_validity_period = transaction_validity_period; self } - pub fn validators_spec(mut self, validators: ValidatorsSpec) -> Self { - self.validators_spec = Some(validators); + pub fn validators_spec(mut self, validators_spec: ValidatorsSpec) -> Self { + self.validators_spec = validators_spec; self } pub fn max_inflation_rate(mut self, max_inflation_rate: Rational32) -> Self { - self.max_inflation_rate = Some(max_inflation_rate); + self.max_inflation_rate = max_inflation_rate; self } @@ -345,7 +361,7 @@ impl TestGenesisBuilder { /// pick an arbitrary account name and ensure that it is included in the /// genesis records. pub fn protocol_treasury_account(mut self, protocol_treasury_account: String) -> Self { - self.protocol_treasury_account = Some(protocol_treasury_account); + self.protocol_treasury_account = protocol_treasury_account; self } @@ -378,95 +394,6 @@ impl TestGenesisBuilder { } pub fn build(self) -> Genesis { - let chain_id = self.chain_id.clone().unwrap_or_else(|| { - let default = "test".to_string(); - tracing::warn!("Genesis chain_id not explicitly set, defaulting to {:?}.", default); - default - }); - let protocol_version = self.protocol_version.unwrap_or_else(|| { - let default = PROTOCOL_VERSION; - tracing::warn!("Genesis protocol_version not explicitly set, defaulting to latest protocol version {:?}.", default); - default - }); - let validators_spec = self.validators_spec.clone().unwrap_or_else(|| { - let default = ValidatorsSpec::DesiredRoles { - block_and_chunk_producers: vec!["validator0".to_string()], - chunk_validators_only: vec![], - }; - tracing::warn!( - "Genesis validators not explicitly set, defaulting to a single validator setup {:?}.", - default - ); - default - }); - let epoch_length = self.epoch_length.unwrap_or_else(|| { - let default = 100; - tracing::warn!("Genesis epoch_length not explicitly set, defaulting to {:?}.", default); - default - }); - let shard_layout = self.shard_layout.clone().unwrap_or_else(|| { - let default = ShardLayout::single_shard(); - tracing::warn!("Genesis shard_layout not explicitly set, defaulting to {:?}.", default); - default - }); - let genesis_time = self.genesis_time.unwrap_or_else(|| { - let default = chrono::Utc::now(); - tracing::warn!( - "Genesis genesis_time not explicitly set, defaulting to current time {:?}.", - default - ); - default - }); - - let genesis_height = self.genesis_height.unwrap_or_else(|| { - let default = 1; - tracing::warn!( - "Genesis genesis_height not explicitly set, defaulting to {:?}.", - default - ); - default - }); - let (min_gas_price, max_gas_price) = self.min_max_gas_price.unwrap_or_else(|| { - let default = (0, 0); - tracing::warn!("Genesis gas prices not explicitly set, defaulting to free gas."); - default - }); - let gas_limit = self.gas_limit.unwrap_or_else(|| { - let default = 1_000_000_000_000_000; - tracing::warn!("Genesis gas_limit not explicitly set, defaulting to {:?}.", default); - default - }); - let transaction_validity_period = self.transaction_validity_period.unwrap_or_else(|| { - let default = 100; - tracing::warn!( - "Genesis transaction_validity_period not explicitly set, defaulting to {:?}.", - default - ); - default - }); - - let protocol_treasury_account: AccountId = self - .protocol_treasury_account - .clone() - .unwrap_or_else(|| { - let default = "near".to_string(); - tracing::warn!( - "Genesis protocol_treasury_account not explicitly set, defaulting to {:?}.", - default - ); - default - }) - .parse() - .unwrap(); - let max_inflation_rate = self.max_inflation_rate.unwrap_or_else(|| { - let default = Rational32::new(1, 1); - tracing::warn!( - "Genesis max_inflation_rate not explicitly set, defaulting to {:?}.", - default - ); - default - }); - if self .user_accounts .iter() @@ -478,6 +405,8 @@ impl TestGenesisBuilder { panic!("Duplicate user accounts specified."); } + let protocol_treasury_account: AccountId = self.protocol_treasury_account.parse().unwrap(); + // We will merge the user accounts that were specified, with the // validator staking accounts from the validator setup, and ensure // that the protocol treasury account is included too. We will use all @@ -502,7 +431,7 @@ impl TestGenesisBuilder { num_block_producer_seats, num_chunk_producer_seats, num_chunk_validator_seats, - } = derive_validator_setup(validators_spec); + } = derive_validator_setup(self.validators_spec); let mut total_supply = 0; let mut validator_stake: HashMap = HashMap::new(); @@ -521,7 +450,7 @@ impl TestGenesisBuilder { 0, CryptoHash::default(), 0, - protocol_version, + self.protocol_version, ), }); for access_key in &user_account.access_keys { @@ -538,50 +467,55 @@ impl TestGenesisBuilder { for (account_id, balance) in validator_stake { records.push(StateRecord::Account { account_id, - account: Account::new(0, balance, 0, CryptoHash::default(), 0, protocol_version), + account: Account::new( + 0, + balance, + 0, + CryptoHash::default(), + 0, + self.protocol_version, + ), }); } - // NOTE: If you want to override any of the hardcoded defaults below, - // follow the same pattern and add a corresponding `Option` field to the builder, - // and add the corresponding functions to set the field. DO NOT just modify - // the defaults. let genesis_config = GenesisConfig { - chain_id, - genesis_time, - genesis_height, - epoch_length, - min_gas_price, - max_gas_price, - gas_limit, - dynamic_resharding: false, - fishermen_threshold: 0, - transaction_validity_period, - protocol_version, + chain_id: self.chain_id, + genesis_time: self.genesis_time, + genesis_height: self.genesis_height, + epoch_length: self.epoch_length, + min_gas_price: self.min_gas_price, + max_gas_price: self.max_gas_price, + gas_limit: self.gas_limit, + dynamic_resharding: self.dynamic_resharding, + fishermen_threshold: self.fishermen_threshold, + transaction_validity_period: self.transaction_validity_period, + protocol_version: self.protocol_version, protocol_treasury_account, - online_min_threshold: Rational32::new(90, 100), - online_max_threshold: Rational32::new(99, 100), - gas_price_adjustment_rate: Rational32::new(0, 1), - num_blocks_per_year: 86400, - protocol_reward_rate: Rational32::new(0, 1), + online_min_threshold: self.online_min_threshold, + online_max_threshold: self.online_max_threshold, + gas_price_adjustment_rate: self.gas_price_adjustment_rate, + num_blocks_per_year: self.num_blocks_per_year, + protocol_reward_rate: self.protocol_reward_rate, total_supply, - max_kickout_stake_perc: 100, + max_kickout_stake_perc: self.max_kickout_stake_perc, validators, - shard_layout: shard_layout.clone(), + shard_layout: self.shard_layout.clone(), num_block_producer_seats, - num_block_producer_seats_per_shard: shard_layout + num_block_producer_seats_per_shard: self + .shard_layout .shard_ids() .map(|_| num_block_producer_seats) .collect(), - num_chunk_only_producer_seats: 0, - minimum_stake_divisor: 10, - max_inflation_rate, - protocol_upgrade_stake_threshold: Rational32::new(8, 10), + num_chunk_only_producer_seats: self.num_chunk_only_producer_seats, + minimum_stake_divisor: self.minimum_stake_divisor, + max_inflation_rate: self.max_inflation_rate, + protocol_upgrade_stake_threshold: self.protocol_upgrade_stake_threshold, num_chunk_producer_seats, num_chunk_validator_seats, - chunk_producer_assignment_changes_limit: 5, + chunk_producer_assignment_changes_limit: self.chunk_producer_assignment_changes_limit, ..Default::default() }; + tracing::debug!("Genesis config: {:#?}", genesis_config); Genesis { config: genesis_config, @@ -714,7 +648,6 @@ pub fn build_genesis_and_epoch_config_store<'a>( .shard_layout(shard_layout.clone()) .validators_spec(validators_spec.clone()) .add_user_accounts_simple(accounts, 1_000_000 * ONE_NEAR) - .gas_prices_free() .gas_limit_one_petagas(); let epoch_config_builder = TestEpochConfigBuilder::new() .epoch_length(epoch_length) diff --git a/integration-tests/src/tests/client/features/in_memory_tries.rs b/integration-tests/src/tests/client/features/in_memory_tries.rs index e03631df9c1..beb566b31dc 100644 --- a/integration-tests/src/tests/client/features/in_memory_tries.rs +++ b/integration-tests/src/tests/client/features/in_memory_tries.rs @@ -50,7 +50,6 @@ fn slow_test_in_memory_trie_node_consistency() { .shard_layout(shard_layout) .validators_spec(validators_spec) .add_user_accounts_simple(&accounts, initial_balance) - .gas_prices_free() .gas_limit_one_petagas() .transaction_validity_period(100) .build();