From 7336895538ec14fd74348957aa26d04cec2112b3 Mon Sep 17 00:00:00 2001 From: Edgar Luque Date: Thu, 21 Nov 2024 16:14:20 +0100 Subject: [PATCH 1/6] initial gas cost 10k --- src/executor.rs | 6 +++- src/executor/contract.rs | 63 ++++++++++++++-------------------- tests/common.rs | 11 ++++-- tests/tests/starknet/keccak.rs | 3 +- 4 files changed, 42 insertions(+), 41 deletions(-) diff --git a/src/executor.rs b/src/executor.rs index dad147b76..9d8733af8 100644 --- a/src/executor.rs +++ b/src/executor.rs @@ -3,7 +3,11 @@ //! This module provides methods to execute the programs, either via JIT or compiled ahead //! of time. It also provides a cache to avoid recompiling previously compiled programs. -pub use self::{aot::AotNativeExecutor, contract::AotContractExecutor, jit::JitNativeExecutor}; +pub use self::{ + aot::AotNativeExecutor, + contract::{AotContractExecutor, INITIAL_GAS_COST}, + jit::JitNativeExecutor, +}; use crate::{ arch::{AbiArgument, ValueWithInfoWrapper}, error::{panic::ToNativeAssertError, Error}, diff --git a/src/executor/contract.rs b/src/executor/contract.rs index 848c9ea98..e8bdaefdd 100644 --- a/src/executor/contract.rs +++ b/src/executor/contract.rs @@ -37,7 +37,6 @@ use crate::{ error::{panic::ToNativeAssertError, Error}, execution_result::{BuiltinStats, ContractExecutionResult}, executor::invoke_trampoline, - metadata::gas::GasMetadata, module::NativeModule, native_panic, starknet::{handler::StarknetSyscallHandlerCallbacks, StarknetSyscallHandler}, @@ -98,7 +97,6 @@ pub enum ContractInfoVersion { #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] pub struct EntryPointInfo { pub builtins: Vec, - pub initial_cost: BTreeMap, // cost token type offset, cost } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] @@ -136,6 +134,9 @@ impl BuiltinType { } } +/// The default initial gas cost for all entry points. +pub const INITIAL_GAS_COST: u64 = 10_000; + impl AotContractExecutor { /// Create the executor from a sierra program with the given optimization level. /// You can save the library on the desired location later using `save`. @@ -153,14 +154,9 @@ impl AotContractExecutor { let NativeModule { module, registry, - metadata, + metadata: _, } = module; - let initial_gas_costs = { - let gas_meta: &GasMetadata = metadata.get().ok_or(Error::MissingMetadata)?; - gas_meta.initial_required_gas_for_entry_points()? - }; - let mut infos = BTreeMap::new(); let mut entry_point_selector_to_id = BTreeMap::new(); @@ -225,13 +221,7 @@ impl AotContractExecutor { } } - infos.insert( - x.id.id, - EntryPointInfo { - builtins, - initial_cost: initial_gas_costs.get(&x.id.id).cloned().unwrap_or_default(), - }, - ); + infos.insert(x.id.id, EntryPointInfo { builtins }); } let library_path = NamedTempFile::new()? @@ -281,12 +271,20 @@ impl AotContractExecutor { }) } - /// Runs the given entry point. + /// Runs the entry point by the given selector. + /// + /// - selector: The selector of the entry point to run. + /// - args: The calldata. + /// - gas: The gas for the execution. + /// - initial_gas_cost: is the gas cost for the called entry point, usually 10k ( `INITIAL_GAS_COST` ). + /// - builtin_costs: An optional argument to customize the costs of the builtins. + /// - syscall_handler: The syscall handler implementation to use when executing the contract. pub fn run( &self, selector: Felt, args: &[Felt], gas: Option, + initial_gas_cost: u64, builtin_costs: Option, mut syscall_handler: impl StarknetSyscallHandler, ) -> Result { @@ -318,25 +316,12 @@ impl AotContractExecutor { // We may be inside a recursive contract, save the possible saved builtin costs to restore it after our call. let old_builtincosts_ptr = set_costs_builtin(builtin_costs.cast()); - let initial_gas_cost = { - let mut cost = 0; - - for (offset, val) in self - .contract_info - .entry_points_info - .get(&function_id.id) - .to_native_assert_error("entry point info for function should be available")? - .initial_cost - .iter() - { - let token_cost = builtin_costs_stack[*offset as usize] * val; - cost += token_cost; - } - cost - }; - let gas = gas - .unwrap_or(initial_gas_cost) - .saturating_sub(initial_gas_cost); + let gas = gas.unwrap_or(initial_gas_cost); + let gas = gas.checked_sub(initial_gas_cost).ok_or_else(|| { + Error::GasMetadataError(crate::metadata::gas::GasMetadataError::NotEnoughGas { + gas: Box::new((gas, initial_gas_cost)), + }) + })?; // it can vary from contract to contract thats why we need to store/ load it. let builtins_size: usize = self.contract_info.entry_points_info[&function_id.id] @@ -721,13 +706,14 @@ mod tests { Felt::from(&selector), &[n.into()], Some(u64::MAX), + INITIAL_GAS_COST, None, &mut StubSyscallHandler::default(), ) .unwrap(); assert_eq!(result.return_values, vec![Felt::from(n), Felt::from(n * 2)]); - assert_eq!(result.remaining_gas, 18446744073709548475); + assert_eq!(result.remaining_gas, 18446744073709539845); }); } @@ -756,6 +742,7 @@ mod tests { Felt::from(&selector), &[2.into()], Some(u64::MAX), + INITIAL_GAS_COST, None, &mut StubSyscallHandler::default(), ) @@ -791,13 +778,14 @@ mod tests { Felt::from(&selector), &[10.into()], Some(u64::MAX), + INITIAL_GAS_COST, None, &mut StubSyscallHandler::default(), ) .unwrap(); assert_eq!(result.return_values, vec![Felt::from(3628800)]); - assert_eq!(result.remaining_gas, 18446744073709534105); + assert_eq!(result.remaining_gas, 18446744073709525475); } #[rstest] @@ -829,6 +817,7 @@ mod tests { Felt::from(&selector), &[], Some(u64::MAX), + INITIAL_GAS_COST, None, &mut StubSyscallHandler::default(), ) diff --git a/tests/common.rs b/tests/common.rs index 39ade8c19..052aae945 100644 --- a/tests/common.rs +++ b/tests/common.rs @@ -34,7 +34,7 @@ use cairo_lang_utils::Upcast; use cairo_native::{ context::NativeContext, execution_result::{ContractExecutionResult, ExecutionResult}, - executor::{AotContractExecutor, AotNativeExecutor, JitNativeExecutor}, + executor::{AotContractExecutor, AotNativeExecutor, JitNativeExecutor, INITIAL_GAS_COST}, starknet::{DummySyscallHandler, StarknetSyscallHandler}, utils::{find_entry_point_by_idx, HALF_PRIME, PRIME}, OptLevel, Value, @@ -452,7 +452,14 @@ pub fn run_native_starknet_aot_contract( ) .unwrap(); native_executor - .run(Felt::from(selector), args, u64::MAX.into(), None, handler) + .run( + Felt::from(selector), + args, + u64::MAX.into(), + INITIAL_GAS_COST, + None, + handler, + ) .expect("failed to execute the given contract") } diff --git a/tests/tests/starknet/keccak.rs b/tests/tests/starknet/keccak.rs index 71babc3c7..9dbdf731c 100644 --- a/tests/tests/starknet/keccak.rs +++ b/tests/tests/starknet/keccak.rs @@ -47,6 +47,7 @@ fn keccak_test() { ); assert!(!result_aot_ct.failure_flag); - assert_eq!(result_aot_ct.remaining_gas, result.remaining_gas); + // Can't compare the gas because the AotContractExecutor has a fixed initial_gas_cost of 10_000 (as per the sequencer requirements) + // assert_eq!(result_aot_ct.remaining_gas, result.remaining_gas); assert_eq!(result_aot_ct.return_values, vec![1.into()]); } From 488a60644e92e9a9ff578234ff5a28b542c7fd3a Mon Sep 17 00:00:00 2001 From: Edgar Luque Date: Thu, 21 Nov 2024 16:22:23 +0100 Subject: [PATCH 2/6] remove --- src/executor/contract.rs | 29 +++++++++-------------------- tests/common.rs | 3 +-- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/src/executor/contract.rs b/src/executor/contract.rs index e8bdaefdd..e5c6e14a2 100644 --- a/src/executor/contract.rs +++ b/src/executor/contract.rs @@ -276,15 +276,15 @@ impl AotContractExecutor { /// - selector: The selector of the entry point to run. /// - args: The calldata. /// - gas: The gas for the execution. - /// - initial_gas_cost: is the gas cost for the called entry point, usually 10k ( `INITIAL_GAS_COST` ). /// - builtin_costs: An optional argument to customize the costs of the builtins. /// - syscall_handler: The syscall handler implementation to use when executing the contract. + /// + /// This method doesn't do any gas accounting, meaning it wont substract the initial gas cost of the entry point from the given gas. pub fn run( &self, selector: Felt, args: &[Felt], - gas: Option, - initial_gas_cost: u64, + gas: u64, builtin_costs: Option, mut syscall_handler: impl StarknetSyscallHandler, ) -> Result { @@ -316,13 +316,6 @@ impl AotContractExecutor { // We may be inside a recursive contract, save the possible saved builtin costs to restore it after our call. let old_builtincosts_ptr = set_costs_builtin(builtin_costs.cast()); - let gas = gas.unwrap_or(initial_gas_cost); - let gas = gas.checked_sub(initial_gas_cost).ok_or_else(|| { - Error::GasMetadataError(crate::metadata::gas::GasMetadataError::NotEnoughGas { - gas: Box::new((gas, initial_gas_cost)), - }) - })?; - // it can vary from contract to contract thats why we need to store/ load it. let builtins_size: usize = self.contract_info.entry_points_info[&function_id.id] .builtins @@ -705,15 +698,14 @@ mod tests { .run( Felt::from(&selector), &[n.into()], - Some(u64::MAX), - INITIAL_GAS_COST, + u64::MAX, None, &mut StubSyscallHandler::default(), ) .unwrap(); assert_eq!(result.return_values, vec![Felt::from(n), Felt::from(n * 2)]); - assert_eq!(result.remaining_gas, 18446744073709539845); + assert_eq!(result.remaining_gas, 18446744073709549845); }); } @@ -741,8 +733,7 @@ mod tests { .run( Felt::from(&selector), &[2.into()], - Some(u64::MAX), - INITIAL_GAS_COST, + u64::MAX, None, &mut StubSyscallHandler::default(), ) @@ -777,15 +768,14 @@ mod tests { .run( Felt::from(&selector), &[10.into()], - Some(u64::MAX), - INITIAL_GAS_COST, + u64::MAX, None, &mut StubSyscallHandler::default(), ) .unwrap(); assert_eq!(result.return_values, vec![Felt::from(3628800)]); - assert_eq!(result.remaining_gas, 18446744073709525475); + assert_eq!(result.remaining_gas, 18446744073709535475); } #[rstest] @@ -816,8 +806,7 @@ mod tests { .run( Felt::from(&selector), &[], - Some(u64::MAX), - INITIAL_GAS_COST, + u64::MAX, None, &mut StubSyscallHandler::default(), ) diff --git a/tests/common.rs b/tests/common.rs index 052aae945..063eaf39d 100644 --- a/tests/common.rs +++ b/tests/common.rs @@ -455,8 +455,7 @@ pub fn run_native_starknet_aot_contract( .run( Felt::from(selector), args, - u64::MAX.into(), - INITIAL_GAS_COST, + u64::MAX, None, handler, ) From 466965158f217e6de2906782eb35f5a3e589d7d9 Mon Sep 17 00:00:00 2001 From: Edgar Luque Date: Thu, 21 Nov 2024 16:23:50 +0100 Subject: [PATCH 3/6] remove unused --- src/executor.rs | 6 +----- src/executor/contract.rs | 3 --- tests/common.rs | 10 ++-------- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/executor.rs b/src/executor.rs index 9d8733af8..dad147b76 100644 --- a/src/executor.rs +++ b/src/executor.rs @@ -3,11 +3,7 @@ //! This module provides methods to execute the programs, either via JIT or compiled ahead //! of time. It also provides a cache to avoid recompiling previously compiled programs. -pub use self::{ - aot::AotNativeExecutor, - contract::{AotContractExecutor, INITIAL_GAS_COST}, - jit::JitNativeExecutor, -}; +pub use self::{aot::AotNativeExecutor, contract::AotContractExecutor, jit::JitNativeExecutor}; use crate::{ arch::{AbiArgument, ValueWithInfoWrapper}, error::{panic::ToNativeAssertError, Error}, diff --git a/src/executor/contract.rs b/src/executor/contract.rs index e5c6e14a2..a86223311 100644 --- a/src/executor/contract.rs +++ b/src/executor/contract.rs @@ -134,9 +134,6 @@ impl BuiltinType { } } -/// The default initial gas cost for all entry points. -pub const INITIAL_GAS_COST: u64 = 10_000; - impl AotContractExecutor { /// Create the executor from a sierra program with the given optimization level. /// You can save the library on the desired location later using `save`. diff --git a/tests/common.rs b/tests/common.rs index 063eaf39d..e16633fce 100644 --- a/tests/common.rs +++ b/tests/common.rs @@ -34,7 +34,7 @@ use cairo_lang_utils::Upcast; use cairo_native::{ context::NativeContext, execution_result::{ContractExecutionResult, ExecutionResult}, - executor::{AotContractExecutor, AotNativeExecutor, JitNativeExecutor, INITIAL_GAS_COST}, + executor::{AotContractExecutor, AotNativeExecutor, JitNativeExecutor}, starknet::{DummySyscallHandler, StarknetSyscallHandler}, utils::{find_entry_point_by_idx, HALF_PRIME, PRIME}, OptLevel, Value, @@ -452,13 +452,7 @@ pub fn run_native_starknet_aot_contract( ) .unwrap(); native_executor - .run( - Felt::from(selector), - args, - u64::MAX, - None, - handler, - ) + .run(Felt::from(selector), args, u64::MAX, None, handler) .expect("failed to execute the given contract") } From 9399fca089cc8fce76d04340121072de43e21201 Mon Sep 17 00:00:00 2001 From: Edgar Luque Date: Mon, 25 Nov 2024 10:41:14 +0100 Subject: [PATCH 4/6] improve doc --- src/executor/contract.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/executor/contract.rs b/src/executor/contract.rs index a86223311..d6268e0cb 100644 --- a/src/executor/contract.rs +++ b/src/executor/contract.rs @@ -276,7 +276,7 @@ impl AotContractExecutor { /// - builtin_costs: An optional argument to customize the costs of the builtins. /// - syscall_handler: The syscall handler implementation to use when executing the contract. /// - /// This method doesn't do any gas accounting, meaning it wont substract the initial gas cost of the entry point from the given gas. + /// The entry point gas cost is not deducted from the gas counter. pub fn run( &self, selector: Felt, From ff8fa891fa0aa5c755030847cde4632937be7e17 Mon Sep 17 00:00:00 2001 From: Edgar Luque Date: Mon, 25 Nov 2024 10:51:29 +0100 Subject: [PATCH 5/6] upd replay --- .github/workflows/starknet-blocks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/starknet-blocks.yml b/.github/workflows/starknet-blocks.yml index 50f1b2759..72d2d9fe4 100644 --- a/.github/workflows/starknet-blocks.yml +++ b/.github/workflows/starknet-blocks.yml @@ -27,7 +27,7 @@ jobs: components: clippy - uses: Swatinem/rust-cache@v2 with: - key: "ref-16302c859b1aacc019eea154a58eddc7b32050c1" + key: "ref-02b46e8b108f85ac50c22a8c41c9d8b0a93294e8" - name: Check and free hdd space left if: ${{ matrix.runner == 'native' }} @@ -76,7 +76,7 @@ jobs: uses: actions/checkout@v4 with: repository: lambdaclass/starknet-replay - ref: 16302c859b1aacc019eea154a58eddc7b32050c1 + ref: 02b46e8b108f85ac50c22a8c41c9d8b0a93294e8 path: replay - name: Install Starknet Replay deps From 2ec6daae328a082e6a3e1589f7e8556e1c6b49c4 Mon Sep 17 00:00:00 2001 From: Edgar Luque Date: Tue, 26 Nov 2024 12:32:02 +0100 Subject: [PATCH 6/6] Add MetadataConfig as parameter to compile and pass correct function costs on AotContractExecutor --- Cargo.lock | 371 ++++++++++++++-------------- benches/compile_time.rs | 20 +- benches/libfuncs.rs | 16 +- examples/easy_api.rs | 4 +- examples/erc20.rs | 4 +- examples/invoke.rs | 4 +- examples/starknet.rs | 4 +- src/bin/cairo-native-compile.rs | 4 +- src/bin/cairo-native-dump.rs | 2 +- src/bin/cairo-native-run.rs | 4 +- src/bin/cairo-native-stress/main.rs | 2 +- src/bin/scarb-native-dump.rs | 6 +- src/bin/utils/test.rs | 4 +- src/cache/aot.rs | 4 +- src/cache/jit.rs | 4 +- src/context.rs | 12 +- src/executor.rs | 8 +- src/executor/aot.rs | 6 +- src/executor/contract.rs | 45 +++- src/libfuncs/enum.rs | 4 +- src/utils.rs | 2 +- tests/common.rs | 18 +- tests/tests/compile_library.rs | 2 +- tests/tests/starknet/keccak.rs | 3 +- tests/tests/trampoline.rs | 4 +- 25 files changed, 316 insertions(+), 241 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ad90db644..ba5969b57 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -42,9 +42,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.18" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9" [[package]] name = "anes" @@ -54,9 +54,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.6.17" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23a1e53f0f5d86382dafe1cf314783b2044280f406e7e1506368220ad11b1338" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ "anstyle", "anstyle-parse", @@ -69,9 +69,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8365de52b16c035ff4fcafe0092ba9390540e3e352870ac09933bebcaa2c8c56" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "anstyle-parse" @@ -103,9 +103,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.91" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" +checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" [[package]] name = "aquamarine" @@ -118,7 +118,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -134,7 +134,7 @@ dependencies = [ "derivative", "hashbrown 0.13.2", "itertools 0.10.5", - "num-traits 0.2.19", + "num-traits", "zeroize", ] @@ -152,7 +152,7 @@ dependencies = [ "digest", "itertools 0.10.5", "num-bigint", - "num-traits 0.2.19", + "num-traits", "paste", "rustc_version", "zeroize", @@ -175,7 +175,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" dependencies = [ "num-bigint", - "num-traits 0.2.19", + "num-traits", "proc-macro2", "quote", "syn 1.0.109", @@ -245,7 +245,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" dependencies = [ - "num-traits 0.2.19", + "num-traits", "rand", ] @@ -310,7 +310,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.85", + "syn 2.0.89", "which", ] @@ -331,7 +331,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -378,9 +378,9 @@ dependencies = [ [[package]] name = "bstr" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" +checksum = "1a68f1f47cdf0ec8ee4b941b2eee2a80cb796db73118c0dd09ac63fbe405be22" dependencies = [ "memchr", "serde", @@ -434,7 +434,7 @@ dependencies = [ "cairo-lang-utils", "indoc", "num-bigint", - "num-traits 0.2.19", + "num-traits", "parity-scale-codec", "serde", ] @@ -569,7 +569,7 @@ dependencies = [ "log", "num-bigint", "num-integer", - "num-traits 0.2.19", + "num-traits", "rust-analyzer-salsa", "smol_str", ] @@ -588,7 +588,7 @@ dependencies = [ "colored", "itertools 0.12.1", "num-bigint", - "num-traits 0.2.19", + "num-traits", "rust-analyzer-salsa", "smol_str", "unescaper", @@ -621,7 +621,7 @@ checksum = "ac857ec4b564712f3e16e3314e23cc0787ab1c05cdfee83f1c8f9989a6eee40f" dependencies = [ "cairo-lang-debug", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -661,7 +661,7 @@ dependencies = [ "keccak", "num-bigint", "num-integer", - "num-traits 0.2.19", + "num-traits", "rand", "sha2", "smol_str", @@ -689,7 +689,7 @@ dependencies = [ "indoc", "itertools 0.12.1", "num-bigint", - "num-traits 0.2.19", + "num-traits", "rust-analyzer-salsa", "smol_str", "toml", @@ -711,7 +711,7 @@ dependencies = [ "lalrpop-util", "num-bigint", "num-integer", - "num-traits 0.2.19", + "num-traits", "regex", "rust-analyzer-salsa", "serde", @@ -734,7 +734,7 @@ dependencies = [ "cairo-lang-utils", "itertools 0.12.1", "num-bigint", - "num-traits 0.2.19", + "num-traits", "thiserror", ] @@ -750,7 +750,7 @@ dependencies = [ "cairo-lang-utils", "itertools 0.12.1", "num-bigint", - "num-traits 0.2.19", + "num-traits", "thiserror", ] @@ -771,7 +771,7 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "itertools 0.12.1", - "num-traits 0.2.19", + "num-traits", "rust-analyzer-salsa", "serde", "serde_json", @@ -794,7 +794,7 @@ dependencies = [ "indoc", "itertools 0.12.1", "num-bigint", - "num-traits 0.2.19", + "num-traits", "starknet-types-core", "thiserror", ] @@ -853,7 +853,7 @@ dependencies = [ "itertools 0.12.1", "num-bigint", "num-integer", - "num-traits 0.2.19", + "num-traits", "serde", "serde_json", "sha3", @@ -872,7 +872,7 @@ dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", "num-bigint", - "num-traits 0.2.19", + "num-traits", "rust-analyzer-salsa", "smol_str", "unescaper", @@ -910,7 +910,7 @@ dependencies = [ "indoc", "itertools 0.12.1", "num-bigint", - "num-traits 0.2.19", + "num-traits", "serde", "starknet-types-core", ] @@ -938,7 +938,7 @@ dependencies = [ "indexmap 2.6.0", "itertools 0.12.1", "num-bigint", - "num-traits 0.2.19", + "num-traits", "schemars", "serde", ] @@ -968,7 +968,7 @@ dependencies = [ "cairo-lang-test-plugin", "cairo-lang-utils", "cairo-native-runtime", - "cairo-vm 2.0.0-rc0", + "cairo-vm 2.0.0-rc1", "cc", "clap", "colored", @@ -985,7 +985,7 @@ dependencies = [ "mlir-sys", "num-bigint", "num-integer", - "num-traits 0.2.19", + "num-traits", "pretty_assertions_sorted", "proptest", "rayon", @@ -1013,7 +1013,7 @@ dependencies = [ "cairo-lang-sierra-gas", "itertools 0.13.0", "lazy_static", - "num-traits 0.2.19", + "num-traits", "rand", "starknet-curve 0.5.1", "starknet-types-core", @@ -1037,7 +1037,7 @@ dependencies = [ "num-bigint", "num-integer", "num-prime", - "num-traits 0.2.19", + "num-traits", "rand", "rust_decimal", "serde", @@ -1052,9 +1052,9 @@ dependencies = [ [[package]] name = "cairo-vm" -version = "2.0.0-rc0" +version = "2.0.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db4375450795765e55bf6c58974b26742a1a3935afd07f996062d7d2e545b4a4" +checksum = "094da2b352a8a0c8400a26f7db6a75c35279f39cc401e08900a714393f110957" dependencies = [ "anyhow", "ark-ff", @@ -1073,7 +1073,7 @@ dependencies = [ "num-bigint", "num-integer", "num-prime", - "num-traits 0.2.19", + "num-traits", "rand", "rust_decimal", "serde", @@ -1114,9 +1114,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.1.31" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" +checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" dependencies = [ "jobserver", "libc", @@ -1188,9 +1188,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.20" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" +checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f" dependencies = [ "clap_builder", "clap_derive", @@ -1198,9 +1198,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.20" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" +checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec" dependencies = [ "anstream", "anstyle", @@ -1217,14 +1217,14 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] name = "clap_lex" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" +checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" [[package]] name = "colorchoice" @@ -1268,7 +1268,7 @@ dependencies = [ "encode_unicode", "lazy_static", "libc", - "unicode-width", + "unicode-width 0.1.14", "windows-sys 0.52.0", ] @@ -1315,9 +1315,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" +checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" dependencies = [ "libc", ] @@ -1344,7 +1344,7 @@ dependencies = [ "criterion-plot", "is-terminal", "itertools 0.10.5", - "num-traits 0.2.19", + "num-traits", "once_cell", "oorandom", "plotters", @@ -1440,7 +1440,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -1451,7 +1451,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -1518,7 +1518,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -1528,7 +1528,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -1599,7 +1599,7 @@ dependencies = [ "enum-ordinalize", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -1646,7 +1646,7 @@ checksum = "0d28318a75d4aead5c4db25382e8ef717932d0346600cacae6357eb5941bc5ff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -1667,9 +1667,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" +checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" [[package]] name = "fixedbitset" @@ -1679,9 +1679,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.34" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", "miniz_oxide", @@ -1761,7 +1761,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -1802,9 +1802,9 @@ dependencies = [ [[package]] name = "genco" -version = "0.17.9" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afac3cbb14db69ac9fef9cdb60d8a87e39a7a527f85a81a923436efa40ad42c6" +checksum = "a35958104272e516c2a5f66a9d82fba4784d2b585fc1e2358b8f96e15d342995" dependencies = [ "genco-macros", "relative-path", @@ -1813,13 +1813,13 @@ dependencies = [ [[package]] name = "genco-macros" -version = "0.17.9" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "553630feadf7b76442b0849fd25fdf89b860d933623aec9693fed19af0400c78" +checksum = "43eaff6bbc0b3a878361aced5ec6a2818ee7c541c5b33b5880dfa9a86c23e9e7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -1860,18 +1860,18 @@ dependencies = [ "aho-corasick", "bstr", "log", - "regex-automata 0.4.8", + "regex-automata 0.4.9", "regex-syntax 0.8.5", ] [[package]] name = "good_lp" -version = "1.8.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3198bd13dea84c76a64621d6ee8ee26a4960a9a0d538eca95ca8f1320a469ac9" +checksum = "97630e1e456d7081c524488a87d8f8f7ed0fd3100ba10c55e3cfa7add5ce05c6" dependencies = [ "fnv", - "minilp", + "microlp", ] [[package]] @@ -1912,9 +1912,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" dependencies = [ "allocator-api2", "equivalent", @@ -1994,7 +1994,7 @@ dependencies = [ "globset", "log", "memchr", - "regex-automata 0.4.8", + "regex-automata 0.4.9", "same-file", "walkdir", "winapi-util", @@ -2002,13 +2002,13 @@ dependencies = [ [[package]] name = "impl-trait-for-tuples" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.89", ] [[package]] @@ -2054,21 +2054,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.15.0", + "hashbrown 0.15.1", "serde", ] [[package]] name = "indicatif" -version = "0.17.8" +version = "0.17.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "763a5a8f45087d6bcea4222e7b72c291a054edf80e4ef6efd2a4979878c7bea3" +checksum = "cbf675b85ed934d3c67b5c5469701eec7db22689d0a2139d856e0925fa28b281" dependencies = [ "console", - "instant", "number_prefix", "portable-atomic", - "unicode-width", + "unicode-width 0.2.0", + "web-time", ] [[package]] @@ -2086,15 +2086,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "instant" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" -dependencies = [ - "cfg-if", -] - [[package]] name = "is-terminal" version = "0.4.13" @@ -2150,9 +2141,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "540654e97a3f4470a492cd30ff187bc95d89557a903a2bbf112e2fae98104ef2" [[package]] name = "jobserver" @@ -2209,7 +2200,7 @@ version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "507460a910eb7b32ee961886ff48539633b788a36b65692b95f225b844c82553" dependencies = [ - "regex-automata 0.4.8", + "regex-automata 0.4.9", ] [[package]] @@ -2252,9 +2243,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.161" +version = "0.2.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" +checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" [[package]] name = "libloading" @@ -2324,7 +2315,7 @@ version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" dependencies = [ - "hashbrown 0.15.0", + "hashbrown 0.15.1", ] [[package]] @@ -2338,10 +2329,11 @@ dependencies = [ [[package]] name = "matrixmultiply" -version = "0.2.4" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "916806ba0031cd542105d916a97c8572e1fa6dd79c9c51e7eb43a09ec2dd84c1" +checksum = "9380b911e3e96d10c1f415da0876389aaf1b56759054eeb0de7df940c456ba1a" dependencies = [ + "autocfg", "rawpointer", ] @@ -2369,7 +2361,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.85", + "syn 2.0.89", "tblgen-alt", "unindent", ] @@ -2381,10 +2373,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] -name = "minilp" -version = "0.2.2" +name = "microlp" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82a7750a9e5076c660b7bec5e6457b4dbff402b9863c8d112891434e18fd5385" +checksum = "4190b5ca62abfbc95a81d57f4a8e3e3872289d656f3eeea5820b3046a1f81d4b" dependencies = [ "log", "sprs", @@ -2416,14 +2408,16 @@ dependencies = [ [[package]] name = "ndarray" -version = "0.13.1" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac06db03ec2f46ee0ecdca1a1c34a99c0d188a0d83439b84bf0cb4b386e4ab09" +checksum = "882ed72dce9365842bf196bdeedf5055305f11fc8c03dee7bb0194a6cad34841" dependencies = [ "matrixmultiply", "num-complex", "num-integer", - "num-traits 0.2.19", + "num-traits", + "portable-atomic", + "portable-atomic-util", "rawpointer", ] @@ -2460,19 +2454,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ "num-integer", - "num-traits 0.2.19", + "num-traits", "rand", "serde", ] [[package]] name = "num-complex" -version = "0.2.4" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" dependencies = [ - "autocfg", - "num-traits 0.2.19", + "num-traits", ] [[package]] @@ -2487,7 +2480,7 @@ version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "num-traits 0.2.19", + "num-traits", ] [[package]] @@ -2498,7 +2491,7 @@ checksum = "64a5fe11d4135c3bcdf3a95b18b194afa9608a5f6ff034f5d857bc9a27fb0119" dependencies = [ "num-bigint", "num-integer", - "num-traits 0.2.19", + "num-traits", ] [[package]] @@ -2513,19 +2506,10 @@ dependencies = [ "num-bigint", "num-integer", "num-modular", - "num-traits 0.2.19", + "num-traits", "rand", ] -[[package]] -name = "num-traits" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" -dependencies = [ - "num-traits 0.2.19", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -2560,7 +2544,7 @@ version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" dependencies = [ - "num-traits 0.2.19", + "num-traits", ] [[package]] @@ -2571,28 +2555,29 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "parity-scale-codec" -version = "3.6.12" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" +checksum = "8be4817d39f3272f69c59fe05d0535ae6456c2dc2fa1ba02910296c7e0a5c590" dependencies = [ "arrayvec", "bitvec", "byte-slice-cast", "impl-trait-for-tuples", "parity-scale-codec-derive", + "rustversion", "serde", ] [[package]] name = "parity-scale-codec-derive" -version = "3.6.12" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" +checksum = "8781a75c6205af67215f382092b6e0a4ff3734798523e69073d4bcd294ec767b" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.89", ] [[package]] @@ -2702,7 +2687,7 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" dependencies = [ - "num-traits 0.2.19", + "num-traits", "plotters-backend", "plotters-svg", "wasm-bindgen", @@ -2730,6 +2715,15 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" +[[package]] +name = "portable-atomic-util" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90a7d5beecc52a491b54d6dd05c7a45ba1801666a5baad9fdbfc6fef8d2d206c" +dependencies = [ + "portable-atomic", +] + [[package]] name = "powerfmt" version = "0.2.0" @@ -2778,7 +2772,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ "proc-macro2", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -2816,9 +2810,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "307e3004becf10f5a6e0d59d20f3cd28231b0e0827a96cd3e0ce6d14bc1e4bb3" dependencies = [ "unicode-ident", ] @@ -2833,7 +2827,7 @@ dependencies = [ "bit-vec", "bitflags", "lazy_static", - "num-traits 0.2.19", + "num-traits", "rand", "rand_chacha", "rand_xorshift", @@ -2957,7 +2951,7 @@ checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.8", + "regex-automata 0.4.9", "regex-syntax 0.8.5", ] @@ -2972,9 +2966,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -3041,7 +3035,7 @@ dependencies = [ "regex", "relative-path", "rustc_version", - "syn 2.0.85", + "syn 2.0.89", "unicode-ident", ] @@ -3071,7 +3065,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -3081,7 +3075,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b082d80e3e3cc52b2ed634388d436fe1f4de6af5786cc2de9ba9737527bdf555" dependencies = [ "arrayvec", - "num-traits 0.2.19", + "num-traits", ] [[package]] @@ -3101,9 +3095,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.38" +version = "0.38.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a" +checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" dependencies = [ "bitflags", "errno", @@ -3197,7 +3191,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -3217,22 +3211,22 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -3243,14 +3237,14 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] name = "serde_json" -version = "1.0.132" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ "itoa", "memchr", @@ -3362,13 +3356,14 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "sprs" -version = "0.7.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec63571489873d4506683915840eeb1bb16b3198ee4894cc6f2fe3013d505e56" +checksum = "704ef26d974e8a452313ed629828cd9d4e4fa34667ca1ad9d6b1fffa43c6e166" dependencies = [ "ndarray", "num-complex", - "num-traits 0.1.43", + "num-traits", + "smallvec", ] [[package]] @@ -3388,7 +3383,7 @@ dependencies = [ "hmac", "num-bigint", "num-integer", - "num-traits 0.2.19", + "num-traits", "rfc6979", "sha2", "starknet-crypto-codegen", @@ -3405,7 +3400,7 @@ checksum = "bbc159a1934c7be9761c237333a57febe060ace2bc9e3b337a59a37af206d19f" dependencies = [ "starknet-curve 0.4.2", "starknet-ff", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -3449,7 +3444,7 @@ dependencies = [ "lazy_static", "num-bigint", "num-integer", - "num-traits 0.2.19", + "num-traits", "serde", ] @@ -3497,9 +3492,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.85" +version = "2.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" +checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" dependencies = [ "proc-macro2", "quote", @@ -3526,9 +3521,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" +checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" dependencies = [ "cfg-if", "fastrand", @@ -3566,7 +3561,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -3577,28 +3572,28 @@ checksum = "5c89e72a01ed4c579669add59014b9a524d609c0c88c6a585ce37485879f6ffb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", "test-case-core", ] [[package]] name = "thiserror" -version = "1.0.65" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.65" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -3737,7 +3732,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -3831,9 +3826,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "unicode-normalization" @@ -3856,6 +3851,12 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + [[package]] name = "unicode-xid" version = "0.2.6" @@ -3950,7 +3951,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", "wasm-bindgen-shared", ] @@ -3972,7 +3973,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3993,6 +3994,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "which" version = "4.4.2" @@ -4204,18 +4215,18 @@ dependencies = [ [[package]] name = "xshell" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db0ab86eae739efd1b054a8d3d16041914030ac4e01cd1dca0cf252fd8b6437" +checksum = "9e7290c623014758632efe00737145b6867b66292c42167f2ec381eb566a373d" dependencies = [ "xshell-macros", ] [[package]] name = "xshell-macros" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d422e8e38ec76e2f06ee439ccc765e9c6a9638b9e7c9f2e8255e4d41e8bd852" +checksum = "32ac00cd3f8ec9c1d33fb3e7958a82df6989c42d747bd326c822b1d625283547" [[package]] name = "yansi" @@ -4241,7 +4252,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] @@ -4261,7 +4272,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.89", ] [[package]] diff --git a/benches/compile_time.rs b/benches/compile_time.rs index c28ac4de4..5ec301c50 100644 --- a/benches/compile_time.rs +++ b/benches/compile_time.rs @@ -14,7 +14,9 @@ pub fn bench_compile_time(c: &mut Criterion) { c.bench_with_input(BenchmarkId::new(filename, 1), &program, |b, program| { b.iter(|| { let native_context = NativeContext::new(); - native_context.compile(program, false).unwrap(); + native_context + .compile(program, false, Some(Default::default())) + .unwrap(); // pass manager internally verifies the MLIR output is correct. }) }); @@ -29,7 +31,9 @@ pub fn bench_compile_time(c: &mut Criterion) { for (program, filename) in &programs { c.bench_with_input(BenchmarkId::new(filename, 1), &program, |b, program| { b.iter(|| { - native_context.compile(program, false).unwrap(); + native_context + .compile(program, false, Some(Default::default())) + .unwrap(); // pass manager internally verifies the MLIR output is correct. }) }); @@ -43,7 +47,9 @@ pub fn bench_compile_time(c: &mut Criterion) { c.bench_with_input(BenchmarkId::new(filename, 1), &program, |b, program| { b.iter(|| { let native_context = NativeContext::new(); - let module = native_context.compile(black_box(program), false).unwrap(); + let module = native_context + .compile(black_box(program), false, Some(Default::default())) + .unwrap(); let object = module_to_object(module.module(), OptLevel::None) .expect("to compile correctly to a object file"); black_box(object) @@ -60,7 +66,9 @@ pub fn bench_compile_time(c: &mut Criterion) { for (program, filename) in &programs { c.bench_with_input(BenchmarkId::new(filename, 1), &program, |b, program| { b.iter(|| { - let module = native_context.compile(black_box(program), false).unwrap(); + let module = native_context + .compile(black_box(program), false, Some(Default::default())) + .unwrap(); let object = module_to_object(module.module(), OptLevel::None) .expect("to compile correctly to a object file"); black_box(object) @@ -77,7 +85,9 @@ pub fn bench_compile_time(c: &mut Criterion) { for (program, filename) in &programs { c.bench_with_input(BenchmarkId::new(filename, 1), &program, |b, program| { b.iter(|| { - let module = native_context.compile(black_box(program), false).unwrap(); + let module = native_context + .compile(black_box(program), false, Some(Default::default())) + .unwrap(); let object = module_to_object(module.module(), OptLevel::Aggressive) .expect("to compile correctly to a object file"); black_box(object) diff --git a/benches/libfuncs.rs b/benches/libfuncs.rs index 8bfa26ca8..edcebd370 100644 --- a/benches/libfuncs.rs +++ b/benches/libfuncs.rs @@ -54,7 +54,9 @@ pub fn bench_libfuncs(c: &mut Criterion) { |b, program| { let native_context = NativeContext::new(); b.iter(|| { - let module = native_context.compile(program, false).unwrap(); + let module = native_context + .compile(program, false, Some(Default::default())) + .unwrap(); // pass manager internally verifies the MLIR output is correct. let native_executor = JitNativeExecutor::from_native_module(module, OptLevel::Aggressive) @@ -74,7 +76,9 @@ pub fn bench_libfuncs(c: &mut Criterion) { program, |b, program| { let native_context = NativeContext::new(); - let module = native_context.compile(program, false).unwrap(); + let module = native_context + .compile(program, false, Some(Default::default())) + .unwrap(); // pass manager internally verifies the MLIR output is correct. let native_executor = JitNativeExecutor::from_native_module(module, OptLevel::Aggressive) @@ -103,7 +107,9 @@ pub fn bench_libfuncs(c: &mut Criterion) { |b, program| { let native_context = NativeContext::new(); b.iter(|| { - let module = native_context.compile(program, false).unwrap(); + let module = native_context + .compile(program, false, Some(Default::default())) + .unwrap(); // pass manager internally verifies the MLIR output is correct. let native_executor = AotNativeExecutor::from_native_module(module, OptLevel::Aggressive) @@ -123,7 +129,9 @@ pub fn bench_libfuncs(c: &mut Criterion) { program, |b, program| { let native_context = NativeContext::new(); - let module = native_context.compile(program, false).unwrap(); + let module = native_context + .compile(program, false, Some(Default::default())) + .unwrap(); // pass manager internally verifies the MLIR output is correct. let native_executor = AotNativeExecutor::from_native_module(module, OptLevel::Aggressive) diff --git a/examples/easy_api.rs b/examples/easy_api.rs index be1851b66..fef4ab8ea 100644 --- a/examples/easy_api.rs +++ b/examples/easy_api.rs @@ -15,7 +15,9 @@ fn main() { let sierra_program = cairo_to_sierra(program_path).unwrap(); // Compile the sierra program into a MLIR module. - let native_program = native_context.compile(&sierra_program, false).unwrap(); + let native_program = native_context + .compile(&sierra_program, false, Some(Default::default())) + .unwrap(); // The parameters of the entry point. let params = &[Value::Felt252(Felt::from_bytes_be_slice(b"user"))]; diff --git a/examples/erc20.rs b/examples/erc20.rs index b36d2947d..5b43b91c0 100644 --- a/examples/erc20.rs +++ b/examples/erc20.rs @@ -313,7 +313,9 @@ fn main() { let native_context = NativeContext::new(); - let native_program = native_context.compile(&sierra_program, false).unwrap(); + let native_program = native_context + .compile(&sierra_program, false, Some(Default::default())) + .unwrap(); let entry_point_fn = find_entry_point_by_idx(&sierra_program, entry_point.function_idx).unwrap(); diff --git a/examples/invoke.rs b/examples/invoke.rs index 8698bac83..2ac4a2494 100644 --- a/examples/invoke.rs +++ b/examples/invoke.rs @@ -20,7 +20,9 @@ fn main() { let native_context = NativeContext::new(); - let native_program = native_context.compile(&sierra_program, false).unwrap(); + let native_program = native_context + .compile(&sierra_program, false, Some(Default::default())) + .unwrap(); // Call the echo function from the contract using the generated wrapper. diff --git a/examples/starknet.rs b/examples/starknet.rs index e64716325..c412e6ad6 100644 --- a/examples/starknet.rs +++ b/examples/starknet.rs @@ -441,7 +441,9 @@ fn main() { let native_context = NativeContext::new(); - let native_program = native_context.compile(&sierra_program, false).unwrap(); + let native_program = native_context + .compile(&sierra_program, false, Some(Default::default())) + .unwrap(); // Call the echo function from the contract using the generated wrapper. diff --git a/src/bin/cairo-native-compile.rs b/src/bin/cairo-native-compile.rs index 1381bee28..1fceffd37 100644 --- a/src/bin/cairo-native-compile.rs +++ b/src/bin/cairo-native-compile.rs @@ -55,7 +55,9 @@ fn main() -> anyhow::Result<()> { let sierra_program = cairo_to_sierra(&args.path).unwrap(); // Compile the sierra program into a MLIR module. - let native_module = native_context.compile(&sierra_program, false).unwrap(); + let native_module = native_context + .compile(&sierra_program, false, Some(Default::default())) + .unwrap(); let output_mlir = args .output_mlir diff --git a/src/bin/cairo-native-dump.rs b/src/bin/cairo-native-dump.rs index 0073e86ea..dccf053d8 100644 --- a/src/bin/cairo-native-dump.rs +++ b/src/bin/cairo-native-dump.rs @@ -35,7 +35,7 @@ fn main() -> Result<(), Box> { let program = load_program(Path::new(&args.input), args.starknet)?; // Compile the program. - let module = context.compile(&program, false)?; + let module = context.compile(&program, false, Some(Default::default()))?; // Write the output. let output_str = module diff --git a/src/bin/cairo-native-run.rs b/src/bin/cairo-native-run.rs index 03f0f48fb..32fd46b95 100644 --- a/src/bin/cairo-native-run.rs +++ b/src/bin/cairo-native-run.rs @@ -72,7 +72,9 @@ fn main() -> anyhow::Result<()> { let native_context = NativeContext::new(); // Compile the sierra program into a MLIR module. - let native_module = native_context.compile(&sierra_program, false).unwrap(); + let native_module = native_context + .compile(&sierra_program, false, Some(Default::default())) + .unwrap(); let native_executor: Box _> = match args.run_mode { RunMode::Aot => { diff --git a/src/bin/cairo-native-stress/main.rs b/src/bin/cairo-native-stress/main.rs index 1b74b1a00..cf5471b1e 100644 --- a/src/bin/cairo-native-stress/main.rs +++ b/src/bin/cairo-native-stress/main.rs @@ -280,7 +280,7 @@ where ) -> Arc { let native_module = self .context - .compile(program, false) + .compile(program, false, Some(Default::default())) .expect("failed to compile program"); let registry = ProgramRegistry::new(program).expect("failed to get program registry"); diff --git a/src/bin/scarb-native-dump.rs b/src/bin/scarb-native-dump.rs index 146a816b1..ab779d4f4 100644 --- a/src/bin/scarb-native-dump.rs +++ b/src/bin/scarb-native-dump.rs @@ -37,7 +37,11 @@ fn main() -> anyhow::Result<()> { // Compile the sierra program into a MLIR module. let native_module = native_context - .compile(&compiled.into_v1().unwrap().program, false) + .compile( + &compiled.into_v1().unwrap().program, + false, + Some(Default::default()), + ) .unwrap(); // Write the output. diff --git a/src/bin/utils/test.rs b/src/bin/utils/test.rs index 45db60a71..c090581e2 100644 --- a/src/bin/utils/test.rs +++ b/src/bin/utils/test.rs @@ -136,7 +136,9 @@ pub fn run_tests( let native_context = NativeContext::new(); // Compile the sierra program into a MLIR module. - let native_module = native_context.compile(&sierra_program, false).unwrap(); + let native_module = native_context + .compile(&sierra_program, false, Some(Default::default())) + .unwrap(); let native_executor: Box _> = match args.run_mode { RunMode::Aot => { diff --git a/src/cache/aot.rs b/src/cache/aot.rs index f2b0869b0..357afd5f2 100644 --- a/src/cache/aot.rs +++ b/src/cache/aot.rs @@ -45,7 +45,9 @@ where module, registry, metadata, - } = self.context.compile(program, false)?; + } = self + .context + .compile(program, false, Some(Default::default()))?; // Compile module into an object. let object_data = crate::ffi::module_to_object(&module, opt_level)?; diff --git a/src/cache/jit.rs b/src/cache/jit.rs index d926b5b2a..6ed6b5ce7 100644 --- a/src/cache/jit.rs +++ b/src/cache/jit.rs @@ -46,7 +46,9 @@ where program: &Program, opt_level: OptLevel, ) -> Result>> { - let module = self.context.compile(program, false)?; + let module = self + .context + .compile(program, false, Some(Default::default()))?; let executor = JitNativeExecutor::from_native_module(module, opt_level)?; let executor = Arc::new(executor); diff --git a/src/context.rs b/src/context.rs index f263856f0..d49b8388b 100644 --- a/src/context.rs +++ b/src/context.rs @@ -71,6 +71,7 @@ impl NativeContext { &self, program: &Program, ignore_debug_names: bool, + gas_metadata_config: Option, ) -> Result { trace!("starting sierra to mlir compilation"); let pre_sierra_compilation_instant = Instant::now(); @@ -157,20 +158,11 @@ impl NativeContext { let mut module = Module::from_operation(op) .to_native_assert_error("value should be module operation")?; - let has_gas_builtin = program - .type_declarations - .iter() - .any(|decl| decl.long_id.generic_id.0.as_str() == "GasBuiltin"); - let mut metadata = MetadataStorage::new(); // Make the runtime library available. metadata.insert(RuntimeBindingsMeta::default()); // We assume that GasMetadata will be always present when the program uses the gas builtin. - let gas_metadata = if has_gas_builtin { - GasMetadata::new(program, Some(MetadataComputationConfig::default())) - } else { - GasMetadata::new(program, None) - }?; + let gas_metadata = GasMetadata::new(program, gas_metadata_config)?; // Unwrapping here is not necessary since the insertion will only fail if there was // already some metadata of the same type. metadata.insert(gas_metadata); diff --git a/src/executor.rs b/src/executor.rs index dad147b76..a908e5650 100644 --- a/src/executor.rs +++ b/src/executor.rs @@ -684,7 +684,7 @@ mod tests { fn test_invoke_dynamic_aot_native_executor(program: Program) { let native_context = NativeContext::new(); let module = native_context - .compile(&program, false) + .compile(&program, false, Some(Default::default())) .expect("failed to compile context"); let executor = AotNativeExecutor::from_native_module(module, OptLevel::default()).unwrap(); @@ -702,7 +702,7 @@ mod tests { fn test_invoke_dynamic_jit_native_executor(program: Program) { let native_context = NativeContext::new(); let module = native_context - .compile(&program, false) + .compile(&program, false, None) .expect("failed to compile context"); let executor = JitNativeExecutor::from_native_module(module, OptLevel::default()).unwrap(); @@ -720,7 +720,7 @@ mod tests { fn test_invoke_contract_dynamic_aot(starknet_program: Program) { let native_context = NativeContext::new(); let module = native_context - .compile(&starknet_program, false) + .compile(&starknet_program, false, Some(Default::default())) .expect("failed to compile context"); let executor = AotNativeExecutor::from_native_module(module, OptLevel::default()).unwrap(); @@ -747,7 +747,7 @@ mod tests { fn test_invoke_contract_dynamic_jit(starknet_program: Program) { let native_context = NativeContext::new(); let module = native_context - .compile(&starknet_program, false) + .compile(&starknet_program, false, Some(Default::default())) .expect("failed to compile context"); let executor = JitNativeExecutor::from_native_module(module, OptLevel::default()).unwrap(); diff --git a/src/executor/aot.rs b/src/executor/aot.rs index 5ea08785e..c13ea5866 100644 --- a/src/executor/aot.rs +++ b/src/executor/aot.rs @@ -264,7 +264,7 @@ mod tests { fn test_invoke_dynamic(program: Program, #[case] optlevel: OptLevel) { let native_context = NativeContext::new(); let module = native_context - .compile(&program, false) + .compile(&program, false, Some(Default::default())) .expect("failed to compile context"); let executor = AotNativeExecutor::from_native_module(module, optlevel).unwrap(); @@ -285,7 +285,7 @@ mod tests { fn test_invoke_dynamic_with_syscall_handler(program: Program, #[case] optlevel: OptLevel) { let native_context = NativeContext::new(); let module = native_context - .compile(&program, false) + .compile(&program, false, Some(Default::default())) .expect("failed to compile context"); let executor = AotNativeExecutor::from_native_module(module, optlevel).unwrap(); @@ -324,7 +324,7 @@ mod tests { fn test_invoke_contract_dynamic(starknet_program: Program, #[case] optlevel: OptLevel) { let native_context = NativeContext::new(); let module = native_context - .compile(&starknet_program, false) + .compile(&starknet_program, false, Some(Default::default())) .expect("failed to compile context"); let executor = AotNativeExecutor::from_native_module(module, optlevel).unwrap(); diff --git a/src/executor/contract.rs b/src/executor/contract.rs index d6268e0cb..93fd2e3a8 100644 --- a/src/executor/contract.rs +++ b/src/executor/contract.rs @@ -37,6 +37,7 @@ use crate::{ error::{panic::ToNativeAssertError, Error}, execution_result::{BuiltinStats, ContractExecutionResult}, executor::invoke_trampoline, + metadata::gas::MetadataComputationConfig, module::NativeModule, native_panic, starknet::{handler::StarknetSyscallHandlerCallbacks, StarknetSyscallHandler}, @@ -50,12 +51,13 @@ use crate::{ use bumpalo::Bump; use cairo_lang_sierra::{ extensions::{ - circuit::CircuitTypeConcrete, core::CoreTypeConcrete, starknet::StarkNetTypeConcrete, - ConcreteType, + circuit::CircuitTypeConcrete, core::CoreTypeConcrete, gas::CostTokenType, + starknet::StarkNetTypeConcrete, ConcreteType, }, ids::FunctionId, program::Program, }; +use cairo_lang_starknet_classes::casm_contract_class::ENTRY_POINT_COST; use cairo_lang_starknet_classes::contract_class::ContractEntryPoints; use educe::Educe; use libloading::Library; @@ -146,15 +148,6 @@ impl AotContractExecutor { opt_level: OptLevel, ) -> Result { let native_context = NativeContext::new(); - let module = native_context.compile(sierra_program, true)?; - - let NativeModule { - module, - registry, - metadata: _, - } = module; - - let mut infos = BTreeMap::new(); let mut entry_point_selector_to_id = BTreeMap::new(); @@ -170,6 +163,32 @@ impl AotContractExecutor { used_function_ids.insert(entry.function_idx as u64); } + let module = native_context.compile( + sierra_program, + true, + Some(MetadataComputationConfig { + function_set_costs: used_function_ids + .iter() + .map(|id| { + ( + FunctionId::new(*id), + [(CostTokenType::Const, ENTRY_POINT_COST)].into(), + ) + }) + .collect(), + linear_gas_solver: true, + linear_ap_change_solver: true, + }), + )?; + + let NativeModule { + module, + registry, + metadata: _, + } = module; + + let mut infos = BTreeMap::new(); + for x in &sierra_program.funcs { // Avoid storing function info for methods that are not contract entry points. if !used_function_ids.contains(&x.id.id) { @@ -702,7 +721,7 @@ mod tests { .unwrap(); assert_eq!(result.return_values, vec![Felt::from(n), Felt::from(n * 2)]); - assert_eq!(result.remaining_gas, 18446744073709549845); + assert_eq!(result.remaining_gas, 18446744073709551615); }); } @@ -772,7 +791,7 @@ mod tests { .unwrap(); assert_eq!(result.return_values, vec![Felt::from(3628800)]); - assert_eq!(result.remaining_gas, 18446744073709535475); + assert_eq!(result.remaining_gas, 18446744073709538915); } #[rstest] diff --git a/src/libfuncs/enum.rs b/src/libfuncs/enum.rs index 150c1d481..90d3fc39c 100644 --- a/src/libfuncs/enum.rs +++ b/src/libfuncs/enum.rs @@ -644,6 +644,8 @@ mod test { }; let native_context = NativeContext::new(); - native_context.compile(&program, false).unwrap(); + native_context + .compile(&program, false, Some(Default::default())) + .unwrap(); } } diff --git a/src/utils.rs b/src/utils.rs index a63ad114f..3e9f70604 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -702,7 +702,7 @@ pub mod test { let context = NativeContext::new(); let module = context - .compile(program, false) + .compile(program, false, Some(Default::default())) .expect("Could not compile test program to MLIR."); let executor = JitNativeExecutor::from_native_module(module, OptLevel::Less).unwrap(); diff --git a/tests/common.rs b/tests/common.rs index e16633fce..dd5b305c3 100644 --- a/tests/common.rs +++ b/tests/common.rs @@ -28,7 +28,8 @@ use cairo_lang_starknet::{ starknet_plugin_suite, }; use cairo_lang_starknet_classes::{ - casm_contract_class::CasmContractClass, contract_class::ContractClass, + casm_contract_class::{CasmContractClass, ENTRY_POINT_COST}, + contract_class::ContractClass, }; use cairo_lang_utils::Upcast; use cairo_native::{ @@ -232,7 +233,7 @@ pub fn run_native_program( let context = NativeContext::new(); let module = context - .compile(program, false) + .compile(program, false, Some(Default::default())) .expect("Could not compile test program to MLIR."); assert!( @@ -427,7 +428,9 @@ pub fn run_native_starknet_contract( ) -> ContractExecutionResult { let native_context = NativeContext::new(); - let native_program = native_context.compile(sierra_program, false).unwrap(); + let native_program = native_context + .compile(sierra_program, false, Some(Default::default())) + .unwrap(); let entry_point_fn = find_entry_point_by_idx(sierra_program, entry_point_function_idx).unwrap(); let entry_point_id = &entry_point_fn.id; @@ -452,7 +455,14 @@ pub fn run_native_starknet_aot_contract( ) .unwrap(); native_executor - .run(Felt::from(selector), args, u64::MAX, None, handler) + // substract ENTRY_POINT_COST so gas matches + .run( + Felt::from(selector), + args, + u64::MAX - ENTRY_POINT_COST as u64, + None, + handler, + ) .expect("failed to execute the given contract") } diff --git a/tests/tests/compile_library.rs b/tests/tests/compile_library.rs index fbb8eb242..cbd5a014c 100644 --- a/tests/tests/compile_library.rs +++ b/tests/tests/compile_library.rs @@ -14,7 +14,7 @@ pub fn compile_library() -> Result<(), Box> { } }; - let module = context.compile(&program.1, false)?; + let module = context.compile(&program.1, false, Some(Default::default()))?; let object = cairo_native::module_to_object(module.module(), Default::default())?; diff --git a/tests/tests/starknet/keccak.rs b/tests/tests/starknet/keccak.rs index 9dbdf731c..71babc3c7 100644 --- a/tests/tests/starknet/keccak.rs +++ b/tests/tests/starknet/keccak.rs @@ -47,7 +47,6 @@ fn keccak_test() { ); assert!(!result_aot_ct.failure_flag); - // Can't compare the gas because the AotContractExecutor has a fixed initial_gas_cost of 10_000 (as per the sequencer requirements) - // assert_eq!(result_aot_ct.remaining_gas, result.remaining_gas); + assert_eq!(result_aot_ct.remaining_gas, result.remaining_gas); assert_eq!(result_aot_ct.return_values, vec![1.into()]); } diff --git a/tests/tests/trampoline.rs b/tests/tests/trampoline.rs index aba95ca6c..846172c08 100644 --- a/tests/tests/trampoline.rs +++ b/tests/tests/trampoline.rs @@ -13,7 +13,9 @@ fn run_program(program: &Program, entry_point: &str, args: &[Value]) -> Executio let entry_point_id = find_function_id(program, entry_point).expect("entry point not found"); let context = NativeContext::new(); - let module = context.compile(program, false).unwrap(); + let module = context + .compile(program, false, Some(Default::default())) + .unwrap(); // FIXME: There are some bugs with non-zero LLVM optimization levels. let executor = JitNativeExecutor::from_native_module(module, OptLevel::None).unwrap();