diff --git a/core/vm/errors.go b/core/vm/errors.go index a1e8adf49ef0..02ce2a678b34 100644 --- a/core/vm/errors.go +++ b/core/vm/errors.go @@ -35,10 +35,11 @@ var ( ErrReturnDataOutOfBounds = errors.New("return data out of bounds") ErrGasUintOverflow = errors.New("gas uint64 overflow") ErrNonceUintOverflow = errors.New("nonce uint64 overflow") + ErrInvalidCode = errors.New("invalid code: must not begin with 0xef") // errStopToken is an internal token indicating interpreter loop termination, // never returned to outside callers. - errStopToken = errors.New("stop token") + errStopToken = errors.New("stop token") ) // ErrStackUnderflow wraps an evm error when the items on the stack less diff --git a/core/vm/evm.go b/core/vm/evm.go index 18b132b1809b..4f61fc3c80a0 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -486,6 +486,11 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64, err = ErrMaxCodeSizeExceeded } + // Reject code starting with 0xEF if EIP-3541 is enabled. + if err == nil && len(ret) >= 1 && ret[0] == 0xEF && evm.chainRules.IsEIP1559 { + err = ErrInvalidCode + } + // if the contract creation ran successfully and no errors were returned // calculate the gas required to store the code. If the code could not // be stored due to not enough gas set an error and let it be handled