fix nonce overflow related to CREATE/CREATE2
if the caller nonce == u64.high, the contract creation cannot go on.
This commit is contained in:
parent
fcad04d9ff
commit
b4283aeb1f
|
@ -311,7 +311,11 @@ proc afterExecCall(c: Computation) =
|
|||
|
||||
proc beforeExecCreate(c: Computation): bool =
|
||||
c.vmState.mutateStateDB:
|
||||
db.incNonce(c.msg.sender)
|
||||
let nonce = db.getNonce(c.msg.sender)
|
||||
if nonce+1 < nonce:
|
||||
c.setError(&"Nonce overflow when sender={c.msg.sender.toHex} wants to create contract", false)
|
||||
return true
|
||||
db.setNonce(c.msg.sender, nonce+1)
|
||||
|
||||
# We add this to the access list _before_ taking a snapshot.
|
||||
# Even if the creation fails, the access-list change should not be rolled back
|
||||
|
@ -322,7 +326,7 @@ proc beforeExecCreate(c: Computation): bool =
|
|||
c.snapshot()
|
||||
|
||||
if c.vmState.readOnlyStateDb().hasCodeOrNonce(c.msg.contractAddress):
|
||||
c.setError("Address collision when creating contract address={c.msg.contractAddress.toHex}", true)
|
||||
c.setError(&"Address collision when creating contract address={c.msg.contractAddress.toHex}", true)
|
||||
c.rollback()
|
||||
return true
|
||||
|
||||
|
|
|
@ -131,7 +131,11 @@ proc afterExecCall(c: Computation) =
|
|||
|
||||
proc beforeExecCreate(c: Computation): bool =
|
||||
c.vmState.mutateStateDB:
|
||||
db.incNonce(c.msg.sender)
|
||||
let nonce = db.getNonce(c.msg.sender)
|
||||
if nonce+1 < nonce:
|
||||
c.setError(&"Nonce overflow when sender={c.msg.sender.toHex} wants to create contract", false)
|
||||
return true
|
||||
db.setNonce(c.msg.sender, nonce+1)
|
||||
|
||||
# We add this to the access list _before_ taking a snapshot.
|
||||
# Even if the creation fails, the access-list change should not be rolled
|
||||
|
|
Loading…
Reference in New Issue