From fc92bb652eb954fd736b9e4884fc9f8384a38d6c Mon Sep 17 00:00:00 2001 From: Alexey Shekhirin Date: Wed, 4 Sep 2024 14:12:09 +0100 Subject: [PATCH] query parent header state --- crates/engine/invalid-block-hooks/src/witness.rs | 8 +++----- crates/storage/storage-api/src/state.rs | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/engine/invalid-block-hooks/src/witness.rs b/crates/engine/invalid-block-hooks/src/witness.rs index 858565b61a14..f3e02a736291 100644 --- a/crates/engine/invalid-block-hooks/src/witness.rs +++ b/crates/engine/invalid-block-hooks/src/witness.rs @@ -1,7 +1,6 @@ use std::{collections::HashMap, path::PathBuf}; use alloy_rpc_types_debug::ExecutionWitness; -use eyre::OptionExt; use reth_chainspec::ChainSpec; use reth_engine_primitives::InvalidBlockHook; use reth_evm::{ @@ -40,7 +39,7 @@ where { fn on_invalid_block( &self, - _parent_header: &SealedHeader, + parent_header: &SealedHeader, block: &SealedBlockWithSenders, _output: &BlockExecutionOutput, _trie_updates: Option<(&TrieUpdates, B256)>, @@ -48,7 +47,7 @@ where // Setup database. let mut db = StateBuilder::new() .with_database(StateProviderDatabase::new( - self.provider.state_by_block_hash(block.hash())?, + self.provider.state_by_block_hash(parent_header.hash())?, )) .with_bundle_update() .build(); @@ -85,8 +84,7 @@ where // Re-execute all of the transactions in the block to load all touched accounts into // the cache DB. - for tx in block.transactions() { - let tx = tx.clone().into_ecrecovered().ok_or_eyre("failed to recover sender")?; + for tx in block.clone().into_transactions_ecrecovered() { let env = EnvWithHandlerCfg { env: Env::boxed(cfg.cfg_env.clone(), block_env.clone(), evm_config.tx_env(&tx)), handler_cfg: cfg.handler_cfg, diff --git a/crates/storage/storage-api/src/state.rs b/crates/storage/storage-api/src/state.rs index adf0601eb9a2..25da9ef4d2f0 100644 --- a/crates/storage/storage-api/src/state.rs +++ b/crates/storage/storage-api/src/state.rs @@ -140,7 +140,7 @@ pub trait StateProviderFactory: BlockIdReader + Send + Sync { /// Note: this only looks at historical blocks, not pending blocks. fn history_by_block_hash(&self, block: BlockHash) -> ProviderResult; - /// Returns _any_[StateProvider] with matching block hash. + /// Returns _any_ [StateProvider] with matching block hash. /// /// This will return a [StateProvider] for either a historical or pending block. fn state_by_block_hash(&self, block: BlockHash) -> ProviderResult;