Skip to content

Commit e5c0d73

Browse files
committed
Return resources for native execution
1 parent d4474f1 commit e5c0d73

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

crates/cheatnet/src/runtime_extensions/native/execution.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,25 @@ pub(crate) fn execute_entry_point_call_native(
3131
cheatnet_state: &mut CheatnetState, // Added parameter
3232
context: &mut EntryPointExecutionContext,
3333
) -> ContractClassEntryPointExecutionResult {
34-
let syscall_handler = CheatableNativeSyscallHandler {
34+
let mut syscall_handler = CheatableNativeSyscallHandler {
3535
cheatnet_state,
3636
native_syscall_handler: &mut NativeSyscallHandler::new(call.clone(), state, context),
3737
};
3838

39-
let call_info = execute_entry_point_call(call, native_compiled_class_v1, syscall_handler)
39+
let call_info = execute_entry_point_call(call, native_compiled_class_v1, &mut syscall_handler)
4040
.map_err(|err| EntryPointExecutionErrorWithTrace {
4141
source: err,
4242
trace: None,
4343
})?;
4444

45+
let syscall_usage = &syscall_handler.native_syscall_handler.base.syscalls_usage;
46+
4547
Ok(CallInfoWithExecutionData {
4648
call_info,
49+
// Native execution doesn't support VM resources.
50+
// If we got to this point, it means tracked resources are SierraGas.
4751
syscall_usage_vm_resources: HashMap::default(),
48-
syscall_usage_sierra_gas: HashMap::default(),
52+
syscall_usage_sierra_gas: syscall_usage.clone(),
4953
vm_trace: None,
5054
})
5155
}
@@ -58,7 +62,7 @@ pub fn execute_entry_point_call(
5862
compiled_class: &NativeCompiledClassV1,
5963
// state: &mut dyn State,
6064
// context: &mut EntryPointExecutionContext,
61-
mut syscall_handler: CheatableNativeSyscallHandler,
65+
syscall_handler: &mut CheatableNativeSyscallHandler,
6266
) -> EntryPointExecutionResult<CallInfo> {
6367
let entry_point = compiled_class.get_entry_point(&call.type_and_selector())?;
6468

@@ -110,7 +114,7 @@ pub fn execute_entry_point_call(
110114
.clone(),
111115
call_initial_gas,
112116
Some(builtin_costs),
113-
&mut syscall_handler,
117+
&mut *syscall_handler,
114118
);
115119

116120
syscall_handler.native_syscall_handler.finalize();
@@ -129,10 +133,9 @@ pub fn execute_entry_point_call(
129133

130134
// Copied from blockifier
131135
#[allow(clippy::result_large_err)]
132-
#[expect(clippy::needless_pass_by_value)]
133136
fn create_callinfo(
134137
call_result: ContractExecutionResult,
135-
syscall_handler: CheatableNativeSyscallHandler<'_>,
138+
syscall_handler: &mut CheatableNativeSyscallHandler<'_>,
136139
) -> Result<CallInfo, EntryPointExecutionError> {
137140
let remaining_gas = call_result.remaining_gas;
138141

0 commit comments

Comments
 (0)