Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(blockifier_reexecution): inject chain ID to chain info creation #1970

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use blockifier::versioned_constants::VersionedConstants;
use serde::{Deserialize, Serialize};
use serde_json::{json, to_value};
use starknet_api::block::{BlockHash, BlockHashAndNumber, BlockNumber, StarknetVersion};
use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce};
use starknet_api::core::{ChainId, ClassHash, CompiledClassHash, ContractAddress, Nonce};
use starknet_api::state::StorageKey;
use starknet_api::transaction::{Transaction, TransactionHash};
use starknet_core::types::ContractClass as StarknetContractClass;
Expand Down Expand Up @@ -131,7 +131,7 @@ impl From<SerializableOfflineReexecutionData> for OfflineReexecutionData {
offline_state_reader_prev_block,
block_context_next_block: BlockContext::new(
block_info_next_block,
get_chain_info(),
get_chain_info(&ChainId::Mainnet),
VersionedConstants::get(&starknet_version).unwrap().clone(),
BouncerConfig::max(),
),
Expand Down Expand Up @@ -327,7 +327,7 @@ impl TestStateReader {
pub fn get_block_context(&self) -> ReexecutionResult<BlockContext> {
Ok(BlockContext::new(
self.get_block_info()?,
get_chain_info(),
get_chain_info(&ChainId::Mainnet),
self.get_versioned_constants()?.clone(),
BouncerConfig::max(),
))
Expand Down
16 changes: 10 additions & 6 deletions crates/blockifier_reexecution/src/state_reader/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ pub const RPC_NODE_URL: &str = "https://free-rpc.nethermind.io/mainnet-juno/";
pub const JSON_RPC_VERSION: &str = "2.0";

/// Returns the fee token addresses of mainnet.
pub fn get_fee_token_addresses() -> FeeTokenAddresses {
FeeTokenAddresses {
strk_fee_token_address: *STRK_FEE_CONTRACT_ADDRESS,
eth_fee_token_address: *ETH_FEE_CONTRACT_ADDRESS,
pub fn get_fee_token_addresses(chain_id: &ChainId) -> FeeTokenAddresses {
match chain_id {
// Mainnet, testnet and integration systems have the same fee token addresses.
ChainId::Mainnet | ChainId::Sepolia | ChainId::IntegrationSepolia => FeeTokenAddresses {
strk_fee_token_address: *STRK_FEE_CONTRACT_ADDRESS,
eth_fee_token_address: *ETH_FEE_CONTRACT_ADDRESS,
},
unknown_chain => unimplemented!("Unknown chain ID {unknown_chain}."),
}
}

Expand All @@ -41,8 +45,8 @@ pub fn get_rpc_state_reader_config() -> RpcStateReaderConfig {
}

/// Returns the chain info of mainnet.
pub fn get_chain_info() -> ChainInfo {
ChainInfo { chain_id: ChainId::Mainnet, fee_token_addresses: get_fee_token_addresses() }
pub fn get_chain_info(chain_id: &ChainId) -> ChainInfo {
ChainInfo { chain_id: chain_id.clone(), fee_token_addresses: get_fee_token_addresses(chain_id) }
}

// TODO(Aner): import the following functions instead, to reduce code duplication.
Expand Down
Loading