mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-23 18:49:57 +00:00
Don't touch nonce until after address in-use check
This commit is contained in:
parent
555687ba97
commit
ca6eb0cb38
@ -546,22 +546,21 @@ op create, inline = false, value, startPosition, size:
|
|||||||
|
|
||||||
## TODO dynamic gas that depends on remaining gas
|
## TODO dynamic gas that depends on remaining gas
|
||||||
|
|
||||||
var
|
let
|
||||||
contractAddress: EthAddress
|
readOnlyState = computation.vmState.readOnlyStateDB
|
||||||
isCollision: bool
|
creationNonce = readOnlyState.getNonce(computation.msg.storageAddress)
|
||||||
|
|
||||||
computation.vmState.mutateStateDB:
|
|
||||||
let creationNonce = db.getNonce(computation.msg.storageAddress)
|
|
||||||
db.setNonce(computation.msg.storageAddress, creationNonce + 1)
|
|
||||||
|
|
||||||
contractAddress = generateAddress(computation.msg.storageAddress, creationNonce)
|
contractAddress = generateAddress(computation.msg.storageAddress, creationNonce)
|
||||||
# Regarding collisions, see: https://github.com/status-im/nimbus/issues/133
|
isCollision = readOnlyState.hasCodeOrNonce(contractAddress)
|
||||||
isCollision = db.hasCodeOrNonce(contractAddress)
|
|
||||||
|
|
||||||
if isCollision:
|
# Regarding collisions, see: https://github.com/status-im/nimbus/issues/133
|
||||||
|
# See: https://github.com/ethereum/EIPs/issues/684
|
||||||
|
if not isCollision:
|
||||||
|
computation.vmState.mutateStateDB:
|
||||||
|
db.setNonce(computation.msg.storageAddress, creationNonce + 1)
|
||||||
|
else:
|
||||||
debug("Address collision while creating contract", address = contractAddress.toHex)
|
debug("Address collision while creating contract", address = contractAddress.toHex)
|
||||||
push: 0
|
push: 0
|
||||||
return
|
raise newException(ValidationError, "Contract address already exists and is in use")
|
||||||
|
|
||||||
let childMsg = prepareChildMessage(
|
let childMsg = prepareChildMessage(
|
||||||
computation,
|
computation,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user