diff --git a/blockchain-tests-skip.yml b/blockchain-tests-skip.yml index cb3b012f8..dfab4ee5d 100644 --- a/blockchain-tests-skip.yml +++ b/blockchain-tests-skip.yml @@ -49,10 +49,6 @@ testname: - create2collisionStorage_d1g0v0_Shanghai - create2collisionStorage_d2g0v0_Shanghai stCreateTest: - - CreateAddressWarmAfterFail_d11g0v1_Shanghai - - CreateAddressWarmAfterFail_d12g0v1_Shanghai - - CreateAddressWarmAfterFail_d2g0v1_Shanghai - - CreateAddressWarmAfterFail_d3g0v1_Shanghai - CreateOOGafterMaxCodesize_d2g0v0_Shanghai - CreateOOGafterMaxCodesize_d3g0v0_Shanghai - CreateOOGafterMaxCodesize_d5g0v0_Shanghai diff --git a/src/kakarot/instructions/system_operations.cairo b/src/kakarot/instructions/system_operations.cairo index e7d79bd06..272da22f4 100644 --- a/src/kakarot/instructions/system_operations.cairo +++ b/src/kakarot/instructions/system_operations.cairo @@ -79,11 +79,14 @@ namespace SystemOperations { let (bytecode: felt*) = alloc(); Memory.load_n(size.low, bytecode, offset.low); - // Get target address let target_address = CreateHelper.get_evm_address( evm.message.address.evm, popped_len, popped, size.low, bytecode ); + // @dev: performed before eventual subsequent early-returns of this function + // to mark the account as warm EIP-2929 + let target_account = State.get_account(target_address); + // Get message call gas let (gas_limit, _) = unsigned_div_rem(evm.gas_left, 64); let gas_limit = evm.gas_left - gas_limit; @@ -95,11 +98,6 @@ namespace SystemOperations { return evm; } - // TODO: Clear return data - // @dev: performed before eventual early-returns of this function - // to mark the account as warm - let target_account = State.get_account(target_address); - // Check sender balance and nonce let sender = State.get_account(evm.message.address.evm); let is_nonce_overflow = Helpers.is_zero(Constants.MAX_NONCE - sender.nonce); @@ -878,6 +876,14 @@ namespace CallHelper { let is_reverted = is_not_zero(evm.reverted); Stack.push_uint128(1 - is_reverted); + // Restore parent state if the call has reverted + if (evm.reverted != FALSE) { + tempvar state = evm.message.parent.state; + } else { + tempvar state = state; + } + let state = cast([ap - 1], model.State*); + if (evm.reverted == Errors.EXCEPTIONAL_HALT) { // If the call has halted exceptionnaly, the return_data is empty // and nothing is copied to memory, and the gas is not returned; @@ -1050,6 +1056,7 @@ namespace CreateHelper { } // @notice At the end of a sub-context initiated with CREATE or CREATE2, the calling context's stack is updated. + // @dev Restores the parent state if the sub-context has reverted. // @param evm The pointer to the calling context. // @return EVM The pointer to the updated calling context. func finalize_parent{ @@ -1074,6 +1081,9 @@ namespace CreateHelper { tempvar stack_code = new Uint256(low=0, high=0); Stack.push(stack_code); + + tempvar state = evm.message.parent.state; + tempvar evm = new model.EVM( message=evm.message.parent.evm.message, return_data_len=return_data_len, @@ -1107,6 +1117,8 @@ namespace CreateHelper { Stack.push(address); if (success == FALSE) { + tempvar state = evm.message.parent.state; + tempvar evm = new model.EVM( message=evm.message.parent.evm.message, return_data_len=0, diff --git a/src/kakarot/interpreter.cairo b/src/kakarot/interpreter.cairo index b7859b763..0c829990f 100644 --- a/src/kakarot/interpreter.cairo +++ b/src/kakarot/interpreter.cairo @@ -710,11 +710,6 @@ namespace Interpreter { let stack = evm.message.parent.stack; let memory = evm.message.parent.memory; - if (evm.reverted == FALSE) { - tempvar state = state; - } else { - tempvar state = evm.message.parent.state; - } if (evm.message.is_create != FALSE) { let evm = CreateHelper.finalize_parent(evm);