From ca0bf911878ac41fe458f3b1bdc546ff7fb32bec 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 | 15 +++++++++++++++ .../src/state_reader/utils.rs | 13 +++++++++++++ 2 files changed, 28 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..77bc6a46dd --- /dev/null +++ b/crates/blockifier_reexecution/resources/block_numbers_for_reexecution.json @@ -0,0 +1,15 @@ +{ + "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, + "example_deploy_account_v1": 837408, + "example_deploy_account_v3": 837792, + "example_declare_v1": 837461, + "example_declare_v2": 822636, + "example_declare_v3": 825013, + "example_l1_handler": 868429 +} \ 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 1fd5b3f16c..68cc27b45c 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; @@ -179,3 +181,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() +}