ethereum / yellowpaper

The "Yellow Paper": Ethereum's formal specification
Creative Commons Attribution Share Alike 4.0 International
1.65k stars 511 forks source link

Incorrect production of "final state" #885

Open chfast opened 1 year ago

chfast commented 1 year ago

The (77) defines transaction's final state σ′ where both selfdestructed and empty-but-touched accounts are deleted. This is not how this is implemented in practice.

What YP suggests is the following workflow:

for tx in transactions:
    execute(state, tx)
    delete_selfdestructed(state)
    delete_empty_but_touched(state)

apply_coinbase_reward()
apply_withdrawals()

Practical implementations are done as the following:

for tx in transactions:
    execute(state, tx)
    delete_selfdestructed(state)

apply_coinbase_reward()
apply_withdrawals()
delete_empty_but_touched(state)

The difference is subtle: in case we apply 0 block reward or 0 withdrawal to an empty account this account will be deleted.