fix: do not calculate requests root pre-prague in dev mode (#8652)

Co-authored-by: Alexey Shekhirin <a.shekhirin@gmail.com>
This commit is contained in:
Dan Cline
2024-06-06 16:39:00 -04:00
committed by GitHub
parent e2cba9fd27
commit 87ba096e98
2 changed files with 12 additions and 10 deletions

View File

@ -260,14 +260,13 @@ impl StorageInner {
/// transactions. /// transactions.
pub(crate) fn build_header_template( pub(crate) fn build_header_template(
&self, &self,
timestamp: u64,
transactions: &[TransactionSigned], transactions: &[TransactionSigned],
ommers: &[Header], ommers: &[Header],
withdrawals: Option<&Withdrawals>, withdrawals: Option<&Withdrawals>,
requests: Option<&Requests>, requests: Option<&Requests>,
chain_spec: Arc<ChainSpec>, chain_spec: Arc<ChainSpec>,
) -> Header { ) -> Header {
let timestamp = SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default().as_secs();
// check previous block for base fee // check previous block for base fee
let base_fee_per_gas = self.headers.get(&self.best_block).and_then(|parent| { let base_fee_per_gas = self.headers.get(&self.best_block).and_then(|parent| {
parent.next_block_base_fee(chain_spec.base_fee_params_at_timestamp(timestamp)) parent.next_block_base_fee(chain_spec.base_fee_params_at_timestamp(timestamp))
@ -347,8 +346,6 @@ impl StorageInner {
&mut self, &mut self,
transactions: Vec<TransactionSigned>, transactions: Vec<TransactionSigned>,
ommers: Vec<Header>, ommers: Vec<Header>,
withdrawals: Option<Withdrawals>,
requests: Option<Requests>,
provider: &Provider, provider: &Provider,
chain_spec: Arc<ChainSpec>, chain_spec: Arc<ChainSpec>,
executor: &Executor, executor: &Executor,
@ -357,7 +354,17 @@ impl StorageInner {
Executor: BlockExecutorProvider, Executor: BlockExecutorProvider,
Provider: StateProviderFactory, Provider: StateProviderFactory,
{ {
let timestamp = SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default().as_secs();
// if shanghai is active, include empty withdrawals
let withdrawals =
chain_spec.is_shanghai_active_at_timestamp(timestamp).then_some(Withdrawals::default());
// if prague is active, include empty requests
let requests =
chain_spec.is_prague_active_at_timestamp(timestamp).then_some(Requests::default());
let header = self.build_header_template( let header = self.build_header_template(
timestamp,
&transactions, &transactions,
&ommers, &ommers,
withdrawals.as_ref(), withdrawals.as_ref(),

View File

@ -3,7 +3,7 @@ use futures_util::{future::BoxFuture, FutureExt};
use reth_beacon_consensus::{BeaconEngineMessage, ForkchoiceStatus}; use reth_beacon_consensus::{BeaconEngineMessage, ForkchoiceStatus};
use reth_engine_primitives::EngineTypes; use reth_engine_primitives::EngineTypes;
use reth_evm::execute::BlockExecutorProvider; use reth_evm::execute::BlockExecutorProvider;
use reth_primitives::{ChainSpec, IntoRecoveredTransaction, Requests, Withdrawals}; use reth_primitives::{ChainSpec, IntoRecoveredTransaction};
use reth_provider::{CanonChainTracker, StateProviderFactory}; use reth_provider::{CanonChainTracker, StateProviderFactory};
use reth_rpc_types::engine::ForkchoiceState; use reth_rpc_types::engine::ForkchoiceState;
use reth_stages_api::PipelineEvent; use reth_stages_api::PipelineEvent;
@ -129,15 +129,10 @@ where
}) })
.collect(); .collect();
let ommers = vec![]; let ommers = vec![];
// todo(onbjerg): these two dont respect chainspec
let withdrawals = Some(Withdrawals::default());
let requests = Some(Requests::default());
match storage.build_and_execute( match storage.build_and_execute(
transactions.clone(), transactions.clone(),
ommers.clone(), ommers.clone(),
withdrawals.clone(),
requests.clone(),
&client, &client,
chain_spec, chain_spec,
&executor, &executor,