Skip to content

Commit 20db73a

Browse files
committed
fix(spec-specs): duplicate storage writes in state tracker (#1743)
- Perform a similar check to balance changes and other tracker methods and keep only the last write.
1 parent 8213d73 commit 20db73a

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

docs/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Test fixtures for use by clients are available for each release on the [Github r
2020

2121
### 📋 Misc
2222

23+
- 🐞 Fix duplicate storage write issues for block access lists EIP-7928 implementation ([#1743](https://github.com/ethereum/execution-specs/pull/1743)).
24+
2325
### 🧪 Test Cases
2426

2527
- 🐞 Fix BALs opcode OOG test vectors by updating the Amsterdam commit hash in specs and validating appropriately on the testing side ([#2293](https://github.com/ethereum/execution-spec-tests/pull/2293)).

src/ethereum/forks/amsterdam/block_access_lists/builder.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ def add_storage_write(
126126
Add a storage write operation to the block access list.
127127
128128
Records a storage slot modification for a given address at a specific
129-
transaction index. Multiple writes to the same slot are tracked
130-
separately, maintaining the order and transaction index of each change.
129+
transaction index. If multiple writes occur to the same slot within the
130+
same transaction (same block_access_index), only the final value is kept.
131131
132132
Parameters
133133
----------
@@ -149,6 +149,18 @@ def add_storage_write(
149149
if slot not in builder.accounts[address].storage_changes:
150150
builder.accounts[address].storage_changes[slot] = []
151151

152+
# Check if there's already an entry with the same block_access_index
153+
# If so, update it with the new value, keeping only the final write
154+
changes = builder.accounts[address].storage_changes[slot]
155+
for i, existing_change in enumerate(changes):
156+
if existing_change.block_access_index == block_access_index:
157+
# Update the existing entry with the new value
158+
changes[i] = StorageChange(
159+
block_access_index=block_access_index, new_value=new_value
160+
)
161+
return
162+
163+
# No existing entry found, append new change
152164
change = StorageChange(
153165
block_access_index=block_access_index, new_value=new_value
154166
)

0 commit comments

Comments
 (0)