mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-12 21:34:33 +00:00
refactor incNonce
This commit is contained in:
parent
2c032ad1ab
commit
200f93a3b7
@ -156,6 +156,9 @@ proc getNonce*(db: AccountStateDB, address: EthAddress): AccountNonce =
|
||||
let account = db.getAccount(address)
|
||||
account.nonce
|
||||
|
||||
proc incNonce*(db: AccountStateDB, address: EthAddress) {.inline.} =
|
||||
db.setNonce(address, db.getNonce(address) + 1)
|
||||
|
||||
proc setCode*(db: AccountStateDB, address: EthAddress, code: ByteRange) =
|
||||
var account = db.getAccount(address)
|
||||
# TODO: implement JournalDB to store code and storage
|
||||
|
@ -57,7 +57,7 @@ proc processTransaction*(t: Transaction, sender: EthAddress, vmState: BaseVMStat
|
||||
trace "txHash", rlpHash = t.rlpHash
|
||||
var db = vmState.accountDb
|
||||
# Inct nonce:
|
||||
db.setNonce(sender, db.getNonce(sender) + 1)
|
||||
db.incNonce(sender)
|
||||
var transactionFailed = false
|
||||
|
||||
#t.dump
|
||||
|
@ -47,10 +47,10 @@ proc testFixtureIndexes(prevStateRoot: Hash256, header: BlockHeader, pre: JsonNo
|
||||
var readOnly = vmState.readOnlyStateDB
|
||||
let storageRoot = readOnly.getStorageRoot(transaction.to)
|
||||
|
||||
let gas_cost = transaction.gasLimit.u256 * transaction.gasPrice.u256
|
||||
let gasCost = transaction.gasLimit.u256 * transaction.gasPrice.u256
|
||||
vmState.mutateStateDB:
|
||||
db.setNonce(sender, db.getNonce(sender) + 1)
|
||||
db.subBalance(sender, transaction.value + gas_cost)
|
||||
db.incNonce(sender)
|
||||
db.subBalance(sender, transaction.value + gasCost)
|
||||
|
||||
if transaction.isContractCreation and transaction.payload.len > 0:
|
||||
vmState.mutateStateDB:
|
||||
@ -82,7 +82,7 @@ proc testFixtureIndexes(prevStateRoot: Hash256, header: BlockHeader, pre: JsonNo
|
||||
# that would simplify/combine codepaths
|
||||
if header.coinbase notin computation.getAccountsForDeletion:
|
||||
db.subBalance(header.coinbase, gasRefundAmount)
|
||||
db.addBalance(header.coinbase, gas_cost)
|
||||
db.addBalance(header.coinbase, gasCost)
|
||||
db.addBalance(sender, gasRefundAmount)
|
||||
# TODO: only here does one commit, with some nuance/caveat
|
||||
else:
|
||||
@ -91,7 +91,7 @@ proc testFixtureIndexes(prevStateRoot: Hash256, header: BlockHeader, pre: JsonNo
|
||||
db.subBalance(transaction.to, transaction.value)
|
||||
db.addBalance(sender, transaction.value)
|
||||
db.setStorageRoot(transaction.to, storageRoot)
|
||||
db.addBalance(header.coinbase, gas_cost)
|
||||
db.addBalance(header.coinbase, gasCost)
|
||||
|
||||
proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus) =
|
||||
var fixture: JsonNode
|
||||
|
Loading…
x
Reference in New Issue
Block a user