diff --git a/evm/src/cpu/kernel/asm/core/create.asm b/evm/src/cpu/kernel/asm/core/create.asm index 5a942854..0bcddecf 100644 --- a/evm/src/cpu/kernel/asm/core/create.asm +++ b/evm/src/cpu/kernel/asm/core/create.asm @@ -137,9 +137,11 @@ after_constructor: // stack: new_ctx, leftover_gas, success, address, kexit_info POP - // TODO: EIP-3541: Reject new contract code starting with the 0xEF byte // TODO: Skip blocks below if success is false. + // EIP-3541: Reject new contract code starting with the 0xEF byte + PUSH 0 %mload_current(@SEGMENT_RETURNDATA) %eq_const(0xEF) %jumpi(fault_exception) + // Charge gas for the code size. SWAP3 // stack: kexit_info, success, address, leftover_gas diff --git a/evm/src/cpu/kernel/asm/core/process_txn.asm b/evm/src/cpu/kernel/asm/core/process_txn.asm index 6c466749..3e16bbd4 100644 --- a/evm/src/cpu/kernel/asm/core/process_txn.asm +++ b/evm/src/cpu/kernel/asm/core/process_txn.asm @@ -144,6 +144,10 @@ process_contract_creation_txn_after_code_loaded: global process_contract_creation_txn_after_constructor: // stack: success, leftover_gas, new_ctx, address, retdest POP // TODO: Success will go into the receipt when we support that. + + // EIP-3541: Reject new contract code starting with the 0xEF byte + PUSH 0 %mload_current(@SEGMENT_RETURNDATA) %eq_const(0xEF) %assert_zero // TODO: need to revert changes here. + // stack: leftover_gas, new_ctx, address, retdest %returndatasize // Size of the code. // stack: code_size, leftover_gas, new_ctx, address, retdest