Skip to content

Commit

Permalink
Fix contract call reversion (#709)
Browse files Browse the repository at this point in the history
* Add checkpointing for contract reversion

* Comment
  • Loading branch information
Nashtare authored Oct 8, 2024
1 parent 5c703ce commit 4c8035e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion evm_arithmetization/src/cpu/kernel/asm/core/call.asm
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ global sys_callcode:
(new_ctx, args_offset, args_size, new_ctx, kexit_info, callgas, address, value, args_offset, args_size, ret_offset, ret_size)
%copy_mem_to_calldata
// stack: new_ctx, kexit_info, callgas, address, value, args_offset, args_size, ret_offset, ret_size
DUP5 %address %address %transfer_eth %jumpi(call_insufficient_balance)
DUP5 %address DUP1 %transfer_eth %jumpi(call_insufficient_balance)
// stack: new_ctx, kexit_info, callgas, address, value, args_offset, args_size, ret_offset, ret_size
DUP3 %set_new_ctx_gas_limit
// stack: new_ctx, kexit_info, callgas, address, value, args_offset, args_size, ret_offset, ret_size
Expand Down
7 changes: 6 additions & 1 deletion evm_arithmetization/src/cpu/kernel/asm/core/process_txn.asm
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ global process_message_txn:
// stack: code_empty, retdest
%jumpi(process_message_txn_return)

%checkpoint

// Otherwise, load to's code and execute it in a new context.
// stack: retdest
%create_context
Expand Down Expand Up @@ -321,7 +323,10 @@ process_message_txn_after_call_contd:

process_message_txn_fail:
// stack: leftover_gas, new_ctx, retdest, success, leftover_gas
// Transfer value back to the caller.

// Revert txn execution, then transfer value back to the caller.
%revert_checkpoint

%mload_txn_field(@TXN_FIELD_VALUE) ISZERO %jumpi(process_message_txn_after_call_contd)
%mload_txn_field(@TXN_FIELD_VALUE)
%mload_txn_field(@TXN_FIELD_ORIGIN)
Expand Down

0 comments on commit 4c8035e

Please sign in to comment.