mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-13 13:55:45 +00:00
fix create contract address collision, GST +1
This commit is contained in:
parent
4383831772
commit
cd765bf452
@ -186,14 +186,14 @@ OK: 50/79 Fail: 0/79 Skip: 29/79
|
|||||||
createInitFailUndefinedInstruction.json Skip
|
createInitFailUndefinedInstruction.json Skip
|
||||||
+ createInitFail_OOGduringInit.json OK
|
+ createInitFail_OOGduringInit.json OK
|
||||||
+ createInitOOGforCREATE.json OK
|
+ createInitOOGforCREATE.json OK
|
||||||
createJS_ExampleContract.json Skip
|
+ createJS_ExampleContract.json OK
|
||||||
+ createJS_NoCollision.json OK
|
+ createJS_NoCollision.json OK
|
||||||
+ createNameRegistratorPerTxs.json OK
|
+ createNameRegistratorPerTxs.json OK
|
||||||
+ createNameRegistratorPerTxsNotEnoughGas.json OK
|
+ createNameRegistratorPerTxsNotEnoughGas.json OK
|
||||||
+ createNameRegistratorPreStore1NotEnoughGas.json OK
|
+ createNameRegistratorPreStore1NotEnoughGas.json OK
|
||||||
+ createNameRegistratorendowmentTooHigh.json OK
|
+ createNameRegistratorendowmentTooHigh.json OK
|
||||||
```
|
```
|
||||||
OK: 18/39 Fail: 0/39 Skip: 21/39
|
OK: 19/39 Fail: 0/39 Skip: 20/39
|
||||||
## stCallDelegateCodesCallCodeHomestead
|
## stCallDelegateCodesCallCodeHomestead
|
||||||
```diff
|
```diff
|
||||||
callcallcallcode_001.json Skip
|
callcallcallcode_001.json Skip
|
||||||
@ -2520,4 +2520,4 @@ OK: 0/133 Fail: 0/133 Skip: 133/133
|
|||||||
OK: 0/130 Fail: 0/130 Skip: 130/130
|
OK: 0/130 Fail: 0/130 Skip: 130/130
|
||||||
|
|
||||||
---TOTAL---
|
---TOTAL---
|
||||||
OK: 1309/2334 Fail: 0/2334 Skip: 1025/2334
|
OK: 1310/2334 Fail: 0/2334 Skip: 1024/2334
|
||||||
|
@ -29,17 +29,23 @@ proc processTransaction*(tx: Transaction, sender: EthAddress, vmState: BaseVMSta
|
|||||||
if balance < upfrontGasCost:
|
if balance < upfrontGasCost:
|
||||||
return tx.gasLimit
|
return tx.gasLimit
|
||||||
|
|
||||||
var computation = setupComputation(vmState, tx, sender, forkOverride)
|
let recipient = tx.getRecipient()
|
||||||
|
let isCollision = vmState.readOnlyStateDb().hasCodeOrNonce(recipient)
|
||||||
|
|
||||||
|
var computation = setupComputation(vmState, tx, sender, recipient, forkOverride)
|
||||||
if computation.isNil:
|
if computation.isNil:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
vmState.mutateStateDB:
|
vmState.mutateStateDB:
|
||||||
db.incNonce(sender)
|
db.incNonce(sender)
|
||||||
db.subBalance(sender, upfrontGasCost)
|
db.subBalance(sender, upfrontGasCost)
|
||||||
|
|
||||||
|
if tx.isContractCreation and isCollision:
|
||||||
|
return tx.gasLimit
|
||||||
|
|
||||||
var snapshot = vmState.snapshot()
|
var snapshot = vmState.snapshot()
|
||||||
defer: snapshot.dispose()
|
defer: snapshot.dispose()
|
||||||
|
|
||||||
var contractOK = true
|
var contractOK = true
|
||||||
result = tx.gasLimit
|
result = tx.gasLimit
|
||||||
|
|
||||||
|
@ -35,11 +35,13 @@ template balance(addressDb: ReadOnlyStateDb, address: EthAddress): GasInt =
|
|||||||
|
|
||||||
proc binarySearchGas(vmState: var BaseVMState, transaction: Transaction, sender: EthAddress, gasPrice: GasInt, tolerance = 1): GasInt =
|
proc binarySearchGas(vmState: var BaseVMState, transaction: Transaction, sender: EthAddress, gasPrice: GasInt, tolerance = 1): GasInt =
|
||||||
proc dummyComputation(vmState: var BaseVMState, transaction: Transaction, sender: EthAddress): BaseComputation =
|
proc dummyComputation(vmState: var BaseVMState, transaction: Transaction, sender: EthAddress): BaseComputation =
|
||||||
|
let recipient = transaction.getRecipient()
|
||||||
# Note that vmState may be altered
|
# Note that vmState may be altered
|
||||||
setupComputation(
|
setupComputation(
|
||||||
vmState,
|
vmState,
|
||||||
transaction,
|
transaction,
|
||||||
sender)
|
sender,
|
||||||
|
recipient)
|
||||||
|
|
||||||
proc dummyTransaction(gasLimit, gasPrice: GasInt, destination: EthAddress, value: UInt256): Transaction =
|
proc dummyTransaction(gasLimit, gasPrice: GasInt, destination: EthAddress, value: UInt256): Transaction =
|
||||||
Transaction(
|
Transaction(
|
||||||
|
@ -24,14 +24,13 @@ proc validateTransaction*(vmState: BaseVMState, transaction: Transaction, sender
|
|||||||
transaction.accountNonce == readOnlyDB.getNonce(sender) and
|
transaction.accountNonce == readOnlyDB.getNonce(sender) and
|
||||||
readOnlyDB.getBalance(sender) >= gasCost
|
readOnlyDB.getBalance(sender) >= gasCost
|
||||||
|
|
||||||
proc setupComputation*(vmState: BaseVMState, tx: Transaction, sender: EthAddress, forkOverride=none(Fork)) : BaseComputation =
|
proc setupComputation*(vmState: BaseVMState, tx: Transaction, sender, recipient: EthAddress, forkOverride=none(Fork)) : BaseComputation =
|
||||||
let fork =
|
let fork =
|
||||||
if forkOverride.isSome:
|
if forkOverride.isSome:
|
||||||
forkOverride.get
|
forkOverride.get
|
||||||
else:
|
else:
|
||||||
vmState.blockNumber.toFork
|
vmState.blockNumber.toFork
|
||||||
|
|
||||||
var recipient: EthAddress
|
|
||||||
var gas = tx.gasLimit - tx.intrinsicGas
|
var gas = tx.gasLimit - tx.intrinsicGas
|
||||||
|
|
||||||
# TODO: refactor message to use byterange
|
# TODO: refactor message to use byterange
|
||||||
@ -39,12 +38,10 @@ proc setupComputation*(vmState: BaseVMState, tx: Transaction, sender: EthAddress
|
|||||||
var data, code: seq[byte]
|
var data, code: seq[byte]
|
||||||
|
|
||||||
if tx.isContractCreation:
|
if tx.isContractCreation:
|
||||||
recipient = generateAddress(sender, tx.accountNonce)
|
|
||||||
gas = gas - gasFees[fork][GasTXCreate]
|
gas = gas - gasFees[fork][GasTXCreate]
|
||||||
data = @[]
|
data = @[]
|
||||||
code = tx.payload
|
code = tx.payload
|
||||||
else:
|
else:
|
||||||
recipient = tx.to
|
|
||||||
data = tx.payload
|
data = tx.payload
|
||||||
code = vmState.readOnlyStateDB.getCode(tx.to).toSeq
|
code = vmState.readOnlyStateDB.getCode(tx.to).toSeq
|
||||||
|
|
||||||
|
@ -78,8 +78,7 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool =
|
|||||||
"callcodecallcallcode_ABCB_RECURSIVE.json",
|
"callcodecallcallcode_ABCB_RECURSIVE.json",
|
||||||
"callcodecallcodecall_ABCB_RECURSIVE.json",
|
"callcodecallcodecall_ABCB_RECURSIVE.json",
|
||||||
"callcodecallcodecallcode_ABCB_RECURSIVE.json",
|
"callcodecallcodecallcode_ABCB_RECURSIVE.json",
|
||||||
# Frontier failed test cases
|
# Frontier failed test cases
|
||||||
"createJS_ExampleContract.json",
|
|
||||||
"callcallcallcode_001_OOGMAfter_1.json",
|
"callcallcallcode_001_OOGMAfter_1.json",
|
||||||
"callcallcallcode_001_OOGMAfter_2.json",
|
"callcallcallcode_001_OOGMAfter_2.json",
|
||||||
"createInitFailUndefinedInstruction.json",
|
"createInitFailUndefinedInstruction.json",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user