diff --git a/CHANGELOG.md b/CHANGELOG.md index d1a5e91ea12..bf6c53d1627 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## [unreleased] ### Protocol Changes -**No Changes** +* Sets `chunk_validator_only_kickout_threshold` to 70. Uses this kickout threshold as a cutoff threshold for contribution of endorsement ratio in rewards calculation: if endorsement ratio is above 70%, the contribution of endorsement ratio in average uptime calculation is 100%, otherwise it is 0%. Endorsements received are now included in `BlockHeader` to improve kickout and reward calculation for chunk validators. ### Non-protocol Changes * Added [documentation](./docs/misc/archival_data_recovery.md) and a [reference](./scripts/recover_missing_archival_data.sh) script to recover the data lost in archival nodes at the beginning of 2024. diff --git a/chain/chain/src/tests/simple_chain.rs b/chain/chain/src/tests/simple_chain.rs index 20bf78ec5f4..80efaaebf9c 100644 --- a/chain/chain/src/tests/simple_chain.rs +++ b/chain/chain/src/tests/simple_chain.rs @@ -34,7 +34,7 @@ fn build_chain() { if cfg!(feature = "nightly") { insta::assert_snapshot!(hash, @"Hc3bWEd7ikHf9BAe2SknvH2jAAakEtBRU1FBu6Udocm3"); } else { - insta::assert_snapshot!(hash, @"GpzRk39JJJZkXiPaXpe7tv1KkyeWYBPYEakZFP6hznGh"); + insta::assert_snapshot!(hash, @"dY6Z6HdATLWK3wwxkNtUs8T1GaEQqpxUCXm7TectWW7"); } for i in 1..5 { @@ -52,7 +52,7 @@ fn build_chain() { if cfg!(feature = "nightly") { insta::assert_snapshot!(hash, @"39R6bDFXkPfwdYs4crV3RyCde85ecycqP5DBwdtwyjcJ"); } else { - insta::assert_snapshot!(hash, @"ANjdWVaMLmMKmXMLfkzVbWSWYri6Q5Mvc1qRogUTZQAK"); + insta::assert_snapshot!(hash, @"6RnKeuiGmxkFxNYeEmAbK6NzwvKYuTcKCwqAmqJ6m3DG"); } } diff --git a/chain/epoch-manager/src/test_utils.rs b/chain/epoch-manager/src/test_utils.rs index 299280bc14b..2f5133e4a2e 100644 --- a/chain/epoch-manager/src/test_utils.rs +++ b/chain/epoch-manager/src/test_utils.rs @@ -1,6 +1,7 @@ use std::collections::{BTreeMap, HashMap}; use near_primitives::types::EpochId; +use near_primitives::types::ProtocolVersion; use near_store::Store; use num_rational::Ratio; @@ -48,6 +49,7 @@ pub fn epoch_info( accounts: Vec<(AccountId, Balance)>, block_producers_settlement: Vec, chunk_producers_settlement: Vec>, + protocol_version: ProtocolVersion, ) -> EpochInfo { let num_seats = block_producers_settlement.len() as u64; epoch_info_with_num_seats( @@ -60,6 +62,7 @@ pub fn epoch_info( Default::default(), 0, num_seats, + protocol_version, ) } @@ -73,6 +76,7 @@ pub fn epoch_info_with_num_seats( validator_reward: HashMap, minted_amount: Balance, num_seats: NumSeats, + protocol_version: ProtocolVersion, ) -> EpochInfo { let seat_price = find_threshold(&accounts.iter().map(|(_, s)| *s).collect::>(), num_seats).unwrap(); @@ -114,7 +118,7 @@ pub fn epoch_info_with_num_seats( validator_kickout.into_iter().collect(), minted_amount, seat_price, - PROTOCOL_VERSION, + protocol_version, TEST_SEED, validator_mandates, ) diff --git a/chain/epoch-manager/src/tests/mod.rs b/chain/epoch-manager/src/tests/mod.rs index 4e149706ec9..6bc992de46c 100644 --- a/chain/epoch-manager/src/tests/mod.rs +++ b/chain/epoch-manager/src/tests/mod.rs @@ -72,6 +72,7 @@ fn test_stake_validator() { reward(vec![("near".parse().unwrap(), 0)]), 0, 4, + PROTOCOL_VERSION, ); let compare_epoch_infos = |a: &EpochInfo, b: &EpochInfo| -> bool { a.validators_iter().eq(b.validators_iter()) @@ -115,6 +116,7 @@ fn test_stake_validator() { reward(vec![("test1".parse().unwrap(), 0), ("near".parse().unwrap(), 0)]), 0, 4, + PROTOCOL_VERSION, ); // no validator change in the last epoch let epoch3 = epoch_manager.get_epoch_id(&h[3]).unwrap(); @@ -2540,7 +2542,13 @@ fn test_validator_kickout_determinism() { ("test4".parse().unwrap(), 500), ("test5".parse().unwrap(), 500), ]; - let epoch_info = epoch_info(0, accounts, vec![0, 1, 2, 3], vec![vec![0, 1, 2], vec![0, 1, 3]]); + let epoch_info = epoch_info( + 0, + accounts, + vec![0, 1, 2, 3], + vec![vec![0, 1, 2], vec![0, 1, 3]], + PROTOCOL_VERSION, + ); let block_validator_tracker = HashMap::from([ (0, ValidatorStats { produced: 100, expected: 100 }), (1, ValidatorStats { produced: 90, expected: 100 }), @@ -2623,7 +2631,13 @@ fn test_chunk_validators_with_different_endorsement_ratio() { ("test2".parse().unwrap(), 500), ("test3".parse().unwrap(), 500), ]; - let epoch_info = epoch_info(0, accounts, vec![0, 1, 2, 3], vec![vec![0, 1, 2], vec![0, 1, 3]]); + let epoch_info = epoch_info( + 0, + accounts, + vec![0, 1, 2, 3], + vec![vec![0, 1, 2], vec![0, 1, 3]], + PROTOCOL_VERSION, + ); let block_validator_tracker = HashMap::from([ (0, ValidatorStats { produced: 100, expected: 100 }), (1, ValidatorStats { produced: 100, expected: 100 }), @@ -2679,7 +2693,13 @@ fn test_chunk_validators_with_same_endorsement_ratio_and_different_stake() { ("test2".parse().unwrap(), 500), ("test3".parse().unwrap(), 499), ]; - let epoch_info = epoch_info(0, accounts, vec![0, 1, 2, 3], vec![vec![0, 1, 2], vec![0, 1, 3]]); + let epoch_info = epoch_info( + 0, + accounts, + vec![0, 1, 2, 3], + vec![vec![0, 1, 2], vec![0, 1, 3]], + PROTOCOL_VERSION, + ); let block_validator_tracker = HashMap::from([ (0, ValidatorStats { produced: 100, expected: 100 }), (1, ValidatorStats { produced: 100, expected: 100 }), @@ -2735,7 +2755,13 @@ fn test_chunk_validators_with_same_endorsement_ratio_and_stake() { ("test2".parse().unwrap(), 500), ("test3".parse().unwrap(), 500), ]; - let epoch_info = epoch_info(0, accounts, vec![0, 1, 2, 3], vec![vec![0, 1, 2], vec![0, 1, 3]]); + let epoch_info = epoch_info( + 0, + accounts, + vec![0, 1, 2, 3], + vec![vec![0, 1, 2], vec![0, 1, 3]], + PROTOCOL_VERSION, + ); let block_validator_tracker = HashMap::from([ (0, ValidatorStats { produced: 100, expected: 100 }), (1, ValidatorStats { produced: 100, expected: 100 }), @@ -2785,7 +2811,13 @@ fn test_validator_kickout_sanity() { ("test4".parse().unwrap(), 500), ("test5".parse().unwrap(), 500), ]; - let epoch_info = epoch_info(0, accounts, vec![0, 1, 2, 3], vec![vec![0, 1, 2], vec![0, 1, 3]]); + let epoch_info = epoch_info( + 0, + accounts, + vec![0, 1, 2, 3], + vec![vec![0, 1, 2], vec![0, 1, 3]], + PROTOCOL_VERSION, + ); let block_validator_tracker = HashMap::from([ (0, ValidatorStats { produced: 100, expected: 100 }), (1, ValidatorStats { produced: 90, expected: 100 }), @@ -2916,7 +2948,13 @@ fn test_chunk_endorsement_stats() { ("test2".parse().unwrap(), 1000), ("test3".parse().unwrap(), 1000), ]; - let epoch_info = epoch_info(0, accounts, vec![0, 1, 2, 3], vec![vec![0, 1, 2], vec![0, 1, 3]]); + let epoch_info = epoch_info( + 0, + accounts, + vec![0, 1, 2, 3], + vec![vec![0, 1, 2], vec![0, 1, 3]], + PROTOCOL_VERSION, + ); let (validator_stats, kickouts) = EpochManager::compute_validators_to_reward_and_kickout( &epoch_config, &epoch_info, @@ -2994,7 +3032,8 @@ fn test_max_kickout_stake_ratio() { ("test3".parse().unwrap(), 1000), ("test4".parse().unwrap(), 1000), ]; - let epoch_info = epoch_info(0, accounts, vec![0, 1, 2, 3], vec![vec![0, 1], vec![2, 4]]); + let epoch_info = + epoch_info(0, accounts, vec![0, 1, 2, 3], vec![vec![0, 1], vec![2, 4]], PROTOCOL_VERSION); let block_stats = HashMap::from([ (0, ValidatorStats { produced: 50, expected: 100 }), // here both test1 and test2 produced the most number of blocks, we made that intentionally @@ -3106,13 +3145,8 @@ fn test_max_kickout_stake_ratio() { /// Common test scenario for a couple of tests exercising chunk validator kickouts. fn test_chunk_validator_kickout( expected_kickouts: HashMap, - expect_new_algorithm: bool, + use_endorsement_cutoff_threshold: bool, ) { - if expect_new_algorithm - != ProtocolFeature::ChunkEndorsementsInBlockHeader.enabled(PROTOCOL_VERSION) - { - return; - } let mut epoch_config = epoch_config(5, 2, 4, 80, 80, 80).for_protocol_version(PROTOCOL_VERSION); let accounts = vec![ ("test0".parse().unwrap(), 1000), @@ -3122,7 +3156,17 @@ fn test_chunk_validator_kickout( ("test4".parse().unwrap(), 1000), ("test5".parse().unwrap(), 1000), ]; - let epoch_info = epoch_info(0, accounts, vec![0, 1, 2, 3], vec![vec![0, 1], vec![0, 2]]); + let epoch_info = epoch_info( + 0, + accounts, + vec![0, 1, 2, 3], + vec![vec![0, 1], vec![0, 2]], + if use_endorsement_cutoff_threshold { + PROTOCOL_VERSION + } else { + ProtocolFeature::ChunkEndorsementsInBlockHeader.protocol_version() - 1 + }, + ); let block_stats = HashMap::from([ (0, ValidatorStats { produced: 90, expected: 100 }), (1, ValidatorStats { produced: 90, expected: 100 }), @@ -3189,16 +3233,19 @@ fn test_chunk_validator_kicked_out_for_low_endorsement() { #[test] /// Tests that a validator is not kicked out due to low endorsement only (as long as it produces most of its blocks and chunks). fn test_block_and_chunk_producer_not_kicked_out_for_low_endorsements() { - if !ProtocolFeature::ChunkEndorsementsInBlockHeader.enabled(PROTOCOL_VERSION) { - return; - } let mut epoch_config = epoch_config(5, 2, 4, 80, 80, 80).for_protocol_version(PROTOCOL_VERSION); let accounts = vec![ ("test0".parse().unwrap(), 1000), ("test1".parse().unwrap(), 1000), ("test2".parse().unwrap(), 1000), ]; - let epoch_info = epoch_info(0, accounts, vec![0, 1, 2], vec![vec![0, 1, 2], vec![0, 1, 2]]); + let epoch_info = epoch_info( + 0, + accounts, + vec![0, 1, 2], + vec![vec![0, 1, 2], vec![0, 1, 2]], + PROTOCOL_VERSION, + ); let block_stats = HashMap::from([ (0, ValidatorStats { produced: 90, expected: 100 }), (1, ValidatorStats { produced: 90, expected: 100 }), diff --git a/core/primitives-core/src/version.rs b/core/primitives-core/src/version.rs index fb07c528dd2..ec453a99284 100644 --- a/core/primitives-core/src/version.rs +++ b/core/primitives-core/src/version.rs @@ -225,7 +225,8 @@ impl ProtocolFeature { ProtocolFeature::BLS12381 | ProtocolFeature::EthImplicitAccounts => 70, ProtocolFeature::FixMinStakeRatio => 71, ProtocolFeature::IncreaseStorageProofSizeSoftLimit - | ProtocolFeature::ChunkEndorsementV2 => 72, + | ProtocolFeature::ChunkEndorsementV2 + | ProtocolFeature::ChunkEndorsementsInBlockHeader => 72, // This protocol version is reserved for use in resharding tests. An extra resharding // is simulated on top of the latest shard layout in production. Note that later @@ -244,7 +245,6 @@ impl ProtocolFeature { // TODO(#11201): When stabilizing this feature in mainnet, also remove the temporary code // that always enables this for mocknet (see config_mocknet function). ProtocolFeature::ShuffleShardAssignments => 143, - ProtocolFeature::ChunkEndorsementsInBlockHeader => 145, } } diff --git a/core/primitives/res/epoch_configs/mainnet/100.json b/core/primitives/res/epoch_configs/mainnet/100.json index ca93d5ea8fa..57ff074dd30 100644 --- a/core/primitives/res/epoch_configs/mainnet/100.json +++ b/core/primitives/res/epoch_configs/mainnet/100.json @@ -21,7 +21,7 @@ ], "block_producer_kickout_threshold": 80, "chunk_producer_kickout_threshold": 80, - "chunk_validator_only_kickout_threshold": 80, + "chunk_validator_only_kickout_threshold": 70, "target_validator_mandates_per_shard": 68, "validator_max_kickout_stake_perc": 30, "online_min_threshold": [ diff --git a/core/primitives/res/epoch_configs/mainnet/101.json b/core/primitives/res/epoch_configs/mainnet/101.json index 4c4880bd5e7..12244d614c4 100644 --- a/core/primitives/res/epoch_configs/mainnet/101.json +++ b/core/primitives/res/epoch_configs/mainnet/101.json @@ -19,7 +19,7 @@ ], "block_producer_kickout_threshold": 80, "chunk_producer_kickout_threshold": 80, - "chunk_validator_only_kickout_threshold": 80, + "chunk_validator_only_kickout_threshold": 70, "target_validator_mandates_per_shard": 68, "validator_max_kickout_stake_perc": 30, "online_min_threshold": [ diff --git a/core/primitives/res/epoch_configs/mainnet/143.json b/core/primitives/res/epoch_configs/mainnet/143.json index b2f9154fd61..5cd0fa2958b 100644 --- a/core/primitives/res/epoch_configs/mainnet/143.json +++ b/core/primitives/res/epoch_configs/mainnet/143.json @@ -19,7 +19,7 @@ ], "block_producer_kickout_threshold": 80, "chunk_producer_kickout_threshold": 80, - "chunk_validator_only_kickout_threshold": 80, + "chunk_validator_only_kickout_threshold": 70, "target_validator_mandates_per_shard": 68, "validator_max_kickout_stake_perc": 30, "online_min_threshold": [ diff --git a/core/primitives/res/epoch_configs/mainnet/145.json b/core/primitives/res/epoch_configs/mainnet/72.json similarity index 96% rename from core/primitives/res/epoch_configs/mainnet/145.json rename to core/primitives/res/epoch_configs/mainnet/72.json index 5cd0fa2958b..12244d614c4 100644 --- a/core/primitives/res/epoch_configs/mainnet/145.json +++ b/core/primitives/res/epoch_configs/mainnet/72.json @@ -84,6 +84,6 @@ 62500 ], "chunk_producer_assignment_changes_limit": 5, - "shuffle_shard_assignment_for_chunk_producers": true + "shuffle_shard_assignment_for_chunk_producers": false } } \ No newline at end of file diff --git a/core/primitives/res/epoch_configs/mocknet/100.json b/core/primitives/res/epoch_configs/mocknet/100.json index 2a0fae43fdb..0251e2a4ff2 100644 --- a/core/primitives/res/epoch_configs/mocknet/100.json +++ b/core/primitives/res/epoch_configs/mocknet/100.json @@ -21,7 +21,7 @@ ], "block_producer_kickout_threshold": 80, "chunk_producer_kickout_threshold": 80, - "chunk_validator_only_kickout_threshold": 80, + "chunk_validator_only_kickout_threshold": 70, "target_validator_mandates_per_shard": 68, "validator_max_kickout_stake_perc": 30, "online_min_threshold": [ diff --git a/core/primitives/res/epoch_configs/mocknet/101.json b/core/primitives/res/epoch_configs/mocknet/101.json index 035ccf5a5d6..c4256c522e5 100644 --- a/core/primitives/res/epoch_configs/mocknet/101.json +++ b/core/primitives/res/epoch_configs/mocknet/101.json @@ -19,7 +19,7 @@ ], "block_producer_kickout_threshold": 80, "chunk_producer_kickout_threshold": 80, - "chunk_validator_only_kickout_threshold": 80, + "chunk_validator_only_kickout_threshold": 70, "target_validator_mandates_per_shard": 68, "validator_max_kickout_stake_perc": 30, "online_min_threshold": [ diff --git a/core/primitives/res/epoch_configs/mocknet/145.json b/core/primitives/res/epoch_configs/mocknet/72.json similarity index 100% rename from core/primitives/res/epoch_configs/mocknet/145.json rename to core/primitives/res/epoch_configs/mocknet/72.json diff --git a/core/primitives/res/epoch_configs/testnet/100.json b/core/primitives/res/epoch_configs/testnet/100.json index 9d9682cc371..066be0b8b10 100644 --- a/core/primitives/res/epoch_configs/testnet/100.json +++ b/core/primitives/res/epoch_configs/testnet/100.json @@ -21,7 +21,7 @@ ], "block_producer_kickout_threshold": 80, "chunk_producer_kickout_threshold": 80, - "chunk_validator_only_kickout_threshold": 80, + "chunk_validator_only_kickout_threshold": 70, "target_validator_mandates_per_shard": 68, "validator_max_kickout_stake_perc": 30, "online_min_threshold": [ diff --git a/core/primitives/res/epoch_configs/testnet/101.json b/core/primitives/res/epoch_configs/testnet/101.json index f89cd337f1c..45cfe0c1670 100644 --- a/core/primitives/res/epoch_configs/testnet/101.json +++ b/core/primitives/res/epoch_configs/testnet/101.json @@ -19,7 +19,7 @@ ], "block_producer_kickout_threshold": 80, "chunk_producer_kickout_threshold": 80, - "chunk_validator_only_kickout_threshold": 80, + "chunk_validator_only_kickout_threshold": 70, "target_validator_mandates_per_shard": 68, "validator_max_kickout_stake_perc": 30, "online_min_threshold": [ diff --git a/core/primitives/res/epoch_configs/testnet/143.json b/core/primitives/res/epoch_configs/testnet/143.json index c0b7bc95c0b..ae6ca2a0066 100644 --- a/core/primitives/res/epoch_configs/testnet/143.json +++ b/core/primitives/res/epoch_configs/testnet/143.json @@ -19,7 +19,7 @@ ], "block_producer_kickout_threshold": 80, "chunk_producer_kickout_threshold": 80, - "chunk_validator_only_kickout_threshold": 80, + "chunk_validator_only_kickout_threshold": 70, "target_validator_mandates_per_shard": 68, "validator_max_kickout_stake_perc": 30, "online_min_threshold": [ diff --git a/core/primitives/res/epoch_configs/testnet/145.json b/core/primitives/res/epoch_configs/testnet/72.json similarity index 96% rename from core/primitives/res/epoch_configs/testnet/145.json rename to core/primitives/res/epoch_configs/testnet/72.json index ae6ca2a0066..45cfe0c1670 100644 --- a/core/primitives/res/epoch_configs/testnet/145.json +++ b/core/primitives/res/epoch_configs/testnet/72.json @@ -84,6 +84,6 @@ 62500 ], "chunk_producer_assignment_changes_limit": 5, - "shuffle_shard_assignment_for_chunk_producers": true + "shuffle_shard_assignment_for_chunk_producers": false } } \ No newline at end of file diff --git a/core/primitives/src/block_header.rs b/core/primitives/src/block_header.rs index c75d3bad929..05561f60ee1 100644 --- a/core/primitives/src/block_header.rs +++ b/core/primitives/src/block_header.rs @@ -604,10 +604,10 @@ impl BlockHeader { block_merkle_root, }; - if chunk_endorsements.is_some() { - debug_assert!(ProtocolFeature::ChunkEndorsementsInBlockHeader - .enabled(this_epoch_protocol_version)); - let chunk_endorsements = chunk_endorsements.unwrap(); + if ProtocolFeature::ChunkEndorsementsInBlockHeader.enabled(this_epoch_protocol_version) { + let chunk_endorsements = chunk_endorsements.unwrap_or_else(|| { + panic!("BlockHeaderV5 is enabled but chunk endorsement bitmap is not provided") + }); let inner_rest = BlockHeaderInnerRestV5 { block_body_hash, prev_chunk_outgoing_receipts_root, diff --git a/core/primitives/src/epoch_manager.rs b/core/primitives/src/epoch_manager.rs index 281be439907..6198093345a 100644 --- a/core/primitives/src/epoch_manager.rs +++ b/core/primitives/src/epoch_manager.rs @@ -397,10 +397,10 @@ static CONFIGS: &[(&str, ProtocolVersion, &str)] = &[ include_config!("mainnet", 69, "69.json"), include_config!("mainnet", 70, "70.json"), include_config!("mainnet", 71, "71.json"), + include_config!("mainnet", 72, "72.json"), include_config!("mainnet", 100, "100.json"), include_config!("mainnet", 101, "101.json"), include_config!("mainnet", 143, "143.json"), - include_config!("mainnet", 145, "145.json"), // Epoch configs for testnet (genesis protool version is 29). include_config!("testnet", 29, "29.json"), include_config!("testnet", 48, "48.json"), @@ -410,10 +410,10 @@ static CONFIGS: &[(&str, ProtocolVersion, &str)] = &[ include_config!("testnet", 69, "69.json"), include_config!("testnet", 70, "70.json"), include_config!("testnet", 71, "71.json"), + include_config!("testnet", 72, "72.json"), include_config!("testnet", 100, "100.json"), include_config!("testnet", 101, "101.json"), include_config!("testnet", 143, "143.json"), - include_config!("testnet", 145, "145.json"), // Epoch configs for mocknet (forknet) (genesis protool version is 29). // TODO(#11900): Check the forknet config and uncomment this. // include_config!("mocknet", 29, "29.json"), @@ -423,9 +423,9 @@ static CONFIGS: &[(&str, ProtocolVersion, &str)] = &[ // include_config!("mocknet", 69, "69.json"), // include_config!("mocknet", 70, "70.json"), // include_config!("mocknet", 71, "71.json"), + // include_config!("mocknet", 72, "72.json"), // include_config!("mocknet", 100, "100.json"), // include_config!("mocknet", 101, "101.json"), - // include_config!("mocknet", 145, "145.json"), ]; /// Store for `[EpochConfig]` per protocol version.` diff --git a/integration-tests/src/tests/nearcore/stake_nodes.rs b/integration-tests/src/tests/nearcore/stake_nodes.rs index 44270e22e0a..a0870f982a4 100644 --- a/integration-tests/src/tests/nearcore/stake_nodes.rs +++ b/integration-tests/src/tests/nearcore/stake_nodes.rs @@ -6,7 +6,6 @@ use actix::{Actor, Addr, System}; use futures::{future, FutureExt}; use near_chain_configs::test_utils::{TESTING_INIT_BALANCE, TESTING_INIT_STAKE}; use near_primitives::num_rational::Ratio; -use near_primitives::version::{ProtocolFeature, PROTOCOL_VERSION}; use rand::Rng; use crate::tests::genesis_helpers::genesis_hash; @@ -612,12 +611,8 @@ fn test_inflation() { // https://nomicon.io/Economics/Economic#validator-rewards-calculation let protocol_reward = base_reward * 1 / 10; let validator_reward = base_reward - protocol_reward; - let inflation = if ProtocolFeature::ChunkEndorsementsInBlockHeader.enabled(PROTOCOL_VERSION) { - // Chunk endorsement ratio 9/10 is mapped to 1 so the reward multiplier becomes 20/27. - protocol_reward + validator_reward * 20 / 27 - } else { - protocol_reward + validator_reward * 10 / 27 - }; + // Chunk endorsement ratio 9/10 is mapped to 1 so the reward multiplier becomes 20/27. + let inflation = protocol_reward + validator_reward * 20 / 27; tracing::info!(?block.header.total_supply, ?block.header.height, ?initial_total_supply, epoch_length, ?inflation, "Step2: epoch2"); if block.header.total_supply == initial_total_supply + inflation { done2_copy2.store(true, Ordering::SeqCst); diff --git a/nearcore/tests/economics.rs b/nearcore/tests/economics.rs index 87ac9257677..e02feea8082 100644 --- a/nearcore/tests/economics.rs +++ b/nearcore/tests/economics.rs @@ -9,10 +9,7 @@ use near_chain_configs::Genesis; use near_client::test_utils::TestEnv; use near_crypto::{InMemorySigner, KeyType}; use near_o11y::testonly::init_integration_logger; -use near_primitives::{ - transaction::SignedTransaction, - version::{ProtocolFeature, PROTOCOL_VERSION}, -}; +use near_primitives::transaction::SignedTransaction; use near_store::{genesis::initialize_genesis_state, test_utils::create_test_store}; use nearcore::NightshadeRuntime; use testlib::fees_utils::FeeHelper; @@ -116,18 +113,11 @@ fn test_burn_mint() { .as_u128() }; // supply + 10% of protocol rewards (where protocol reward rate = 1/10) + average_uptime * 90% of validator rewards. + // Validator stats: Block production rate: 2/2, Chunk production rate: 1/2, Chunk endorsement rate: 1/1. + // Average uptime: (2/2 + 1/2 + 1/1) / 3 = 5/6 + // 1/10 + 5/6 * 9/10 = 85/100 let expected_total_supply = - if ProtocolFeature::ChunkEndorsementsInBlockHeader.enabled(PROTOCOL_VERSION) { - // Validator stats: Block production rate: 2/2, Chunk production rate: 1/2, Chunk endorsement rate: 1/1. - // Average uptime: (2/2 + 1/2 + 1/1) / 3 = 5/6 - // 1/10 + 5/6 * 9/10 = 85/100 - initial_total_supply + epoch_total_reward * 85 / 100 - half_transfer_cost - } else { - // Validator stats: Block production rate: 2/2, Chunk production rate: 1/2, Chunk endorsement rate: 1/2. - // Average uptime: (2/2 + 1/2 + 1/2) / 3 = 2/3 - // 1/10 + 2/3 * 9/10 = 7/10 - initial_total_supply + epoch_total_reward * 7 / 10 - half_transfer_cost - }; + initial_total_supply + epoch_total_reward * 85 / 100 - half_transfer_cost; assert_eq!(block3.header().total_supply(), expected_total_supply); assert_eq!(block3.chunks()[0].prev_balance_burnt(), half_transfer_cost); // Block 4: subtract 2nd part of transfer. diff --git a/pytest/tests/sanity/rpc_hash.py b/pytest/tests/sanity/rpc_hash.py index 090a2326ef5..41a2398ad75 100644 --- a/pytest/tests/sanity/rpc_hash.py +++ b/pytest/tests/sanity/rpc_hash.py @@ -28,7 +28,7 @@ BLOCK_HEADER_V2_PROTOCOL_VERSION = 42 BLOCK_HEADER_V3_PROTOCOL_VERSION = 50 BLOCK_HEADER_V4_PROTOCOL_VERSION = 63 -BLOCK_HEADER_V5_PROTOCOL_VERSION = 145 +BLOCK_HEADER_V5_PROTOCOL_VERSION = 72 def serialize(msg: typing.Any) -> bytes: