From f1341e5bf2dc59ea10c19012257c7e386cfc195f Mon Sep 17 00:00:00 2001 From: Zhang Zhuo Date: Tue, 15 Aug 2023 07:24:04 +0800 Subject: [PATCH] fix LastCalleeId for call empty --- bus-mapping/src/evm/opcodes/callop.rs | 4 ++-- zkevm-circuits/src/evm_circuit/execution/callop.rs | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/bus-mapping/src/evm/opcodes/callop.rs b/bus-mapping/src/evm/opcodes/callop.rs index e06246e194..499c48361c 100644 --- a/bus-mapping/src/evm/opcodes/callop.rs +++ b/bus-mapping/src/evm/opcodes/callop.rs @@ -489,7 +489,7 @@ impl Opcode for CallOpcode { // 2. Call to account with empty code. (false, _, true) => { for (field, value) in [ - (CallContextField::LastCalleeId, 0.into()), + (CallContextField::LastCalleeId, call.call_id.into()), (CallContextField::LastCalleeReturnDataOffset, 0.into()), (CallContextField::LastCalleeReturnDataLength, 0.into()), ] { @@ -587,7 +587,7 @@ impl Opcode for CallOpcode { // 4. insufficient balance or error depth cases. (true, _, _) => { for (field, value) in [ - (CallContextField::LastCalleeId, 0.into()), + (CallContextField::LastCalleeId, call.call_id.into()), (CallContextField::LastCalleeReturnDataOffset, 0.into()), (CallContextField::LastCalleeReturnDataLength, 0.into()), ] { diff --git a/zkevm-circuits/src/evm_circuit/execution/callop.rs b/zkevm-circuits/src/evm_circuit/execution/callop.rs index 3261802ea9..bd510197af 100644 --- a/zkevm-circuits/src/evm_circuit/execution/callop.rs +++ b/zkevm-circuits/src/evm_circuit/execution/callop.rs @@ -507,8 +507,13 @@ impl ExecutionGadget for CallOpGadget { ]), |cb| { // Save caller's call state - for field_tag in [ + cb.call_context_lookup( + true.expr(), + None, CallContextFieldTag::LastCalleeId, + callee_call_id.expr(), + ); + for field_tag in [ CallContextFieldTag::LastCalleeReturnDataOffset, CallContextFieldTag::LastCalleeReturnDataLength, ] { @@ -558,8 +563,13 @@ impl ExecutionGadget for CallOpGadget { // handle ErrDepth or ErrInsufficientBalance step transition cb.condition(not::expr(is_precheck_ok.expr()), |cb| { // Save caller's call state - for field_tag in [ + cb.call_context_lookup( + true.expr(), + None, CallContextFieldTag::LastCalleeId, + callee_call_id.expr(), + ); + for field_tag in [ CallContextFieldTag::LastCalleeReturnDataOffset, CallContextFieldTag::LastCalleeReturnDataLength, ] {