Skip to content

Commit

Permalink
hotfix(katana): include missing udc class if custom genesis is specif…
Browse files Browse the repository at this point in the history
…ied (#2575)
  • Loading branch information
kariy authored Oct 24, 2024
1 parent 4930450 commit 15114c5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
29 changes: 23 additions & 6 deletions crates/katana/primitives/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ use crate::da::L1DataAvailabilityMode;
use crate::genesis::allocation::{DevAllocationsGenerator, GenesisAllocation};
use crate::genesis::constant::{
get_fee_token_balance_base_storage_address, DEFAULT_ACCOUNT_CLASS_PUBKEY_STORAGE_SLOT,
DEFAULT_ETH_FEE_TOKEN_ADDRESS, DEFAULT_LEGACY_ERC20_CLASS_HASH, DEFAULT_LEGACY_UDC_CLASS_HASH,
DEFAULT_ETH_FEE_TOKEN_ADDRESS, DEFAULT_LEGACY_ERC20_CLASS_HASH, DEFAULT_LEGACY_UDC_CASM,
DEFAULT_LEGACY_UDC_CLASS_HASH, DEFAULT_LEGACY_UDC_COMPILED_CLASS_HASH,
DEFAULT_PREFUNDED_ACCOUNT_BALANCE, DEFAULT_STRK_FEE_TOKEN_ADDRESS, DEFAULT_UDC_ADDRESS,
ERC20_DECIMAL_STORAGE_SLOT, ERC20_NAME_STORAGE_SLOT, ERC20_SYMBOL_STORAGE_SLOT,
ERC20_TOTAL_SUPPLY_STORAGE_SLOT,
Expand Down Expand Up @@ -130,11 +131,7 @@ impl ChainSpec {
);

// -- UDC

states
.state_updates
.deployed_contracts
.insert(DEFAULT_UDC_ADDRESS, DEFAULT_LEGACY_UDC_CLASS_HASH);
add_default_udc(&mut states);

states
}
Expand Down Expand Up @@ -219,6 +216,26 @@ fn add_fee_token(
states.state_updates.storage_updates.insert(address, storage);
}

fn add_default_udc(states: &mut StateUpdatesWithDeclaredClasses) {
// declare UDC class
states
.declared_compiled_classes
.entry(DEFAULT_LEGACY_UDC_CLASS_HASH)
.or_insert_with(|| DEFAULT_LEGACY_UDC_CASM.clone());
states
.state_updates
.declared_classes
.entry(DEFAULT_LEGACY_UDC_CLASS_HASH)
.or_insert(DEFAULT_LEGACY_UDC_COMPILED_CLASS_HASH);

// deploy UDC contract
states
.state_updates
.deployed_contracts
.entry(DEFAULT_UDC_ADDRESS)
.or_insert(DEFAULT_LEGACY_UDC_CLASS_HASH);
}

#[cfg(test)]
mod tests {

Expand Down
2 changes: 0 additions & 2 deletions crates/katana/primitives/src/genesis/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ pub struct GenesisJson {
pub gas_prices: GasPrices,
#[serde(default)]
pub classes: Vec<GenesisClassJson>,
// pub fee_token: FeeTokenConfigJson,
// pub universal_deployer: Option<UniversalDeployerConfigJson>,
#[serde(default)]
pub accounts: BTreeMap<ContractAddress, GenesisAccountJson>,
#[serde(default)]
Expand Down

0 comments on commit 15114c5

Please sign in to comment.