Skip to content

Commit

Permalink
Revert "fix: correct feature handling"
Browse files Browse the repository at this point in the history
This reverts commit 3f8923e.

We don't know if that change is actually correct or not, see

    near#4938
  • Loading branch information
matklad committed Oct 7, 2021
1 parent 2c9375e commit cd9ca90
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions chain/chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -385,20 +387,23 @@ impl Chain {
last_known_hash: &CryptoHash,
) -> Result<CryptoHash, Error> {
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
Expand Down

0 comments on commit cd9ca90

Please sign in to comment.