Skip to content

Commit 36580c6

Browse files
committed
core/vm: Fail account creation in case nonce overflows 64 bit
Required by EIP-2681: Limit account nonce to 2^64-1
1 parent 5cee33e commit 36580c6

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

core/vm/errors.go

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

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

core/vm/evm.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,9 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
387387
return nil, common.Address{}, gas, ErrInsufficientBalance
388388
}
389389
nonce := evm.StateDB.GetNonce(caller.Address())
390+
if nonce+1 < nonce {
391+
return nil, common.Address{}, gas, ErrNonceUintOverflow
392+
}
390393
evm.StateDB.SetNonce(caller.Address(), nonce+1)
391394
// We add this to the access list _before_ taking a snapshot. Even if the creation fails,
392395
// the access-list change should not be rolled back

0 commit comments

Comments
 (0)