Skip to content

Commit

Permalink
refactor(blockifier): see if LC fix worked
Browse files Browse the repository at this point in the history
  • Loading branch information
meship-starkware committed Nov 26, 2024
1 parent abf5736 commit e48c43b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
6 changes: 2 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
34 changes: 17 additions & 17 deletions crates/blockifier/src/execution/native/entry_point_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand All @@ -64,24 +64,24 @@ fn create_callinfo(
call_result: ContractExecutionResult,
syscall_handler: NativeSyscallHandler<'_>,
) -> Result<CallInfo, EntryPointExecutionError> {
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;
Expand Down

0 comments on commit e48c43b

Please sign in to comment.