From 71da1a59851078445e3047a0d452130876774a1e Mon Sep 17 00:00:00 2001 From: Aner Ben Efraim Date: Wed, 6 Nov 2024 18:39:18 +0200 Subject: [PATCH] chore(blockifier_reexecution): use pre_process_and_create --- crates/blockifier_reexecution/src/main.rs | 4 +--- .../src/state_reader/test_state_reader.rs | 14 ++++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/crates/blockifier_reexecution/src/main.rs b/crates/blockifier_reexecution/src/main.rs index 5f43e5c777..0110ed8975 100644 --- a/crates/blockifier_reexecution/src/main.rs +++ b/crates/blockifier_reexecution/src/main.rs @@ -190,7 +190,7 @@ fn main() { let reexecution_state_readers = OfflineConsecutiveStateReaders::new(serializable_offline_reexecution_data.into()); - let mut expected_state_diff = + let expected_state_diff = reexecution_state_readers.get_next_block_state_diff().unwrap(); let all_txs_in_next_block = reexecution_state_readers.get_next_block_txs().unwrap(); @@ -203,8 +203,6 @@ fn main() { let (actual_state_diff, _, _) = transaction_executor.finalize().expect("Couldn't finalize block"); - // TODO(Aner): compute correct block hash at storage slot 0x1 instead of removing it. - expected_state_diff.storage_updates.shift_remove(&ContractAddress(1_u128.into())); assert_eq!(expected_state_diff, actual_state_diff); println!("Reexecution test for block {block_number} passed successfully."); diff --git a/crates/blockifier_reexecution/src/state_reader/test_state_reader.rs b/crates/blockifier_reexecution/src/state_reader/test_state_reader.rs index 06e1bb5a4e..6c7448ca8e 100644 --- a/crates/blockifier_reexecution/src/state_reader/test_state_reader.rs +++ b/crates/blockifier_reexecution/src/state_reader/test_state_reader.rs @@ -9,7 +9,7 @@ use blockifier::blockifier::transaction_executor::TransactionExecutor; use blockifier::bouncer::BouncerConfig; use blockifier::context::BlockContext; use blockifier::execution::contract_class::RunnableContractClass; -use blockifier::state::cached_state::{CachedState, CommitmentStateDiff, StateMaps}; +use blockifier::state::cached_state::{CommitmentStateDiff, StateMaps}; use blockifier::state::errors::StateError; use blockifier::state::state_api::{StateReader, StateResult}; use blockifier::transaction::transaction_execution::Transaction as BlockifierTransaction; @@ -544,11 +544,17 @@ impl OfflineStateReader { block_context_next_block: BlockContext, transaction_executor_config: Option, ) -> ReexecutionResult> { - Ok(TransactionExecutor::::new( - CachedState::new(self), + let old_block_number = BlockNumber( + block_context_next_block.block_info().block_number.0 + - constants::STORED_BLOCK_HASH_BUFFER, + ); + let hash = self.old_block_hash; + Ok(TransactionExecutor::::pre_process_and_create( + self, block_context_next_block, + Some(BlockHashAndNumber { number: old_block_number, hash }), transaction_executor_config.unwrap_or_default(), - )) + )?) } }