diff --git a/crates/blockifier_reexecution/src/main.rs b/crates/blockifier_reexecution/src/main.rs index bbc18809cc..8efd169f74 100644 --- a/crates/blockifier_reexecution/src/main.rs +++ b/crates/blockifier_reexecution/src/main.rs @@ -10,6 +10,7 @@ use blockifier_reexecution::state_reader::utils::{ }; use clap::{Args, Parser, Subcommand}; use starknet_api::block::BlockNumber; +use starknet_api::core::ChainId; use starknet_gateway::config::RpcStateReaderConfig; /// BlockifierReexecution CLI. @@ -105,6 +106,7 @@ fn main() { reexecute_and_verify_correctness(ConsecutiveTestStateReaders::new( BlockNumber(block_number - 1), Some(config), + ChainId::Mainnet, false, )); @@ -123,6 +125,7 @@ fn main() { BlockNumber(block_number), &full_file_path, node_url, + ChainId::Mainnet, ); } @@ -146,6 +149,7 @@ fn main() { block_number, &full_file_path, node_url.clone(), + ChainId::Mainnet, ); } } diff --git a/crates/blockifier_reexecution/src/state_reader/rpc_https_test.rs b/crates/blockifier_reexecution/src/state_reader/rpc_https_test.rs index b74a59d59e..f2a47f3496 100644 --- a/crates/blockifier_reexecution/src/state_reader/rpc_https_test.rs +++ b/crates/blockifier_reexecution/src/state_reader/rpc_https_test.rs @@ -17,6 +17,7 @@ use blockifier::blockifier::block::BlockInfo; use rstest::{fixture, rstest}; use starknet_api::block::BlockNumber; use starknet_api::class_hash; +use starknet_api::core::ChainId; use starknet_api::transaction::{ DeclareTransaction, DeployAccountTransaction, @@ -93,6 +94,7 @@ pub fn test_state_reader() -> TestStateReader { block_id: get_test_block_id(), }, retry_config: RetryConfig::default(), + chain_id: ChainId::Mainnet, contract_class_mapping_dumper: Arc::new(Mutex::new(None)), } } @@ -111,7 +113,7 @@ pub fn last_constructed_block(test_block_number: BlockNumber) -> BlockNumber { pub fn test_state_readers_last_and_current_block( last_constructed_block: BlockNumber, ) -> ConsecutiveTestStateReaders { - ConsecutiveTestStateReaders::new(last_constructed_block, None, false) + ConsecutiveTestStateReaders::new(last_constructed_block, None, ChainId::Mainnet, false) } /// Test that the block info can be retrieved from the RPC server. 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 d86a06d7d4..42c6c2c7a7 100644 --- a/crates/blockifier_reexecution/src/state_reader/test_state_reader.rs +++ b/crates/blockifier_reexecution/src/state_reader/test_state_reader.rs @@ -176,6 +176,7 @@ impl Default for RetryConfig { pub struct TestStateReader { pub(crate) rpc_state_reader: RpcStateReader, pub(crate) retry_config: RetryConfig, + pub(crate) chain_id: ChainId, #[allow(dead_code)] pub(crate) contract_class_mapping_dumper: Arc>>, } @@ -185,6 +186,7 @@ impl Default for TestStateReader { Self { rpc_state_reader: RpcStateReader::from_latest(&get_rpc_state_reader_config()), retry_config: RetryConfig::default(), + chain_id: ChainId::Mainnet, contract_class_mapping_dumper: Arc::new(Mutex::new(None)), } } @@ -236,20 +238,26 @@ impl StateReader for TestStateReader { } impl TestStateReader { - pub fn new(config: &RpcStateReaderConfig, block_number: BlockNumber, dump_mode: bool) -> Self { + pub fn new( + config: &RpcStateReaderConfig, + chain_id: ChainId, + block_number: BlockNumber, + dump_mode: bool, + ) -> Self { let contract_class_mapping_dumper = Arc::new(Mutex::new(match dump_mode { true => Some(HashMap::new()), false => None, })); Self { rpc_state_reader: RpcStateReader::from_number(config, block_number), - contract_class_mapping_dumper, retry_config: RetryConfig::default(), + chain_id, + contract_class_mapping_dumper, } } pub fn new_for_testing(block_number: BlockNumber) -> Self { - TestStateReader::new(&get_rpc_state_reader_config(), block_number, false) + TestStateReader::new(&get_rpc_state_reader_config(), ChainId::Mainnet, block_number, false) } /// Get the block info of the current block. @@ -334,7 +342,7 @@ impl TestStateReader { pub fn get_block_context(&self) -> ReexecutionResult { Ok(BlockContext::new( self.get_block_info()?, - get_chain_info(&ChainId::Mainnet), + get_chain_info(&self.chain_id), self.get_versioned_constants()?.clone(), BouncerConfig::max(), )) @@ -468,17 +476,20 @@ impl ConsecutiveTestStateReaders { pub fn new( last_constructed_block_number: BlockNumber, config: Option, + chain_id: ChainId, dump_mode: bool, ) -> Self { let config = config.unwrap_or(get_rpc_state_reader_config()); Self { last_block_state_reader: TestStateReader::new( &config, + chain_id.clone(), last_constructed_block_number, dump_mode, ), next_block_state_reader: TestStateReader::new( &config, + chain_id, last_constructed_block_number.next().expect("Overflow in block number"), dump_mode, ), diff --git a/crates/blockifier_reexecution/src/state_reader/utils.rs b/crates/blockifier_reexecution/src/state_reader/utils.rs index 25af8ba25c..5ff18e9d75 100644 --- a/crates/blockifier_reexecution/src/state_reader/utils.rs +++ b/crates/blockifier_reexecution/src/state_reader/utils.rs @@ -239,6 +239,7 @@ pub fn write_block_reexecution_data_to_file( block_number: BlockNumber, full_file_path: &str, node_url: String, + chain_id: ChainId, ) { let config = RpcStateReaderConfig { url: node_url, json_rpc_version: JSON_RPC_VERSION.to_string() }; @@ -246,6 +247,7 @@ pub fn write_block_reexecution_data_to_file( let consecutive_state_readers = ConsecutiveTestStateReaders::new( block_number.prev().expect("Should not run with block 0"), Some(config), + chain_id, true, );