From 07f7b8d8bddb7b168a8c1745c2b43e2b7b804c3e Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Mon, 20 Jan 2025 17:04:01 +0100 Subject: [PATCH] fix: Fix circuit implementation of EVM memory stipend (#91) --- .../src/main_vm/opcodes/call_ret_impl/far_call.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/zkevm_circuits/src/main_vm/opcodes/call_ret_impl/far_call.rs b/crates/zkevm_circuits/src/main_vm/opcodes/call_ret_impl/far_call.rs index 9ead23a..d121bbd 100644 --- a/crates/zkevm_circuits/src/main_vm/opcodes/call_ret_impl/far_call.rs +++ b/crates/zkevm_circuits/src/main_vm/opcodes/call_ret_impl/far_call.rs @@ -1136,18 +1136,18 @@ where zkevm_opcode_defs::system_params::NEW_EVM_FRAME_MEMORY_STIPEND, ); - let memory_stipend = UInt32::conditionally_select( + let memory_size_stipend_for_userspace = UInt32::conditionally_select( cs, - new_callstack_entry.is_kernel_mode, - &memory_size_stipend_for_kernel, + versioned_byte_is_evm_bytecode, + &memory_size_stipend_for_evm, &memory_size_stipend_for_userspace, ); let memory_stipend = UInt32::conditionally_select( cs, - versioned_byte_is_evm_bytecode, - &memory_size_stipend_for_evm, - &memory_stipend, + new_callstack_entry.is_kernel_mode, + &memory_size_stipend_for_kernel, + &memory_size_stipend_for_userspace, ); new_callstack_entry.heap_upper_bound = memory_stipend;