diff --git a/crates/blockifier_reexecution/src/main.rs b/crates/blockifier_reexecution/src/main.rs index 7cecf38ac7..53c2b932b3 100644 --- a/crates/blockifier_reexecution/src/main.rs +++ b/crates/blockifier_reexecution/src/main.rs @@ -1,3 +1,4 @@ +use blockifier::abi::constants; use blockifier_reexecution::assert_eq_state_diff; use blockifier_reexecution::state_reader::reexecution_state_reader::ReexecutionStateReader; use blockifier_reexecution::state_reader::test_state_reader::{ @@ -114,6 +115,13 @@ fn main() { let block_info_next_block = next_block_state_reader.get_block_info().unwrap(); + let old_block_number = BlockNumber( + block_info_next_block.block_number.0 - constants::STORED_BLOCK_HASH_BUFFER, + ); + + let old_block_hash = + last_block_state_reader.get_old_block_hash(old_block_number).unwrap(); + let starknet_version = next_block_state_reader.get_starknet_version().unwrap(); let state_diff_next_block = next_block_state_reader.get_state_diff().unwrap(); @@ -146,6 +154,7 @@ fn main() { transactions_next_block, contract_class_mapping, state_diff_next_block, + old_block_hash, }; serializable_offline_reexecution_data 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 18cd882ff1..06e1bb5a4e 100644 --- a/crates/blockifier_reexecution/src/state_reader/test_state_reader.rs +++ b/crates/blockifier_reexecution/src/state_reader/test_state_reader.rs @@ -72,6 +72,7 @@ pub struct SerializableOfflineReexecutionData { pub transactions_next_block: Vec<(Transaction, TransactionHash)>, pub state_diff_next_block: CommitmentStateDiff, pub contract_class_mapping: StarknetContractClassMapping, + pub old_block_hash: BlockHash, } impl SerializableOfflineReexecutionData { @@ -97,6 +98,7 @@ impl From for OfflineReexecutionData { let offline_state_reader_prev_block = OfflineStateReader { state_maps: value.state_maps.try_into().expect("Failed to deserialize state maps."), contract_class_mapping: value.contract_class_mapping, + old_block_hash: value.old_block_hash, }; let transactions_next_block = offline_state_reader_prev_block .api_txs_to_blockifier_txs_next_block(value.transactions_next_block) @@ -466,6 +468,7 @@ impl ConsecutiveStateReaders for ConsecutiveTestStateReaders { pub struct OfflineStateReader { pub state_maps: StateMaps, pub contract_class_mapping: StarknetContractClassMapping, + pub old_block_hash: BlockHash, } impl StateReader for OfflineStateReader { @@ -531,7 +534,7 @@ impl ReexecutionStateReader for OfflineStateReader { } fn get_old_block_hash(&self, _old_block_number: BlockNumber) -> ReexecutionResult { - todo!() + Ok(self.old_block_hash) } }