Skip to content

Commit 3a85f3d

Browse files
committed
refactor(spec-specs): Move net-zero filtering inside commit tx frame
1 parent dd3a353 commit 3a85f3d

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

src/ethereum/forks/amsterdam/fork.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -679,12 +679,9 @@ def process_system_transaction(
679679

680680
system_tx_output = process_message_call(system_tx_message)
681681

682-
# EIP-7928: Filter net-zero changes before committing to block frame.
683-
filter_net_zero_frame_changes(tx_env.state_changes, block_env.state)
684-
685682
# Commit system transaction changes to block frame
686683
# System transactions always succeed (or block is invalid)
687-
commit_transaction_frame(tx_env.state_changes)
684+
commit_transaction_frame(tx_env.state_changes, block_env.state)
688685

689686
return system_tx_output
690687

@@ -1095,11 +1092,9 @@ def process_transaction(
10951092
for address in tx_output.accounts_to_delete:
10961093
destroy_account(block_env.state, address)
10971094

1098-
# EIP-7928: Filter net-zero changes before committing to block frame.
1095+
# EIP-7928: Commit transaction frame (includes net-zero filtering).
10991096
# Must happen AFTER destroy_account so filtering sees correct state.
1100-
filter_net_zero_frame_changes(tx_env.state_changes, block_env.state)
1101-
1102-
commit_transaction_frame(tx_env.state_changes)
1097+
commit_transaction_frame(tx_env.state_changes, block_env.state)
11031098

11041099
# EIP-7928: Track in-transaction self-destruct normalization AFTER merge
11051100
# Convert storage writes to reads and remove nonce/code changes

src/ethereum/forks/amsterdam/state_tracker.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,22 +436,30 @@ def merge_on_failure(child_frame: StateChanges) -> None:
436436
# merged on failure - they are discarded
437437

438438

439-
def commit_transaction_frame(tx_frame: StateChanges) -> None:
439+
def commit_transaction_frame(
440+
tx_frame: StateChanges,
441+
state: "State",
442+
) -> None:
440443
"""
441444
Commit transaction frame to block frame.
442445
443-
Unlike merge_on_success(), this merges ALL changes without net-zero
444-
filtering (each tx's changes recorded at their respective index).
446+
Filters net-zero changes before merging to ensure only actual state
447+
modifications are recorded in the block access list.
445448
446449
Parameters
447450
----------
448451
tx_frame :
449452
The transaction frame to commit.
453+
state :
454+
The current state (used for net-zero filtering).
450455
451456
"""
452457
assert tx_frame.parent is not None
453458
block_frame = tx_frame.parent
454459

460+
# Filter net-zero changes before committing
461+
filter_net_zero_frame_changes(tx_frame, state)
462+
455463
# Merge address accesses
456464
block_frame.touched_addresses.update(tx_frame.touched_addresses)
457465

@@ -468,7 +476,7 @@ def commit_transaction_frame(tx_frame: StateChanges) -> None:
468476
for addr, idx, nonce in tx_frame.nonce_changes:
469477
block_frame.nonce_changes.add((addr, idx, nonce))
470478

471-
# Merge code changes (net-zero filtering done in normalize_transaction)
479+
# Merge code changes
472480
for (addr, idx), final_code in tx_frame.code_changes.items():
473481
block_frame.code_changes[(addr, idx)] = final_code
474482

0 commit comments

Comments
 (0)