Skip to content

Commit

Permalink
chore(blockifier_reexecution): use pre_process_and_create
Browse files Browse the repository at this point in the history
  • Loading branch information
aner-starkware committed Nov 6, 2024
1 parent f8eb0c3 commit 71da1a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 1 addition & 3 deletions crates/blockifier_reexecution/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -544,11 +544,17 @@ impl OfflineStateReader {
block_context_next_block: BlockContext,
transaction_executor_config: Option<TransactionExecutorConfig>,
) -> ReexecutionResult<TransactionExecutor<OfflineStateReader>> {
Ok(TransactionExecutor::<OfflineStateReader>::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::<OfflineStateReader>::pre_process_and_create(
self,
block_context_next_block,
Some(BlockHashAndNumber { number: old_block_number, hash }),
transaction_executor_config.unwrap_or_default(),
))
)?)
}
}

Expand Down

0 comments on commit 71da1a5

Please sign in to comment.