Skip to content

Commit

Permalink
query parent header state
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin committed Sep 4, 2024
1 parent 9018c21 commit fc92bb6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions crates/engine/invalid-block-hooks/src/witness.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down Expand Up @@ -40,15 +39,15 @@ where
{
fn on_invalid_block(
&self,
_parent_header: &SealedHeader,
parent_header: &SealedHeader,
block: &SealedBlockWithSenders,
_output: &BlockExecutionOutput<Receipt>,
_trie_updates: Option<(&TrieUpdates, B256)>,
) -> eyre::Result<()> {
// 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();
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion crates/storage/storage-api/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<StateProviderBox>;

/// 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<StateProviderBox>;
Expand Down

0 comments on commit fc92bb6

Please sign in to comment.