From cd9ca90105c52d6e73931515af4eb0d65581fc71 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 7 Oct 2021 21:03:36 +0300 Subject: [PATCH] Revert "fix: correct feature handling" This reverts commit 3f8923e53df08536c12c0b754afa8ca8b5c1f461. We don't know if that change is actually correct or not, see https://github.com/near/nearcore/pull/4938 --- chain/chain/src/chain.rs | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/chain/chain/src/chain.rs b/chain/chain/src/chain.rs index a65ca337e1e..9becca2e33d 100644 --- a/chain/chain/src/chain.rs +++ b/chain/chain/src/chain.rs @@ -38,6 +38,8 @@ use near_primitives::types::{ NumBlocks, NumShards, ShardId, StateChangesForSplitStates, StateRoot, }; use near_primitives::unwrap_or_return; +#[cfg(feature = "protocol_feature_block_header_v3")] +use near_primitives::version::ProtocolFeature; use near_primitives::views::{ ExecutionOutcomeWithIdView, ExecutionStatusView, FinalExecutionOutcomeView, FinalExecutionOutcomeWithReceiptView, FinalExecutionStatus, LightClientBlockView, @@ -385,20 +387,23 @@ impl Chain { last_known_hash: &CryptoHash, ) -> Result { let bps = runtime_adapter.get_epoch_block_producers_ordered(&epoch_id, last_known_hash)?; - let protocol_version = runtime_adapter.get_epoch_protocol_version(&epoch_id)?; - checked_feature!( - "protocol_feature_block_header_v3", - BlockHeaderV3, - protocol_version, - { - let validator_stakes = bps.into_iter().map(|(bp, _)| bp).collect(); - Chain::compute_collection_hash(validator_stakes) - }, - { + #[cfg(not(feature = "protocol_feature_block_header_v3"))] + { + let validator_stakes = bps.into_iter().map(|(bp, _)| bp).collect(); + Chain::compute_collection_hash(validator_stakes) + } + #[cfg(feature = "protocol_feature_block_header_v3")] + { + let protocol_version = runtime_adapter.get_epoch_protocol_version(&epoch_id)?; + let block_header_v3_version = ProtocolFeature::BlockHeaderV3.protocol_version(); + if protocol_version < block_header_v3_version { let validator_stakes = bps.into_iter().map(|(bp, _)| bp.into_v1()).collect(); Chain::compute_collection_hash(validator_stakes) + } else { + let validator_stakes = bps.into_iter().map(|(bp, _)| bp).collect(); + Chain::compute_collection_hash(validator_stakes) } - ) + } } /// Creates a light client block for the last final block from perspective of some other block