Skip to content

Commit 1f45af0

Browse files
committed
core/vm: implement EIP 3541 (ethereum#22809)
1 parent c47819c commit 1f45af0

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

core/vm/errors.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ var (
3535
ErrReturnDataOutOfBounds = errors.New("return data out of bounds")
3636
ErrGasUintOverflow = errors.New("gas uint64 overflow")
3737
ErrNonceUintOverflow = errors.New("nonce uint64 overflow")
38+
ErrInvalidCode = errors.New("invalid code: must not begin with 0xef")
3839

3940
// errStopToken is an internal token indicating interpreter loop termination,
4041
// never returned to outside callers.
41-
errStopToken = errors.New("stop token")
42+
errStopToken = errors.New("stop token")
4243
)
4344

4445
// ErrStackUnderflow wraps an evm error when the items on the stack less

core/vm/evm.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,11 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
486486
err = ErrMaxCodeSizeExceeded
487487
}
488488

489+
// Reject code starting with 0xEF if EIP-3541 is enabled.
490+
if err == nil && len(ret) >= 1 && ret[0] == 0xEF && evm.chainRules.IsEIP1559 {
491+
err = ErrInvalidCode
492+
}
493+
489494
// if the contract creation ran successfully and no errors were returned
490495
// calculate the gas required to store the code. If the code could not
491496
// be stored due to not enough gas set an error and let it be handled

0 commit comments

Comments
 (0)