Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Commit

Permalink
Fix chain_id is now a storage_var, and class_hashes file
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementWalter committed Nov 12, 2024
1 parent 933f887 commit 5e89e3f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/test_utils/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ pub const KAKAROT_COINBASE: &str = "Kakarot_coinbase";
pub const KAKAROT_BASE_FEE: &str = "Kakarot_base_fee";
pub const KAKAROT_PREV_RANDAO: &str = "Kakarot_prev_randao";
pub const KAKAROT_BLOCK_GAS_LIMIT: &str = "Kakarot_block_gas_limit";
pub const KAKAROT_CHAIN_ID: &str = "Kakarot_chain_id";
12 changes: 10 additions & 2 deletions src/test_utils/katana/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::{
test_utils::constants::{
ACCOUNT_AUTHORIZED_MESSAGE_HASHES, ACCOUNT_CAIRO1_HELPERS_CLASS_HASH, ACCOUNT_EVM_ADDRESS,
ACCOUNT_IMPLEMENTATION, EIP_155_AUTHORIZED_MESSAGE_HASHES, KAKAROT_ACCOUNT_CONTRACT_CLASS_HASH,
KAKAROT_BASE_FEE, KAKAROT_BLOCK_GAS_LIMIT, KAKAROT_CAIRO1_HELPERS_CLASS_HASH, KAKAROT_COINBASE,
KAKAROT_EVM_TO_STARKNET_ADDRESS, KAKAROT_NATIVE_TOKEN_ADDRESS, KAKAROT_PREV_RANDAO,
KAKAROT_BASE_FEE, KAKAROT_BLOCK_GAS_LIMIT, KAKAROT_CAIRO1_HELPERS_CLASS_HASH, KAKAROT_CHAIN_ID,
KAKAROT_COINBASE, KAKAROT_EVM_TO_STARKNET_ADDRESS, KAKAROT_NATIVE_TOKEN_ADDRESS, KAKAROT_PREV_RANDAO,
KAKAROT_UNINITIALIZED_ACCOUNT_CLASS_HASH, OWNABLE_OWNER,
},
};
Expand Down Expand Up @@ -152,6 +152,11 @@ impl KatanaGenesisBuilder<Uninitialized> {
.par_bridge()
.filter_map(|entry| {
let path = entry.unwrap().path().to_path_buf();
// Skip class_hashes.json file
if path.file_name().map_or(false, |name| name == "class_hashes.json") {
return None;
}

let artifact = fs::read_to_string(&path).expect("Failed to read artifact");
let artifact = serde_json::from_str(&artifact).expect("Failed to parse artifact");
let class_hash = compute_class_hash(&artifact)
Expand Down Expand Up @@ -193,6 +198,8 @@ impl KatanaGenesisBuilder<Loaded> {
let uninitialized_account_class_hash = self.uninitialized_account_class_hash()?;
let cairo1_helpers_class_hash = self.cairo1_helpers_class_hash()?;
let block_gas_limit = 20_000_000u64.into();
let chain_id = Felt::from(0xb615f74ebad2c_u64);

// Construct the kakarot contract address. Based on the constructor args from
// https://github.com/kkrt-labs/kakarot/blob/main/src/kakarot/kakarot.cairo#L23
let kakarot_address = ContractAddress::new(get_udc_deployed_address(
Expand Down Expand Up @@ -223,6 +230,7 @@ impl KatanaGenesisBuilder<Loaded> {
(storage_addr(KAKAROT_BASE_FEE)?, Felt::ZERO),
(storage_addr(KAKAROT_PREV_RANDAO)?, Felt::ZERO),
(storage_addr(KAKAROT_BLOCK_GAS_LIMIT)?, block_gas_limit),
(storage_addr(KAKAROT_CHAIN_ID)?, chain_id),
]
.into_iter()
.collect();
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/eth_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async fn test_chain_id(#[future] katana: Katana, _setup: ()) {
let chain_id = eth_provider.chain_id().await.unwrap().unwrap_or_default();

// Then
// Chain ID should correspond to "kaka_test"
// Chain ID should correspond to "kaka_test" % max safe chain id
assert_eq!(chain_id, U64::from_str_radix("b615f74ebad2c", 16).unwrap());
}

Expand Down

0 comments on commit 5e89e3f

Please sign in to comment.