From 45b96654708547776002e76177af3d519ebd6eb1 Mon Sep 17 00:00:00 2001 From: Longarithm Date: Fri, 7 Jun 2024 01:02:14 +0400 Subject: [PATCH] revert threshold --- chain/chain/src/runtime/mod.rs | 2 - chain/chain/src/runtime/tests.rs | 2 - chain/chain/src/test_utils/kv_runtime.rs | 1 - chain/client/src/info.rs | 1 - chain/epoch-manager/src/lib.rs | 17 ---- chain/epoch-manager/src/shard_tracker.rs | 1 - chain/epoch-manager/src/test_utils.rs | 9 +-- chain/epoch-manager/src/tests/mod.rs | 81 +++++++------------ .../epoch-manager/src/validator_selection.rs | 1 - .../jsonrpc-tests/res/genesis_config.json | 1 - core/chain-configs/src/genesis_config.rs | 14 ---- core/chain-configs/src/lib.rs | 3 - core/chain-configs/src/test_genesis.rs | 6 -- core/chain-configs/src/test_utils.rs | 8 +- core/primitives/src/epoch_manager.rs | 3 - core/primitives/src/shard_layout.rs | 1 - core/primitives/src/types.rs | 2 - .../src/csv_to_json_configs.rs | 9 +-- .../client/features/adversarial_behaviors.rs | 1 - .../client/features/stateless_validation.rs | 1 - .../src/tests/client/resharding.rs | 1 - .../src/tests/nearcore/stake_nodes.rs | 1 - nearcore/src/config.rs | 11 ++- tools/amend-genesis/src/cli.rs | 4 - tools/amend-genesis/src/lib.rs | 6 -- tools/fork-network/src/cli.rs | 1 - utils/mainnet-res/res/mainnet_genesis.json | 1 - 27 files changed, 43 insertions(+), 146 deletions(-) diff --git a/chain/chain/src/runtime/mod.rs b/chain/chain/src/runtime/mod.rs index 53387aa2169..1f684dd1c11 100644 --- a/chain/chain/src/runtime/mod.rs +++ b/chain/chain/src/runtime/mod.rs @@ -1313,8 +1313,6 @@ impl RuntimeAdapter for NightshadeRuntime { epoch_config.block_producer_kickout_threshold; genesis_config.chunk_producer_kickout_threshold = epoch_config.chunk_producer_kickout_threshold; - genesis_config.chunk_validator_only_kickout_threshold = - epoch_config.chunk_validator_only_kickout_threshold; genesis_config.max_kickout_stake_perc = epoch_config.validator_max_kickout_stake_perc; genesis_config.online_min_threshold = epoch_config.online_min_threshold; genesis_config.online_max_threshold = epoch_config.online_max_threshold; diff --git a/chain/chain/src/runtime/tests.rs b/chain/chain/src/runtime/tests.rs index 15afc4c7786..6fe397e41d2 100644 --- a/chain/chain/src/runtime/tests.rs +++ b/chain/chain/src/runtime/tests.rs @@ -206,8 +206,6 @@ impl TestEnv { genesis.config.epoch_length = config.epoch_length; genesis.config.chunk_producer_kickout_threshold = genesis.config.block_producer_kickout_threshold; - genesis.config.chunk_validator_only_kickout_threshold = - genesis.config.block_producer_kickout_threshold; if !config.has_reward { genesis.config.max_inflation_rate = Ratio::from_integer(0); } diff --git a/chain/chain/src/test_utils/kv_runtime.rs b/chain/chain/src/test_utils/kv_runtime.rs index 656a779a613..7458b669a00 100644 --- a/chain/chain/src/test_utils/kv_runtime.rs +++ b/chain/chain/src/test_utils/kv_runtime.rs @@ -486,7 +486,6 @@ impl EpochManagerAdapter for MockEpochManager { avg_hidden_validator_seats_per_shard: vec![1, 1], block_producer_kickout_threshold: 0, chunk_producer_kickout_threshold: 0, - chunk_validator_only_kickout_threshold: 0, validator_max_kickout_stake_perc: 0, online_min_threshold: Ratio::new(1i32, 4i32), online_max_threshold: Ratio::new(3i32, 4i32), diff --git a/chain/client/src/info.rs b/chain/client/src/info.rs index da4b067b9b8..16f118da37e 100644 --- a/chain/client/src/info.rs +++ b/chain/client/src/info.rs @@ -1031,7 +1031,6 @@ mod tests { num_block_producer_seats.try_into().unwrap(), 90, 90, - 0, default_reward_calculator(), ) .into_handle(); diff --git a/chain/epoch-manager/src/lib.rs b/chain/epoch-manager/src/lib.rs index 0a2f3609ab2..561304d5c8c 100644 --- a/chain/epoch-manager/src/lib.rs +++ b/chain/epoch-manager/src/lib.rs @@ -481,7 +481,6 @@ impl EpochManager { { let block_producer_kickout_threshold = config.block_producer_kickout_threshold; let chunk_producer_kickout_threshold = config.chunk_producer_kickout_threshold; - let chunk_validator_only_kickout_threshold = config.chunk_validator_only_kickout_threshold; let mut validator_block_chunk_stats = HashMap::new(); let mut total_stake: Balance = 0; let mut maximum_block_prod = 0; @@ -552,21 +551,6 @@ impl EpochManager { } }); } - let chunk_validator_only = - stats.block_stats.expected == 0 && stats.chunk_stats.expected() == 0; - if chunk_validator_only - && stats - .chunk_stats - .endorsement_stats() - .less_than(chunk_validator_only_kickout_threshold) - { - validator_kickout.entry(account_id.clone()).or_insert_with(|| { - ValidatorKickoutReason::NotEnoughChunkEndorsements { - produced: stats.chunk_stats.endorsement_stats().produced, - expected: stats.chunk_stats.endorsement_stats().expected, - } - }); - } let is_already_kicked_out = prev_validator_kickout.contains_key(account_id); if !validator_kickout.contains_key(account_id) { if !is_already_kicked_out { @@ -738,7 +722,6 @@ impl EpochManager { reason, ValidatorKickoutReason::NotEnoughBlocks { .. } | ValidatorKickoutReason::NotEnoughChunks { .. } - | ValidatorKickoutReason::NotEnoughChunkEndorsements { .. } ) { validator_block_chunk_stats.remove(account_id); } diff --git a/chain/epoch-manager/src/shard_tracker.rs b/chain/epoch-manager/src/shard_tracker.rs index e813bc4b7f7..9d90cb6d649 100644 --- a/chain/epoch-manager/src/shard_tracker.rs +++ b/chain/epoch-manager/src/shard_tracker.rs @@ -229,7 +229,6 @@ mod tests { avg_hidden_validator_seats_per_shard: vec![], block_producer_kickout_threshold: 90, chunk_producer_kickout_threshold: 60, - chunk_validator_only_kickout_threshold: 60, fishermen_threshold: 0, online_max_threshold: Ratio::from_integer(1), online_min_threshold: Ratio::new(90, 100), diff --git a/chain/epoch-manager/src/test_utils.rs b/chain/epoch-manager/src/test_utils.rs index 2ef8de2cc57..331a7c83b89 100644 --- a/chain/epoch-manager/src/test_utils.rs +++ b/chain/epoch-manager/src/test_utils.rs @@ -127,7 +127,6 @@ pub fn epoch_config_with_production_config( num_chunk_producer_seats: NumSeats, block_producer_kickout_threshold: u8, chunk_producer_kickout_threshold: u8, - chunk_validator_only_kickout_threshold: u8, use_production_config: bool, ) -> AllEpochConfig { let epoch_config = EpochConfig { @@ -140,7 +139,6 @@ pub fn epoch_config_with_production_config( avg_hidden_validator_seats_per_shard: vec![], block_producer_kickout_threshold, chunk_producer_kickout_threshold, - chunk_validator_only_kickout_threshold, fishermen_threshold: 0, online_min_threshold: Ratio::new(90, 100), online_max_threshold: Ratio::new(99, 100), @@ -162,7 +160,6 @@ pub fn epoch_config( num_block_producer_seats: NumSeats, block_producer_kickout_threshold: u8, chunk_producer_kickout_threshold: u8, - chunk_validator_only_kickout_threshold: u8, ) -> AllEpochConfig { epoch_config_with_production_config( epoch_length, @@ -171,7 +168,6 @@ pub fn epoch_config( 100, block_producer_kickout_threshold, chunk_producer_kickout_threshold, - chunk_validator_only_kickout_threshold, false, ) } @@ -206,7 +202,6 @@ pub fn setup_epoch_manager( num_block_producer_seats: NumSeats, block_producer_kickout_threshold: u8, chunk_producer_kickout_threshold: u8, - chunk_validator_only_kickout_threshold: u8, reward_calculator: RewardCalculator, ) -> EpochManager { let store = create_test_store(); @@ -216,7 +211,6 @@ pub fn setup_epoch_manager( num_block_producer_seats, block_producer_kickout_threshold, chunk_producer_kickout_threshold, - chunk_validator_only_kickout_threshold, ); EpochManager::new( store, @@ -246,7 +240,6 @@ pub fn setup_default_epoch_manager( num_block_producer_seats, block_producer_kickout_threshold, chunk_producer_kickout_threshold, - 0, default_reward_calculator(), ) } @@ -280,7 +273,7 @@ pub fn setup_epoch_manager_with_block_and_chunk_producers( validators.push((chunk_only_producer.clone(), stake)); total_stake += stake; } - let config = epoch_config(epoch_length, num_shards, num_block_producers, 0, 0, 0); + let config = epoch_config(epoch_length, num_shards, num_block_producers, 0, 0); let epoch_manager = EpochManager::new( store, config, diff --git a/chain/epoch-manager/src/tests/mod.rs b/chain/epoch-manager/src/tests/mod.rs index c49fbf3f46d..27fc08ba81e 100644 --- a/chain/epoch-manager/src/tests/mod.rs +++ b/chain/epoch-manager/src/tests/mod.rs @@ -20,9 +20,7 @@ use near_primitives::hash::hash; use near_primitives::shard_layout::ShardLayout; use near_primitives::sharding::{ShardChunkHeader, ShardChunkHeaderV3}; use near_primitives::stateless_validation::PartialEncodedStateWitness; -use near_primitives::types::ValidatorKickoutReason::{ - NotEnoughBlocks, NotEnoughChunkEndorsements, NotEnoughChunks, -}; +use near_primitives::types::ValidatorKickoutReason::{NotEnoughBlocks, NotEnoughChunks}; use near_primitives::validator_signer::ValidatorSigner; use near_primitives::version::ProtocolFeature::{SimpleNightshade, StatelessValidationV0}; use near_primitives::version::PROTOCOL_VERSION; @@ -138,7 +136,7 @@ fn test_validator_change_of_stake() { let validators = vec![("test1".parse().unwrap(), amount_staked), ("test2".parse().unwrap(), amount_staked)]; let mut epoch_manager = - setup_epoch_manager(validators, 2, 1, 2, 90, 60, 0, default_reward_calculator()); + setup_epoch_manager(validators, 2, 1, 2, 90, 60, default_reward_calculator()); let h = hash_range(4); record_block(&mut epoch_manager, CryptoHash::default(), h[0], 0, vec![]); @@ -362,7 +360,7 @@ fn test_validator_kickout() { #[test] fn test_validator_unstake() { let store = create_test_store(); - let config = epoch_config(2, 1, 2, 90, 60, 0); + let config = epoch_config(2, 1, 2, 90, 60); let amount_staked = 1_000_000; let validators = vec![ stake("test1".parse().unwrap(), amount_staked), @@ -427,7 +425,7 @@ fn test_validator_unstake() { #[test] fn test_slashing() { let store = create_test_store(); - let config = epoch_config(2, 1, 2, 90, 60, 0); + let config = epoch_config(2, 1, 2, 90, 60); let amount_staked = 1_000_000; let validators = vec![ stake("test1".parse().unwrap(), amount_staked), @@ -494,7 +492,7 @@ fn test_slashing() { #[test] fn test_double_sign_slashing1() { let store = create_test_store(); - let config = epoch_config(2, 1, 2, 90, 60, 0); + let config = epoch_config(2, 1, 2, 90, 60); let amount_staked = 1_000_000; let validators = vec![ stake("test1".parse().unwrap(), amount_staked), @@ -664,7 +662,7 @@ fn test_validator_reward_one_validator() { num_seconds_per_year: 50, }; let mut epoch_manager = - setup_epoch_manager(validators, epoch_length, 1, 1, 90, 60, 0, reward_calculator.clone()); + setup_epoch_manager(validators, epoch_length, 1, 1, 90, 60, reward_calculator.clone()); let rng_seed = [0; 32]; let h = hash_range(5); @@ -747,7 +745,7 @@ fn test_validator_reward_weight_by_stake() { num_seconds_per_year: 50, }; let mut epoch_manager = - setup_epoch_manager(validators, epoch_length, 1, 2, 90, 60, 0, reward_calculator.clone()); + setup_epoch_manager(validators, epoch_length, 1, 2, 90, 60, reward_calculator.clone()); let h = hash_range(5); record_with_block_info( &mut epoch_manager, @@ -851,7 +849,6 @@ fn test_reward_multiple_shards() { 2, 90, 60, - 0, reward_calculator.clone(), ); let h = hash_range((2 * epoch_length + 1) as usize); @@ -991,7 +988,7 @@ fn test_expected_chunks() { let total_supply = stake_amount * validators.len() as u128; let epoch_config = - epoch_config_with_production_config(epoch_length, num_shards, 3, 3, 90, 60, 60, false); + epoch_config_with_production_config(epoch_length, num_shards, 3, 3, 90, 60, false); let mut epoch_manager = EpochManager::new( create_test_store(), epoch_config, @@ -1067,7 +1064,7 @@ fn test_expected_chunks_prev_block_not_produced() { let epoch_length = 50; let total_supply = stake_amount * validators.len() as u128; let mut epoch_manager = - setup_epoch_manager(validators, epoch_length, 1, 3, 90, 90, 0, default_reward_calculator()); + setup_epoch_manager(validators, epoch_length, 1, 3, 90, 90, default_reward_calculator()); let rng_seed = [0; 32]; let hashes = hash_range((2 * epoch_length) as usize); record_block(&mut epoch_manager, Default::default(), hashes[0], 0, vec![]); @@ -1161,7 +1158,7 @@ fn test_rewards_with_kickouts() { online_max_threshold: Ratio::new(99, 100), num_seconds_per_year: NUM_SECONDS_IN_A_YEAR, }; - let mut em = setup_epoch_manager(validators, epoch_length, 1, 3, 10, 10, 0, reward_calculator); + let mut em = setup_epoch_manager(validators, epoch_length, 1, 3, 10, 10, reward_calculator); let mut height: BlockHeight = 0; let genesis_hash = hash(height.to_le_bytes().as_ref()); @@ -1268,7 +1265,7 @@ fn test_epoch_info_aggregator() { vec![("test1".parse().unwrap(), stake_amount), ("test2".parse().unwrap(), stake_amount)]; let epoch_length = 5; let mut em = - setup_epoch_manager(validators, epoch_length, 1, 2, 10, 10, 0, default_reward_calculator()); + setup_epoch_manager(validators, epoch_length, 1, 2, 10, 10, default_reward_calculator()); let h = hash_range(6); record_block(&mut em, Default::default(), h[0], 0, vec![]); record_block_with_final_block_hash(&mut em, h[0], h[1], h[0], 1, vec![]); @@ -1304,7 +1301,7 @@ fn test_epoch_info_aggregator_data_loss() { vec![("test1".parse().unwrap(), stake_amount), ("test2".parse().unwrap(), stake_amount)]; let epoch_length = 5; let mut em = - setup_epoch_manager(validators, epoch_length, 1, 2, 10, 10, 0, default_reward_calculator()); + setup_epoch_manager(validators, epoch_length, 1, 2, 10, 10, default_reward_calculator()); let h = hash_range(6); record_block(&mut em, Default::default(), h[0], 0, vec![]); record_block(&mut em, h[0], h[1], 1, vec![stake("test1".parse().unwrap(), stake_amount - 10)]); @@ -1339,7 +1336,7 @@ fn test_epoch_info_aggregator_reorg_past_final_block() { vec![("test1".parse().unwrap(), stake_amount), ("test2".parse().unwrap(), stake_amount)]; let epoch_length = 6; let mut em = - setup_epoch_manager(validators, epoch_length, 1, 2, 10, 10, 0, default_reward_calculator()); + setup_epoch_manager(validators, epoch_length, 1, 2, 10, 10, default_reward_calculator()); let h = hash_range(6); record_block(&mut em, Default::default(), h[0], 0, vec![]); record_block_with_final_block_hash(&mut em, h[0], h[1], h[0], 1, vec![]); @@ -1370,7 +1367,7 @@ fn test_epoch_info_aggregator_reorg_beginning_of_epoch() { vec![("test1".parse().unwrap(), stake_amount), ("test2".parse().unwrap(), stake_amount)]; let epoch_length = 4; let mut em = - setup_epoch_manager(validators, epoch_length, 1, 2, 10, 10, 0, default_reward_calculator()); + setup_epoch_manager(validators, epoch_length, 1, 2, 10, 10, default_reward_calculator()); let h = hash_range(10); record_block(&mut em, Default::default(), h[0], 0, vec![]); for i in 1..5 { @@ -1423,7 +1420,7 @@ fn test_num_missing_blocks() { vec![("test1".parse().unwrap(), stake_amount), ("test2".parse().unwrap(), stake_amount)]; let epoch_length = 2; let mut em = - setup_epoch_manager(validators, epoch_length, 1, 2, 10, 10, 0, default_reward_calculator()); + setup_epoch_manager(validators, epoch_length, 1, 2, 10, 10, default_reward_calculator()); let h = hash_range(8); record_block(&mut em, Default::default(), h[0], 0, vec![]); record_block(&mut em, h[0], h[1], 1, vec![]); @@ -1470,7 +1467,7 @@ fn test_chunk_producer_kickout() { let epoch_length = 10; let total_supply = stake_amount * validators.len() as u128; let mut em = - setup_epoch_manager(validators, epoch_length, 4, 2, 90, 70, 0, default_reward_calculator()); + setup_epoch_manager(validators, epoch_length, 4, 2, 90, 70, default_reward_calculator()); let rng_seed = [0; 32]; let hashes = hash_range((epoch_length + 2) as usize); record_block(&mut em, Default::default(), hashes[0], 0, vec![]); @@ -1537,7 +1534,7 @@ fn test_chunk_validator_kickout() { let total_supply = stake_amount * validators.len() as u128; let num_shards = 2; let epoch_config = - epoch_config_with_production_config(epoch_length, num_shards, 2, 2, 90, 40, 75, false); + epoch_config_with_production_config(epoch_length, num_shards, 2, 2, 90, 40, false); let mut em = EpochManager::new( create_test_store(), epoch_config, @@ -1577,25 +1574,10 @@ fn test_chunk_validator_kickout() { } let last_epoch_info = hashes.iter().filter_map(|x| em.get_epoch_info(&EpochId(*x)).ok()).last(); - let total_expected_chunks = num_shards * (epoch_length - 1); - // Every second chunk is skipped. - let total_produced_chunks = total_expected_chunks / 2; // Chunk producers skip only every second chunk and pass the threshold. - // Chunk validator validates all chunks, so its performance is determined - // by the chunk production ratio, which is not enough. - assert_eq!( - last_epoch_info.unwrap().validator_kickout(), - &[( - "test2".parse().unwrap(), - NotEnoughChunkEndorsements { - produced: total_produced_chunks, - expected: total_expected_chunks - } - )] - .into_iter() - .collect::>(), - ); + // Chunk validator doesn't have any threshold to meet. + assert_eq!(last_epoch_info.unwrap().validator_kickout(), &HashMap::default()); } #[test] @@ -1639,7 +1621,7 @@ fn test_fishermen() { ]; let epoch_length = 4; let em = - setup_epoch_manager(validators, epoch_length, 1, 4, 90, 70, 0, default_reward_calculator()); + setup_epoch_manager(validators, epoch_length, 1, 4, 90, 70, default_reward_calculator()); let epoch_info = em.get_epoch_info(&EpochId::default()).unwrap(); check_validators(&epoch_info, &[("test1", stake_amount), ("test2", stake_amount)]); check_fishermen(&epoch_info, &[]); @@ -1664,7 +1646,7 @@ fn test_fishermen_unstake() { ("test2".parse().unwrap(), fishermen_threshold), ("test3".parse().unwrap(), fishermen_threshold), ]; - let mut em = setup_epoch_manager(validators, 2, 1, 1, 90, 70, 0, default_reward_calculator()); + let mut em = setup_epoch_manager(validators, 2, 1, 1, 90, 70, default_reward_calculator()); let h = hash_range(5); record_block(&mut em, CryptoHash::default(), h[0], 0, vec![]); // fishermen unstake @@ -2109,7 +2091,7 @@ fn set_block_info_protocol_version(info: &mut BlockInfo, protocol_version: Proto #[test] fn test_protocol_version_switch() { let store = create_test_store(); - let config = epoch_config(2, 1, 2, 90, 60, 0); + let config = epoch_config(2, 1, 2, 90, 60); let amount_staked = 1_000_000; let validators = vec![ stake("test1".parse().unwrap(), amount_staked), @@ -2135,7 +2117,7 @@ fn test_protocol_version_switch() { #[test] fn test_protocol_version_switch_with_shard_layout_change() { let store = create_test_store(); - let config = epoch_config_with_production_config(2, 1, 2, 100, 90, 60, 0, true); + let config = epoch_config_with_production_config(2, 1, 2, 100, 90, 60, true); let amount_staked = 1_000_000; let validators = vec![ stake("test1".parse().unwrap(), amount_staked), @@ -2205,7 +2187,6 @@ fn test_protocol_version_switch_with_many_seats() { avg_hidden_validator_seats_per_shard: Vec::from([0]), block_producer_kickout_threshold: 90, chunk_producer_kickout_threshold: 60, - chunk_validator_only_kickout_threshold: 60, fishermen_threshold: 0, online_min_threshold: Ratio::new(90, 100), online_max_threshold: Ratio::new(99, 100), @@ -2245,7 +2226,7 @@ fn test_protocol_version_switch_with_many_seats() { fn test_protocol_version_switch_after_switch() { let store = create_test_store(); let epoch_length: usize = 10; - let config = epoch_config(epoch_length as u64, 1, 2, 90, 60, 0); + let config = epoch_config(epoch_length as u64, 1, 2, 90, 60); let amount_staked = 1_000_000; let validators = vec![ stake("test1".parse().unwrap(), amount_staked), @@ -2431,7 +2412,7 @@ fn test_chunk_producers() { /// the validators that don't meet the block/chunk producer kickout threshold is kicked out #[test] fn test_validator_kickout_sanity() { - let epoch_config = epoch_config_with_production_config(5, 2, 4, 4, 90, 80, 90, false) + let epoch_config = epoch_config_with_production_config(5, 2, 4, 4, 90, 80, false) .for_protocol_version(PROTOCOL_VERSION); let accounts = vec![ ("test0".parse().unwrap(), 1000), @@ -2456,9 +2437,8 @@ fn test_validator_kickout_sanity() { 1, ChunkStats { production: ValidatorStats { produced: 80, expected: 100 }, - // Note that test1 would not pass chunk endorsement - // threshold, but it is applied to nodes which are only - // chunk validators. + // Note that test1 has low chunk endorsement + // threshold, but it doesn't impact kickout. endorsement: ValidatorStats { produced: 0, expected: 100 }, }, ), @@ -2477,7 +2457,7 @@ fn test_validator_kickout_sanity() { }, ), (3, ChunkStats::new_with_production(100, 100)), - // test4 is only a chunk validator and should be kicked out. + // test4 is only a chunk validator and it cannot be kicked out. (4, ChunkStats::new_with_endorsement(89, 100)), ]), ), @@ -2495,7 +2475,6 @@ fn test_validator_kickout_sanity() { HashMap::from([ ("test2".parse().unwrap(), NotEnoughChunks { produced: 70, expected: 100 }), ("test3".parse().unwrap(), NotEnoughBlocks { produced: 89, expected: 100 }), - ("test4".parse().unwrap(), NotEnoughChunkEndorsements { produced: 89, expected: 100 }), ]) ); let expected_validator_stats: HashMap = HashMap::from([ @@ -2556,7 +2535,7 @@ fn test_validator_kickout_sanity() { /// This test does not test kickouts at all. #[test] fn test_chunk_endorsement_stats() { - let epoch_config = epoch_config(5, 2, 4, 90, 80, 0).for_protocol_version(PROTOCOL_VERSION); + let epoch_config = epoch_config(5, 2, 4, 90, 80).for_protocol_version(PROTOCOL_VERSION); let accounts = vec![ ("test0".parse().unwrap(), 1000), ("test1".parse().unwrap(), 1000), @@ -2633,7 +2612,7 @@ fn test_chunk_endorsement_stats() { #[test] /// Test that the stake of validators kicked out in an epoch doesn't exceed the max_kickout_stake_ratio fn test_max_kickout_stake_ratio() { - let mut epoch_config = epoch_config(5, 2, 4, 90, 80, 0).for_protocol_version(PROTOCOL_VERSION); + let mut epoch_config = epoch_config(5, 2, 4, 90, 80).for_protocol_version(PROTOCOL_VERSION); let accounts = vec![ ("test0".parse().unwrap(), 1000), ("test1".parse().unwrap(), 1000), diff --git a/chain/epoch-manager/src/validator_selection.rs b/chain/epoch-manager/src/validator_selection.rs index e39681f113d..ce68db5126c 100644 --- a/chain/epoch-manager/src/validator_selection.rs +++ b/chain/epoch-manager/src/validator_selection.rs @@ -1276,7 +1276,6 @@ mod tests { avg_hidden_validator_seats_per_shard: vec![0; num_shards as usize], 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: 0.into(), online_max_threshold: 0.into(), diff --git a/chain/jsonrpc/jsonrpc-tests/res/genesis_config.json b/chain/jsonrpc/jsonrpc-tests/res/genesis_config.json index 6232adc2e88..c503c105626 100644 --- a/chain/jsonrpc/jsonrpc-tests/res/genesis_config.json +++ b/chain/jsonrpc/jsonrpc-tests/res/genesis_config.json @@ -21,7 +21,6 @@ "max_gas_price": "10000000000000000000000", "block_producer_kickout_threshold": 90, "chunk_producer_kickout_threshold": 90, - "chunk_validator_only_kickout_threshold": 80, "online_min_threshold": [ 9, 10 diff --git a/core/chain-configs/src/genesis_config.rs b/core/chain-configs/src/genesis_config.rs index 13006eeb8d2..0f4718fcab6 100644 --- a/core/chain-configs/src/genesis_config.rs +++ b/core/chain-configs/src/genesis_config.rs @@ -44,10 +44,6 @@ fn default_online_max_threshold() -> Rational32 { Rational32::new(99, 100) } -fn default_chunk_validator_only_kickout_threshold() -> u8 { - 80 -} - fn default_minimum_stake_divisor() -> u64 { 10 } @@ -136,9 +132,6 @@ pub struct GenesisConfig { pub block_producer_kickout_threshold: u8, /// Threshold for kicking out chunk producers, between 0 and 100. pub chunk_producer_kickout_threshold: u8, - /// Threshold for kicking out nodes which are only chunk validators, between 0 and 100. - #[serde(default = "default_chunk_validator_only_kickout_threshold")] - pub chunk_validator_only_kickout_threshold: u8, /// Online minimum threshold below which validator doesn't receive reward. #[serde(default = "default_online_min_threshold")] #[default(Rational32::new(90, 100))] @@ -244,7 +237,6 @@ impl From<&GenesisConfig> for EpochConfig { .clone(), block_producer_kickout_threshold: config.block_producer_kickout_threshold, chunk_producer_kickout_threshold: config.chunk_producer_kickout_threshold, - chunk_validator_only_kickout_threshold: config.chunk_validator_only_kickout_threshold, fishermen_threshold: config.fishermen_threshold, online_min_threshold: config.online_min_threshold, online_max_threshold: config.online_max_threshold, @@ -803,8 +795,6 @@ pub struct ProtocolConfigView { pub block_producer_kickout_threshold: u8, /// Threshold for kicking out chunk producers, between 0 and 100. pub chunk_producer_kickout_threshold: u8, - /// Threshold for kicking out nodes which are only chunk validators, between 0 and 100. - pub chunk_validator_only_kickout_threshold: u8, /// Online minimum threshold below which validator doesn't receive reward. pub online_min_threshold: Rational32, /// Online maximum threshold above which validator gets full reward. @@ -872,8 +862,6 @@ impl From for ProtocolConfigView { max_gas_price: genesis_config.max_gas_price, block_producer_kickout_threshold: genesis_config.block_producer_kickout_threshold, chunk_producer_kickout_threshold: genesis_config.chunk_producer_kickout_threshold, - chunk_validator_only_kickout_threshold: genesis_config - .chunk_validator_only_kickout_threshold, online_min_threshold: genesis_config.online_min_threshold, online_max_threshold: genesis_config.online_max_threshold, gas_price_adjustment_rate: genesis_config.gas_price_adjustment_rate, @@ -1086,7 +1074,6 @@ mod test { "max_gas_price": "10000000000000000000000", "block_producer_kickout_threshold": 90, "chunk_producer_kickout_threshold": 90, - "chunk_validator_only_kickout_threshold": 80, "online_min_threshold": [ 9, 10 @@ -1212,7 +1199,6 @@ mod test { "max_gas_price": "10000000000000000000000", "block_producer_kickout_threshold": 90, "chunk_producer_kickout_threshold": 90, - "chunk_validator_only_kickout_threshold": 80, "online_min_threshold": [ 9, 10 diff --git a/core/chain-configs/src/lib.rs b/core/chain-configs/src/lib.rs index cdd8d4be355..07e594adf33 100644 --- a/core/chain-configs/src/lib.rs +++ b/core/chain-configs/src/lib.rs @@ -52,9 +52,6 @@ pub const BLOCK_PRODUCER_KICKOUT_THRESHOLD: u8 = 90; /// Criterion for kicking out chunk producers. pub const CHUNK_PRODUCER_KICKOUT_THRESHOLD: u8 = 90; -/// Criterion for kicking out chunk validators. -pub const CHUNK_VALIDATOR_ONLY_KICKOUT_THRESHOLD: u8 = 80; - /// Fishermen stake threshold. pub const FISHERMEN_THRESHOLD: Balance = 10 * NEAR_BASE; diff --git a/core/chain-configs/src/test_genesis.rs b/core/chain-configs/src/test_genesis.rs index eea7968e873..51a1c56a741 100644 --- a/core/chain-configs/src/test_genesis.rs +++ b/core/chain-configs/src/test_genesis.rs @@ -66,7 +66,6 @@ enum ValidatorsSpec { struct KickoutsConfig { block_producer_kickout_threshold: u8, chunk_producer_kickout_threshold: u8, - chunk_validator_only_kickout_threshold: u8, } #[derive(Debug, Clone)] @@ -222,7 +221,6 @@ impl TestGenesisBuilder { self.kickouts_config = Some(KickoutsConfig { block_producer_kickout_threshold: 0, chunk_producer_kickout_threshold: 0, - chunk_validator_only_kickout_threshold: 0, }); self } @@ -231,7 +229,6 @@ impl TestGenesisBuilder { self.kickouts_config = Some(KickoutsConfig { block_producer_kickout_threshold: 90, chunk_producer_kickout_threshold: 90, - chunk_validator_only_kickout_threshold: 90, }); self } @@ -352,7 +349,6 @@ impl TestGenesisBuilder { let default = KickoutsConfig { block_producer_kickout_threshold: 0, chunk_producer_kickout_threshold: 0, - chunk_validator_only_kickout_threshold: 0, }; tracing::warn!( "Genesis kickouts_config not explicitly set, defaulting to disabling kickouts.", @@ -444,8 +440,6 @@ impl TestGenesisBuilder { fishermen_threshold: 0, block_producer_kickout_threshold: kickouts_config.block_producer_kickout_threshold, chunk_producer_kickout_threshold: kickouts_config.chunk_producer_kickout_threshold, - chunk_validator_only_kickout_threshold: kickouts_config - .chunk_validator_only_kickout_threshold, transaction_validity_period, protocol_version, protocol_treasury_account, diff --git a/core/chain-configs/src/test_utils.rs b/core/chain-configs/src/test_utils.rs index 9400c5aad78..9931d0a8a8c 100644 --- a/core/chain-configs/src/test_utils.rs +++ b/core/chain-configs/src/test_utils.rs @@ -13,10 +13,9 @@ use num_rational::Ratio; use crate::{ Genesis, GenesisConfig, BLOCK_PRODUCER_KICKOUT_THRESHOLD, CHUNK_PRODUCER_KICKOUT_THRESHOLD, - CHUNK_VALIDATOR_ONLY_KICKOUT_THRESHOLD, FISHERMEN_THRESHOLD, GAS_PRICE_ADJUSTMENT_RATE, - INITIAL_GAS_LIMIT, MAX_INFLATION_RATE, MIN_GAS_PRICE, NEAR_BASE, NUM_BLOCKS_PER_YEAR, - PROTOCOL_REWARD_RATE, PROTOCOL_TREASURY_ACCOUNT, PROTOCOL_UPGRADE_STAKE_THRESHOLD, - TRANSACTION_VALIDITY_PERIOD, + FISHERMEN_THRESHOLD, GAS_PRICE_ADJUSTMENT_RATE, INITIAL_GAS_LIMIT, MAX_INFLATION_RATE, + MIN_GAS_PRICE, NEAR_BASE, NUM_BLOCKS_PER_YEAR, PROTOCOL_REWARD_RATE, PROTOCOL_TREASURY_ACCOUNT, + PROTOCOL_UPGRADE_STAKE_THRESHOLD, TRANSACTION_VALIDITY_PERIOD, }; /// Initial balance used in tests. @@ -92,7 +91,6 @@ impl Genesis { gas_price_adjustment_rate: GAS_PRICE_ADJUSTMENT_RATE, block_producer_kickout_threshold: BLOCK_PRODUCER_KICKOUT_THRESHOLD, chunk_producer_kickout_threshold: CHUNK_PRODUCER_KICKOUT_THRESHOLD, - chunk_validator_only_kickout_threshold: CHUNK_VALIDATOR_ONLY_KICKOUT_THRESHOLD, validators, protocol_reward_rate: PROTOCOL_REWARD_RATE, total_supply: get_initial_supply(&records), diff --git a/core/primitives/src/epoch_manager.rs b/core/primitives/src/epoch_manager.rs index 32a047fe4a8..63e73a5b866 100644 --- a/core/primitives/src/epoch_manager.rs +++ b/core/primitives/src/epoch_manager.rs @@ -37,8 +37,6 @@ pub struct EpochConfig { pub block_producer_kickout_threshold: u8, /// Threshold for kicking out chunk producers. pub chunk_producer_kickout_threshold: u8, - /// Threshold for kicking out nodes which are only chunk validators. - pub chunk_validator_only_kickout_threshold: u8, /// Max ratio of validators that we can kick out in an epoch pub validator_max_kickout_stake_perc: u8, /// Online minimum threshold below which validator doesn't receive reward. @@ -188,7 +186,6 @@ impl AllEpochConfig { if checked_feature!("stable", LowerValidatorKickoutPercentForDebugging, protocol_version) { config.block_producer_kickout_threshold = 50; config.chunk_producer_kickout_threshold = 50; - config.chunk_validator_only_kickout_threshold = 50; } } diff --git a/core/primitives/src/shard_layout.rs b/core/primitives/src/shard_layout.rs index 565c3e4a8a4..87ac2778f9e 100644 --- a/core/primitives/src/shard_layout.rs +++ b/core/primitives/src/shard_layout.rs @@ -532,7 +532,6 @@ mod tests { avg_hidden_validator_seats_per_shard: vec![], block_producer_kickout_threshold: 0, chunk_producer_kickout_threshold: 0, - chunk_validator_only_kickout_threshold: 0, validator_max_kickout_stake_perc: 0, online_min_threshold: 0.into(), online_max_threshold: 0.into(), diff --git a/core/primitives/src/types.rs b/core/primitives/src/types.rs index af982d2a836..1e7635e6952 100644 --- a/core/primitives/src/types.rs +++ b/core/primitives/src/types.rs @@ -1066,8 +1066,6 @@ pub enum ValidatorKickoutReason { NotEnoughBlocks { produced: NumBlocks, expected: NumBlocks }, /// Validator didn't produce enough chunks. NotEnoughChunks { produced: NumBlocks, expected: NumBlocks }, - /// Validator didn't produce enough chunk endorsements. - NotEnoughChunkEndorsements { produced: NumBlocks, expected: NumBlocks }, /// Validator unstaked themselves. Unstaked, /// Validator stake is now below threshold diff --git a/genesis-tools/genesis-csv-to-json/src/csv_to_json_configs.rs b/genesis-tools/genesis-csv-to-json/src/csv_to_json_configs.rs index b5b1fd18f65..73c4f811999 100644 --- a/genesis-tools/genesis-csv-to-json/src/csv_to_json_configs.rs +++ b/genesis-tools/genesis-csv-to-json/src/csv_to_json_configs.rs @@ -1,9 +1,9 @@ use near_chain_configs::{ Genesis, GenesisConfig, BLOCK_PRODUCER_KICKOUT_THRESHOLD, CHUNK_PRODUCER_KICKOUT_THRESHOLD, - CHUNK_VALIDATOR_ONLY_KICKOUT_THRESHOLD, EXPECTED_EPOCH_LENGTH, FISHERMEN_THRESHOLD, - GAS_PRICE_ADJUSTMENT_RATE, GENESIS_CONFIG_FILENAME, INITIAL_GAS_LIMIT, MAX_INFLATION_RATE, - MIN_GAS_PRICE, NEAR_BASE, NUM_BLOCKS_PER_YEAR, NUM_BLOCK_PRODUCER_SEATS, PROTOCOL_REWARD_RATE, - PROTOCOL_UPGRADE_STAKE_THRESHOLD, TRANSACTION_VALIDITY_PERIOD, + EXPECTED_EPOCH_LENGTH, FISHERMEN_THRESHOLD, GAS_PRICE_ADJUSTMENT_RATE, GENESIS_CONFIG_FILENAME, + INITIAL_GAS_LIMIT, MAX_INFLATION_RATE, MIN_GAS_PRICE, NEAR_BASE, NUM_BLOCKS_PER_YEAR, + NUM_BLOCK_PRODUCER_SEATS, PROTOCOL_REWARD_RATE, PROTOCOL_UPGRADE_STAKE_THRESHOLD, + TRANSACTION_VALIDITY_PERIOD, }; use near_primitives::types::{Balance, NumShards, ShardId}; use near_primitives::utils::get_num_seats_per_shard; @@ -71,7 +71,6 @@ pub fn csv_to_json_configs(home: &Path, chain_id: String, tracked_shards: Vec, - /// chunk_validator_only_kickout_threshold to set in the output genesis file - #[clap(long)] - chunk_validator_only_kickout_threshold: Option, /// protocol_reward_rate to set in the output genesis file. Give a ratio here (e.g. "1/10") #[clap(long)] protocol_reward_rate: Option, @@ -97,7 +94,6 @@ impl AmendGenesisCommand { max_inflation_rate: self.max_inflation_rate, 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, gas_limit: self.gas_limit, min_gas_price: self.min_gas_price, max_gas_price: self.max_gas_price, diff --git a/tools/amend-genesis/src/lib.rs b/tools/amend-genesis/src/lib.rs index 47baaff9812..a5019b02778 100644 --- a/tools/amend-genesis/src/lib.rs +++ b/tools/amend-genesis/src/lib.rs @@ -280,7 +280,6 @@ pub struct GenesisChanges { pub max_inflation_rate: Option, pub block_producer_kickout_threshold: Option, pub chunk_producer_kickout_threshold: Option, - pub chunk_validator_only_kickout_threshold: Option, pub gas_limit: Option, pub min_gas_price: Option, pub max_gas_price: Option, @@ -410,9 +409,6 @@ pub fn amend_genesis( if let Some(t) = genesis_changes.chunk_producer_kickout_threshold { genesis.config.chunk_producer_kickout_threshold = t; } - if let Some(t) = genesis_changes.chunk_validator_only_kickout_threshold { - genesis.config.chunk_validator_only_kickout_threshold = t; - } if let Some(l) = genesis_changes.gas_limit { genesis.config.gas_limit = l; } @@ -645,8 +641,6 @@ mod test { near_chain_configs::BLOCK_PRODUCER_KICKOUT_THRESHOLD, chunk_producer_kickout_threshold: near_chain_configs::CHUNK_PRODUCER_KICKOUT_THRESHOLD, - chunk_validator_only_kickout_threshold: - near_chain_configs::CHUNK_VALIDATOR_ONLY_KICKOUT_THRESHOLD, online_max_threshold: Rational32::new(99, 100), online_min_threshold: Rational32::new( near_chain_configs::BLOCK_PRODUCER_KICKOUT_THRESHOLD as i32, diff --git a/tools/fork-network/src/cli.rs b/tools/fork-network/src/cli.rs index ada0195b7aa..8c747a95391 100644 --- a/tools/fork-network/src/cli.rs +++ b/tools/fork-network/src/cli.rs @@ -791,7 +791,6 @@ impl ForkNetworkCommand { avg_hidden_validator_seats_per_shard: epoch_config.avg_hidden_validator_seats_per_shard, block_producer_kickout_threshold: 0, chunk_producer_kickout_threshold: 0, - chunk_validator_only_kickout_threshold: 0, max_kickout_stake_perc: 0, online_min_threshold: epoch_config.online_min_threshold, online_max_threshold: epoch_config.online_max_threshold, diff --git a/utils/mainnet-res/res/mainnet_genesis.json b/utils/mainnet-res/res/mainnet_genesis.json index e45bbb1c6e7..ded3caf5812 100644 --- a/utils/mainnet-res/res/mainnet_genesis.json +++ b/utils/mainnet-res/res/mainnet_genesis.json @@ -16,7 +16,6 @@ "min_gas_price": "1000000000", "block_producer_kickout_threshold": 90, "chunk_producer_kickout_threshold": 90, - "chunk_validator_only_kickout_threshold": 80, "online_min_threshold": [ 90, 100