Skip to content

Commit

Permalink
feat(blockifier): use same versioned constant as snos (#2956)
Browse files Browse the repository at this point in the history
[`snos`](https://github.com/cartridge-gg/snos/tree/kariy/katana-compat-genesis-rebased-upstream) is using an older version of `blockifier` which only supports up to Starknet version `v0.13.3` while `katana`'s is up to `v0.13.4`. So, we pin the version on `katana` to match `snos` to make sure the execution outcome is similar.

The call to `VersionedConstants::latest_constants()` will basically use the latest version ie `v0.13.4`.
  • Loading branch information
kariy authored Jan 27, 2025
1 parent 75dce98 commit fb772c8
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion crates/katana/executor/src/implementation/blockifier/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use katana_cairo::cairo_vm::types::errors::program_errors::ProgramError;
use katana_cairo::cairo_vm::vm::runners::cairo_runner::{ExecutionResources, RunResources};
use katana_cairo::starknet_api::block::{
BlockInfo, BlockNumber, BlockTimestamp, FeeType, GasPriceVector, GasPrices, NonzeroGasPrice,
StarknetVersion,
};
use katana_cairo::starknet_api::contract_class::{ClassInfo, EntryPointType, SierraVersion};
use katana_cairo::starknet_api::core::{
Expand Down Expand Up @@ -442,7 +443,18 @@ pub fn block_context_from_envs(block_env: &BlockEnv, cfg_env: &CfgEnv) -> BlockC

let chain_info = ChainInfo { fee_token_addresses, chain_id: to_blk_chain_id(cfg_env.chain_id) };

let mut versioned_constants = VersionedConstants::latest_constants().clone();
// IMPORTANT:
//
// The versioned constants that we use here must match the version that is used in `snos`.
// Otherwise, there might be a mismatch between the calculated fees.
//
// The version of `snos` we're using is still limited up to Starknet version `0.13.3`.
const SN_VERSION: StarknetVersion = StarknetVersion::V0_13_3;
let mut versioned_constants = VersionedConstants::get(&SN_VERSION).unwrap().clone();

// NOTE:
// These overrides would potentially make the `snos` run be invalid as it doesn't know about the
// new overridden values.
versioned_constants.max_recursion_depth = cfg_env.max_recursion_depth;
versioned_constants.validate_max_n_steps = cfg_env.validate_max_n_steps;
versioned_constants.invoke_tx_max_n_steps = cfg_env.invoke_tx_max_n_steps;
Expand Down

0 comments on commit fb772c8

Please sign in to comment.