fix(hive): overflow when timestamp is u64::max (#14132)

This commit is contained in:
joshieDo
2025-01-31 20:53:48 +00:00
committed by GitHub
parent 3e0cd2eb3d
commit d30a1b6c7d
2 changed files with 8 additions and 7 deletions

View File

@ -111,7 +111,7 @@ pub trait LoadPendingBlock:
.next_evm_env( .next_evm_env(
&latest, &latest,
NextBlockEnvAttributes { NextBlockEnvAttributes {
timestamp: latest.timestamp() + 12, timestamp: latest.timestamp().saturating_add(12),
suggested_fee_recipient: latest.beneficiary(), suggested_fee_recipient: latest.beneficiary(),
prev_randao: B256::random(), prev_randao: B256::random(),
gas_limit: latest.gas_limit(), gas_limit: latest.gas_limit(),

View File

@ -116,11 +116,11 @@ pub async fn maintain_transaction_pool<N, Client, P, St, Tasks>(
last_seen_block_number: latest.number(), last_seen_block_number: latest.number(),
pending_basefee: latest pending_basefee: latest
.next_block_base_fee( .next_block_base_fee(
chain_spec.base_fee_params_at_timestamp(latest.timestamp() + 12), chain_spec.base_fee_params_at_timestamp(latest.timestamp().saturating_add(12)),
) )
.unwrap_or_default(), .unwrap_or_default(),
pending_blob_fee: latest.maybe_next_block_blob_fee( pending_blob_fee: latest.maybe_next_block_blob_fee(
chain_spec.blob_params_at_timestamp(latest.timestamp() + 12), chain_spec.blob_params_at_timestamp(latest.timestamp().saturating_add(12)),
), ),
}; };
pool.set_block_info(info); pool.set_block_info(info);
@ -276,11 +276,12 @@ pub async fn maintain_transaction_pool<N, Client, P, St, Tasks>(
let pending_block_base_fee = new_tip let pending_block_base_fee = new_tip
.header() .header()
.next_block_base_fee( .next_block_base_fee(
chain_spec.base_fee_params_at_timestamp(new_tip.timestamp() + 12), chain_spec
.base_fee_params_at_timestamp(new_tip.timestamp().saturating_add(12)),
) )
.unwrap_or_default(); .unwrap_or_default();
let pending_block_blob_fee = new_tip.header().maybe_next_block_blob_fee( let pending_block_blob_fee = new_tip.header().maybe_next_block_blob_fee(
chain_spec.blob_params_at_timestamp(new_tip.timestamp() + 12), chain_spec.blob_params_at_timestamp(new_tip.timestamp().saturating_add(12)),
); );
// we know all changed account in the new chain // we know all changed account in the new chain
@ -382,11 +383,11 @@ pub async fn maintain_transaction_pool<N, Client, P, St, Tasks>(
let pending_block_base_fee = tip let pending_block_base_fee = tip
.header() .header()
.next_block_base_fee( .next_block_base_fee(
chain_spec.base_fee_params_at_timestamp(tip.timestamp() + 12), chain_spec.base_fee_params_at_timestamp(tip.timestamp().saturating_add(12)),
) )
.unwrap_or_default(); .unwrap_or_default();
let pending_block_blob_fee = tip.header().maybe_next_block_blob_fee( let pending_block_blob_fee = tip.header().maybe_next_block_blob_fee(
chain_spec.blob_params_at_timestamp(tip.timestamp() + 12), chain_spec.blob_params_at_timestamp(tip.timestamp().saturating_add(12)),
); );
let first_block = blocks.first(); let first_block = blocks.first();