Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: always take gas price from previous block #9638

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions chain/chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -4187,15 +4187,22 @@ impl Chain {
split_state_roots: Option<HashMap<ShardUId, CryptoHash>>,
) -> Result<Option<ApplyChunkJob>, 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<ApplyChunkResult, Error> {
let _span = tracing::debug_span!(
Expand Down
2 changes: 2 additions & 0 deletions core/primitives-core/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ pub enum ProtocolFeature {
/// Add `AccessKey` nonce range by setting nonce to `(block_height - 1) * 1e6`, see
/// <https://github.com/near/nearcore/issues/3779>.
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,
Expand Down