Skip to content

Commit

Permalink
chore(blockifier_reexecution): implement get_old_block_hash_and_numbe…
Browse files Browse the repository at this point in the history
…r for offline state reader
  • Loading branch information
aner-starkware committed Nov 7, 2024
1 parent bb41a7a commit f450411
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
9 changes: 9 additions & 0 deletions crates/blockifier_reexecution/src/main.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -146,6 +154,7 @@ fn main() {
transactions_next_block,
contract_class_mapping,
state_diff_next_block,
old_block_hash,
};

serializable_offline_reexecution_data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ pub struct OfflineReexecutionData {

#[derive(Serialize, Deserialize)]
pub struct SerializableOfflineReexecutionData {
state_maps: ReexecutionStateMaps,
contract_class_mapping: StarknetContractClassMapping,
block_info_next_block: BlockInfo,
starknet_version: StarknetVersion,
transactions_next_block: Vec<(Transaction, TransactionHash)>,
state_diff_next_block: CommitmentStateDiff,
old_block_hash: BlockHash,
pub state_maps: ReexecutionStateMaps,
pub block_info_next_block: BlockInfo,
pub starknet_version: StarknetVersion,
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 {
Expand Down

0 comments on commit f450411

Please sign in to comment.