Skip to content

Commit

Permalink
fix LastCalleeId for call empty
Browse files Browse the repository at this point in the history
  • Loading branch information
lispc committed Aug 14, 2023
1 parent 30e2b78 commit f1341e5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions bus-mapping/src/evm/opcodes/callop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ impl<const N_ARGS: usize> Opcode for CallOpcode<N_ARGS> {
// 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()),
] {
Expand Down Expand Up @@ -587,7 +587,7 @@ impl<const N_ARGS: usize> Opcode for CallOpcode<N_ARGS> {
// 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()),
] {
Expand Down
14 changes: 12 additions & 2 deletions zkevm-circuits/src/evm_circuit/execution/callop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,13 @@ impl<F: Field> ExecutionGadget<F> for CallOpGadget<F> {
]),
|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,
] {
Expand Down Expand Up @@ -558,8 +563,13 @@ impl<F: Field> ExecutionGadget<F> for CallOpGadget<F> {
// 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,
] {
Expand Down

0 comments on commit f1341e5

Please sign in to comment.