From 887cfadf51c3df9990301f39101fcb1fb7878b59 Mon Sep 17 00:00:00 2001 From: AvivYossef-starkware Date: Mon, 4 Nov 2024 14:48:46 +0200 Subject: [PATCH] chore(blockifier_reexecution): add test cases --- .../resources/block_numbers_for_reexecution.json | 9 +++++++++ .../src/state_reader/utils.rs | 13 +++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 crates/blockifier_reexecution/resources/block_numbers_for_reexecution.json diff --git a/crates/blockifier_reexecution/resources/block_numbers_for_reexecution.json b/crates/blockifier_reexecution/resources/block_numbers_for_reexecution.json new file mode 100644 index 0000000000..e1e5eb78a4 --- /dev/null +++ b/crates/blockifier_reexecution/resources/block_numbers_for_reexecution.json @@ -0,0 +1,9 @@ +{ + "0.13.0": 600001, + "0.13.1": 620978, + "0.13.1.1": 649367, + "0.13.2": 685878, + "0.13.2.1": 700000, + "example_invoke_with_replace_class_syscall": 780008, + "example_invoke_with_deploy_syscall": 870136 +} \ No newline at end of file diff --git a/crates/blockifier_reexecution/src/state_reader/utils.rs b/crates/blockifier_reexecution/src/state_reader/utils.rs index 3fada7b15b..f39e943208 100644 --- a/crates/blockifier_reexecution/src/state_reader/utils.rs +++ b/crates/blockifier_reexecution/src/state_reader/utils.rs @@ -6,8 +6,10 @@ use indexmap::IndexMap; use papyrus_execution::{ETH_FEE_CONTRACT_ADDRESS, STRK_FEE_CONTRACT_ADDRESS}; use pretty_assertions::assert_eq; use serde::{Deserialize, Serialize}; +use starknet_api::block::BlockNumber; use starknet_api::core::{ChainId, ClassHash, CompiledClassHash, ContractAddress, Nonce}; use starknet_api::state::StorageKey; +use starknet_api::test_utils::read_json_file; use starknet_gateway::config::RpcStateReaderConfig; use starknet_types_core::felt::Felt; @@ -178,3 +180,14 @@ macro_rules! assert_eq_state_diff { ); }; } + +/// Returns the block numbers for re-execution. +/// There is block number for each Starknet Version (starting v0.13) +/// And some additional block with specific transactions. +#[allow(dead_code)] +pub(crate) fn get_block_numbers_for_reexecution() -> Vec { + let block_numbers_examples: HashMap = + serde_json::from_value(read_json_file("block_numbers_for_reexecution.json")) + .expect("Failed to deserialize block header"); + block_numbers_examples.values().map(|block_number| BlockNumber(*block_number)).collect() +}