[skip ci] collectTouchedAccounts reduction

This commit is contained in:
andri lim 2020-01-09 13:51:54 +07:00 committed by zah
parent 20a138c270
commit 5e6018b20b
3 changed files with 10 additions and 18 deletions

View File

@ -13,9 +13,6 @@ proc processTransaction*(tx: Transaction, sender: EthAddress, vmState: BaseVMSta
trace "Sender", sender trace "Sender", sender
trace "txHash", rlpHash = tx.rlpHash trace "txHash", rlpHash = tx.rlpHash
if fork >= FkSpurious:
vmState.touchedAccounts.incl(vmState.blockHeader.coinbase)
var gasUsed = tx.gasLimit var gasUsed = tx.gasLimit
var coinBaseSuicide = false var coinBaseSuicide = false
@ -61,7 +58,9 @@ proc processTransaction*(tx: Transaction, sender: EthAddress, vmState: BaseVMSta
else: else:
db.addBalance(vmState.blockHeader.coinbase, 0.u256) db.addBalance(vmState.blockHeader.coinbase, 0.u256)
# EIP158 state clearing if fork >= FkSpurious:
vmState.touchedAccounts.incl(vmState.blockHeader.coinbase)
# EIP158/161 state clearing
for account in vmState.touchedAccounts: for account in vmState.touchedAccounts:
if db.accountExists(account) and db.isEmptyAccount(account): if db.accountExists(account) and db.isEmptyAccount(account):
debug "state clearing", account debug "state clearing", account

View File

@ -210,6 +210,7 @@ proc addChildComputation*(computation: BaseComputation, child: BaseComputation)
computation.logEntries.add child.logEntries computation.logEntries.add child.logEntries
computation.gasMeter.refundGas(child.gasMeter.gasRefunded) computation.gasMeter.refundGas(child.gasMeter.gasRefunded)
computation.suicides.incl child.suicides computation.suicides.incl child.suicides
computation.touchedAccounts.incl child.touchedAccounts
if not child.shouldBurnGas: if not child.shouldBurnGas:
computation.gasMeter.returnGas(child.gasMeter.gasRemaining) computation.gasMeter.returnGas(child.gasMeter.gasRemaining)
@ -258,16 +259,6 @@ proc collectTouchedAccounts*(c: BaseComputation, output: var HashSet[EthAddress]
let isIstanbul = c.getFork >= FkIstanbul let isIstanbul = c.getFork >= FkIstanbul
let condition = c.isError or ancestorHadError let condition = c.isError or ancestorHadError
for beneficiary in c.touchedAccounts:
if condition:
# Special case to account for geth+parity bug
# https://github.com/ethereum/EIPs/issues/716
if beneficiary.cmpThree:
output.incl beneficiary
continue
else:
output.incl beneficiary
if not c.msg.isCreate: if not c.msg.isCreate:
if condition: if condition:
# Special case to account for geth+parity bug # Special case to account for geth+parity bug

View File

@ -79,6 +79,8 @@ proc execComputation*(computation: var BaseComputation) =
if computation.getFork >= FkSpurious: if computation.getFork >= FkSpurious:
computation.collectTouchedAccounts(computation.vmState.touchedAccounts) computation.collectTouchedAccounts(computation.vmState.touchedAccounts)
if computation.isSuccess:
computation.vmState.touchedAccounts.incl computation.touchedAccounts
computation.vmstate.status = computation.isSuccess computation.vmstate.status = computation.isSuccess
if computation.isSuccess: if computation.isSuccess: