diff --git a/chain/chain/src/chain.rs b/chain/chain/src/chain.rs index 8def5255c40..ea860e69c35 100644 --- a/chain/chain/src/chain.rs +++ b/chain/chain/src/chain.rs @@ -70,7 +70,7 @@ use near_primitives::types::{ }; use near_primitives::unwrap_or_return; use near_primitives::utils::MaybeValidated; -use near_primitives::version::PROTOCOL_VERSION; +use near_primitives::version::{ProtocolFeature, PROTOCOL_VERSION}; use near_primitives::views::{ BlockStatusView, DroppedReason, ExecutionOutcomeWithIdView, ExecutionStatusView, FinalExecutionOutcomeView, FinalExecutionOutcomeWithReceiptView, FinalExecutionStatus, @@ -4187,15 +4187,22 @@ impl Chain { split_state_roots: Option>, ) -> Result, Error> { let shard_id = shard_uid.shard_id(); - let new_extra = self.get_chunk_extra(prev_block.hash(), &shard_uid)?; + let prev_block_hash = *prev_block.hash(); + let new_extra = self.get_chunk_extra(&prev_block_hash, &shard_uid)?; let block_hash = *block.hash(); let challenges_result = block.header().challenges_result().clone(); let block_timestamp = block.header().raw_timestamp(); - let gas_price = block.header().gas_price(); + let epoch_id = self.epoch_manager.get_epoch_id_from_prev_block(&prev_block_hash)?; + let protocol_version = self.epoch_manager.get_epoch_protocol_version(&epoch_id)?; + + let gas_price = if protocol_version >= ProtocolFeature::FixApplyChunks.protocol_version() { + prev_block.header().gas_price() + } else { + block.header().gas_price() + }; let random_seed = *block.header().random_value(); let height = block.header().height(); - let prev_block_hash = *prev_block.hash(); Ok(Some(Box::new(move |parent_span| -> Result { let _span = tracing::debug_span!( diff --git a/core/primitives-core/src/version.rs b/core/primitives-core/src/version.rs index 41b19df4d57..3b4f89affc2 100644 --- a/core/primitives-core/src/version.rs +++ b/core/primitives-core/src/version.rs @@ -15,6 +15,8 @@ pub enum ProtocolFeature { /// Add `AccessKey` nonce range by setting nonce to `(block_height - 1) * 1e6`, see /// . AccessKeyNonceRange, + /// Don't process any receipts for shard when chunk is not present. + /// Always use gas price computed in the previous block. FixApplyChunks, LowerStorageCost, DeleteActionRestriction,