Skip to content

Commit 6701c64

Browse files
veoxcburgdorf
authored andcommitted
eth/vm/state: recurse collect_touched_accounts() always, unless computation had error.
Previously, "nested" computations would be recursed into even if they had an error; whereas "origin" computation would be recursed into on success only. This commit effectively makes so that "nested" comp-ns will be recursed into only if they are successful (that is, same logic as for "origin" comp-n). The rest of the changes are comments, heredoc brush-ups, and similar fluff from the debugging session.
1 parent 2bf83c0 commit 6701c64

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

eth/vm/forks/spurious_dragon/_utils.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,18 @@
1717
@to_set
1818
def collect_touched_accounts(computation: BaseComputation) -> Iterable[bytes]:
1919
"""
20-
Collect all of the accounts that *may* need to be deleted based on EIP161:
20+
Collect all of the accounts that *may* need to be deleted based on
21+
`EIP-161 <https://eips.ethereum.org/EIPS/eip-161>`_.
2122
22-
https://github.com/ethereum/EIPs/blob/master/EIPS/eip-161.md
23+
Checking whether they *do* need to be deleted happens in the caller.
2324
24-
also see: https://github.com/ethereum/EIPs/issues/716
25+
See also: https://github.com/ethereum/EIPs/issues/716
2526
"""
27+
# collect the coinbase account if it was touched via zero-fee transfer
2628
if computation.is_origin_computation and computation.transaction_context.gas_price == 0:
2729
yield computation.state.coinbase
2830

31+
# collect those explicitly marked for deletion ("beneficiary" is of SELFDESTRUCT)
2932
for beneficiary in sorted(set(computation.accounts_to_delete.values())):
3033
if computation.is_error and computation.is_origin_computation:
3134
# Special case to account for geth+parity bug
@@ -36,6 +39,7 @@ def collect_touched_accounts(computation: BaseComputation) -> Iterable[bytes]:
3639
else:
3740
yield beneficiary
3841

42+
# collect account directly addressed
3943
if computation.msg.to != constants.CREATE_CONTRACT_ADDRESS:
4044
if computation.is_error and computation.is_origin_computation:
4145
# Special case to account for geth+parity bug
@@ -45,6 +49,7 @@ def collect_touched_accounts(computation: BaseComputation) -> Iterable[bytes]:
4549
else:
4650
yield computation.msg.to
4751

48-
if not computation.is_origin_computation or not computation.is_error:
52+
# recurse into nested computations if this one was successful
53+
if not computation.is_error:
4954
for child in computation.children:
5055
yield from collect_touched_accounts(child)

tests/conftest.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# from eth._utils.logging import DEBUG2_LEVEL_NUM
2-
31
import pytest
42

53
from eth_utils import (
@@ -31,7 +29,7 @@
3129
import datetime
3230
import logging
3331
import os
34-
from eth.tools.logging import TRACE_LEVEL_NUM
32+
from eth.tools.logging import DEBUG2_LEVEL_NUM
3533
3634
@pytest.yield_fixture(autouse=True)
3735
def _file_logging(request):

0 commit comments

Comments
 (0)