mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-02-03 07:45:18 +00:00
s/increaseBalance/addBalance
This commit is contained in:
parent
75f973e654
commit
0adfaf0f31
@ -61,9 +61,6 @@ proc setBalance*(db: var AccountStateDB, address: EthAddress, balance: UInt256)
|
|||||||
account.balance = balance
|
account.balance = balance
|
||||||
db.setAccount(address, account)
|
db.setAccount(address, account)
|
||||||
|
|
||||||
proc increaseBalance*(db: var AccountStateDB, address: EthAddress, delta: UInt256) =
|
|
||||||
db.setBalance(address, db.getBalance(address) + delta)
|
|
||||||
|
|
||||||
proc addBalance*(db: var AccountStateDB, address: EthAddress, delta: UInt256) =
|
proc addBalance*(db: var AccountStateDB, address: EthAddress, delta: UInt256) =
|
||||||
db.setBalance(address, db.getBalance(address) + delta)
|
db.setBalance(address, db.getBalance(address) + delta)
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ proc applyMessage(computation: var BaseComputation) =
|
|||||||
|
|
||||||
computation.vmState.mutateStateDb:
|
computation.vmState.mutateStateDb:
|
||||||
db.setBalance(computation.msg.sender, db.getBalance(computation.msg.sender) - computation.msg.value)
|
db.setBalance(computation.msg.sender, db.getBalance(computation.msg.sender) - computation.msg.value)
|
||||||
db.increaseBalance(computation.msg.storage_address, computation.msg.value)
|
db.addBalance(computation.msg.storage_address, computation.msg.value)
|
||||||
|
|
||||||
debug "Apply message",
|
debug "Apply message",
|
||||||
value = computation.msg.value,
|
value = computation.msg.value,
|
||||||
|
@ -72,7 +72,7 @@ proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus) =
|
|||||||
vmState.mutateStateDb:
|
vmState.mutateStateDb:
|
||||||
# pre-EIP158 (e.g., Byzantium, should ensure currentCoinbase exists)
|
# pre-EIP158 (e.g., Byzantium, should ensure currentCoinbase exists)
|
||||||
# but in later forks, don't create at all
|
# but in later forks, don't create at all
|
||||||
db.increaseBalance(currentCoinbase, 0.u256)
|
db.addBalance(currentCoinbase, 0.u256)
|
||||||
|
|
||||||
# FIXME: don't repeat this code
|
# FIXME: don't repeat this code
|
||||||
# TODO: iterate over all fixture indexes
|
# TODO: iterate over all fixture indexes
|
||||||
@ -92,7 +92,7 @@ proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus) =
|
|||||||
# Also, in general, map out/etc the whole vmState.mutateStateDB flow set
|
# Also, in general, map out/etc the whole vmState.mutateStateDB flow set
|
||||||
db.setBalance(sender, db.getBalance(sender) - gas_cost)
|
db.setBalance(sender, db.getBalance(sender) - gas_cost)
|
||||||
db.setNonce(sender, db.getNonce(sender) + 1)
|
db.setNonce(sender, db.getNonce(sender) + 1)
|
||||||
db.increaseBalance(transaction.to, transaction.value)
|
db.addBalance(transaction.to, transaction.value)
|
||||||
db.setBalance(sender, db.getBalance(sender) - transaction.value)
|
db.setBalance(sender, db.getBalance(sender) - transaction.value)
|
||||||
|
|
||||||
# build_message (Py-EVM)
|
# build_message (Py-EVM)
|
||||||
@ -139,8 +139,8 @@ proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus) =
|
|||||||
vmState.mutateStateDB:
|
vmState.mutateStateDB:
|
||||||
if currentCoinbase notin deletedAccounts:
|
if currentCoinbase notin deletedAccounts:
|
||||||
db.setBalance(currentCoinbase, db.getBalance(currentCoinbase) - gasRefundAmount)
|
db.setBalance(currentCoinbase, db.getBalance(currentCoinbase) - gasRefundAmount)
|
||||||
db.increaseBalance(currentCoinbase, gas_cost)
|
db.addBalance(currentCoinbase, gas_cost)
|
||||||
db.increaseBalance(sender, gasRefundAmount)
|
db.addBalance(sender, gasRefundAmount)
|
||||||
# TODO: only here does one commit, with some nuance/caveat
|
# TODO: only here does one commit, with some nuance/caveat
|
||||||
else:
|
else:
|
||||||
# XXX: both error paths are intentionally indentical, for merging, with refactoring
|
# XXX: both error paths are intentionally indentical, for merging, with refactoring
|
||||||
@ -148,17 +148,17 @@ proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus) =
|
|||||||
vmState.mutateStateDB:
|
vmState.mutateStateDB:
|
||||||
# XXX: the coinbase has to be committed; the rest are basically reverts
|
# XXX: the coinbase has to be committed; the rest are basically reverts
|
||||||
db.setBalance(transaction.to, db.getBalance(transaction.to) - transaction.value)
|
db.setBalance(transaction.to, db.getBalance(transaction.to) - transaction.value)
|
||||||
db.increaseBalance(sender, transaction.value)
|
db.addBalance(sender, transaction.value)
|
||||||
db.setStorageRoot(transaction.to, storageRoot)
|
db.setStorageRoot(transaction.to, storageRoot)
|
||||||
db.increaseBalance(currentCoinbase, gas_cost)
|
db.addBalance(currentCoinbase, gas_cost)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# TODO: replace with transactional commit/revert state (foo.revert or implicit)
|
# TODO: replace with transactional commit/revert state (foo.revert or implicit)
|
||||||
vmState.mutateStateDB:
|
vmState.mutateStateDB:
|
||||||
# XXX: the coinbase has to be committed; the rest are basically reverts
|
# XXX: the coinbase has to be committed; the rest are basically reverts
|
||||||
db.setBalance(transaction.to, db.getBalance(transaction.to) - transaction.value)
|
db.setBalance(transaction.to, db.getBalance(transaction.to) - transaction.value)
|
||||||
db.increaseBalance(sender, transaction.value)
|
db.addBalance(sender, transaction.value)
|
||||||
db.setStorageRoot(transaction.to, storageRoot)
|
db.setStorageRoot(transaction.to, storageRoot)
|
||||||
db.increaseBalance(currentCoinbase, gas_cost)
|
db.addBalance(currentCoinbase, gas_cost)
|
||||||
|
|
||||||
#echo vmState.readOnlyStateDB.dumpAccount("b94f5374fce5edbc8e2a8697c15331677e6ebf0b")
|
#echo vmState.readOnlyStateDB.dumpAccount("b94f5374fce5edbc8e2a8697c15331677e6ebf0b")
|
||||||
#echo vmState.readOnlyStateDB.dumpAccount("a94f5374fce5edbc8e2a8697c15331677e6ebf0b")
|
#echo vmState.readOnlyStateDB.dumpAccount("a94f5374fce5edbc8e2a8697c15331677e6ebf0b")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user