Skip to content

Commit

Permalink
core/vm: implement EIP 3541 (ethereum#22809)
Browse files Browse the repository at this point in the history
  • Loading branch information
gzliudan committed Aug 26, 2024
1 parent c47819c commit 1f45af0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/vm/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1f45af0

Please sign in to comment.