From e48c43b8a9d7469e0359d0c37f0d974b1020bf0c Mon Sep 17 00:00:00 2001 From: meship-starkware Date: Mon, 25 Nov 2024 17:16:45 +0200 Subject: [PATCH] refactor(blockifier): see if LC fix worked --- Cargo.lock | 6 ++-- Cargo.toml | 2 +- crates/blockifier/cairo_native | 2 +- .../execution/native/entry_point_execution.rs | 34 +++++++++---------- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9af159fa55..8f2b1f4828 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2226,8 +2226,7 @@ dependencies = [ [[package]] name = "cairo-native" version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "833170f422b08eec0e5ab116573bbb73c73f1601987d4b151cf71760836bd142" +source = "git+https://github.com/lambdaclass/cairo_native.git?rev=ff8fa891fa0aa5c755030847cde4632937be7e17#ff8fa891fa0aa5c755030847cde4632937be7e17" dependencies = [ "anyhow", "aquamarine", @@ -2280,8 +2279,7 @@ dependencies = [ [[package]] name = "cairo-native-runtime" version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fa4ec78d0a6df2988b71838c330a5113f65a4db6ccff53d8d71465f6619a427" +source = "git+https://github.com/lambdaclass/cairo_native.git?rev=ff8fa891fa0aa5c755030847cde4632937be7e17#ff8fa891fa0aa5c755030847cde4632937be7e17" dependencies = [ "cairo-lang-sierra-gas", "itertools 0.13.0", diff --git a/Cargo.toml b/Cargo.toml index 730c9a1e8b..4e01f5f4fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -103,7 +103,7 @@ cairo-lang-sierra-to-casm = "2.9.0-dev.0" cairo-lang-starknet-classes = "2.9.0-dev.0" cairo-lang-utils = "2.9.0-dev.0" # Important: when updated, make sure to update the cairo-native submodule as well. -cairo-native = "0.2.3" +cairo-native = { git = "https://github.com/lambdaclass/cairo_native.git", rev = "ff8fa891fa0aa5c755030847cde4632937be7e17" } cairo-vm = "=1.0.1" camelpaste = "0.1.0" chrono = "0.4.26" diff --git a/crates/blockifier/cairo_native b/crates/blockifier/cairo_native index c9b0fb767d..ff8fa891fa 160000 --- a/crates/blockifier/cairo_native +++ b/crates/blockifier/cairo_native @@ -1 +1 @@ -Subproject commit c9b0fb767d5952053bfe978782a18a410713866a +Subproject commit ff8fa891fa0aa5c755030847cde4632937be7e17 diff --git a/crates/blockifier/src/execution/native/entry_point_execution.rs b/crates/blockifier/src/execution/native/entry_point_execution.rs index 9a338d593b..f71d11e218 100644 --- a/crates/blockifier/src/execution/native/entry_point_execution.rs +++ b/crates/blockifier/src/execution/native/entry_point_execution.rs @@ -41,11 +41,11 @@ pub fn execute_entry_point_call( // Fund the initial budget since the native executor charges it before the run. // TODO(Yoni): revert once the VM is aligned with this. - let gas = syscall_handler.base.call.initial_gas + gas_costs.entry_point_initial_budget; + let gas = syscall_handler.base.call.initial_gas; let execution_result = contract_class.executor.run( entry_point.selector.0, &syscall_handler.base.call.calldata.0.clone(), - Some(gas), + gas, Some(builtin_costs), &mut syscall_handler, ); @@ -64,24 +64,24 @@ fn create_callinfo( call_result: ContractExecutionResult, syscall_handler: NativeSyscallHandler<'_>, ) -> Result { - let mut remaining_gas = call_result.remaining_gas; + let remaining_gas = call_result.remaining_gas; if remaining_gas > syscall_handler.base.call.initial_gas { - if remaining_gas - syscall_handler.base.call.initial_gas - <= syscall_handler.base.context.gas_costs().entry_point_initial_budget - { - // Revert the refund. - // TODO(Yoni): temporary hack - this is probably a bug. Investigate and fix native. - remaining_gas = syscall_handler.base.call.initial_gas; - } else { - return Err(PostExecutionError::MalformedReturnData { - error_message: format!( - "Unexpected remaining gas. Used gas is greater than initial gas: {} > {}", - remaining_gas, syscall_handler.base.call.initial_gas - ), - } - .into()); + // if remaining_gas - syscall_handler.call.initial_gas + // <= syscall_handler.context.gas_costs().entry_point_initial_budget + // { + // // Revert the refund. + // // TODO(Yoni): temporary hack - this is probably a bug. Investigate and fix native. + // remaining_gas = syscall_handler.call.initial_gas; + // } else { + return Err(PostExecutionError::MalformedReturnData { + error_message: format!( + "Unexpected remaining gas. Used gas is greater than initial gas: {} > {}", + remaining_gas, syscall_handler.base.call.initial_gas + ), } + .into()); + // } } let gas_consumed = syscall_handler.base.call.initial_gas - remaining_gas;