Skip to content

Commit 5f62058

Browse files
authored
fix(tests): Block-Level Access List invalid tests (#2121)
* refactor: Make modifier internal / private API * fix(tests): Fix BlockAccessListExpectation to forbid extras; fix tests * Add note to changelog for BAL tests fixes * Update to latest commit in BAL specs branch
1 parent df69127 commit 5f62058

File tree

6 files changed

+49
-66
lines changed

6 files changed

+49
-66
lines changed

.github/configs/eels_resolutions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@
5252
"Amsterdam": {
5353
"git_url": "https://github.com/fselmo/execution-specs.git",
5454
"branch": "feat/amsterdam-fork-and-block-access-lists",
55-
"commit": "a5c7b29a658320c2432de78883d350e9f4444d14"
55+
"commit": "39e0b59613be4100d2efc86702ff594c54e5bd81"
5656
}
5757
}

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ Users can select any of the artifacts depending on their benchmarking or testing
239239
- 🔀 Adds the max blob transaction limit to the tests including updates to [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844) for Osaka ([#1884](https://github.com/ethereum/execution-spec-tests/pull/1884)).
240240
- 🐞 Fix issues when filling block rlp size limit tests with ``--generate-pre-alloc-groups`` ([#1989](https://github.com/ethereum/execution-spec-tests/pull/1989)).
241241
-[EIP-7928](https://eips.ethereum.org/EIPS/eip-7928): Add test cases for `Block Level Access Lists (BAL)` to Amsterdam ([#2067](https://github.com/ethereum/execution-spec-tests/pull/2067)).
242+
- 🐞 Fix issues with `Block Level Access Lists (BAL)` tests for Amsterdam ([#2121](https://github.com/ethereum/execution-spec-tests/pull/2121)).
242243

243244
## [v4.5.0](https://github.com/ethereum/execution-spec-tests/releases/tag/v4.5.0) - 2025-05-14
244245

src/ethereum_test_specs/blockchain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ def generate_block_data(
660660
and not block.skip_exception_verification
661661
and not (
662662
block.expected_block_access_list is not None
663-
and block.expected_block_access_list.modifier is not None
663+
and block.expected_block_access_list._modifier is not None
664664
)
665665
):
666666
# Only verify block level exception if:

src/ethereum_test_types/block_access_list/__init__.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from typing import Any, Callable, ClassVar, Dict, List
1010

1111
import ethereum_rlp as eth_rlp
12-
from pydantic import Field
12+
from pydantic import Field, PrivateAttr
1313

1414
from ethereum_test_base_types import (
1515
Address,
@@ -197,15 +197,13 @@ class BlockAccessListExpectation(CamelModel):
197197
198198
"""
199199

200+
model_config = CamelModel.model_config | {"extra": "forbid"}
201+
200202
account_expectations: Dict[Address, BalAccountExpectation | None] = Field(
201203
default_factory=dict, description="Expected account changes or exclusions to verify"
202204
)
203205

204-
modifier: Callable[["BlockAccessList"], "BlockAccessList"] | None = Field(
205-
None,
206-
exclude=True,
207-
description="Optional modifier to modify the BAL for invalid tests",
208-
)
206+
_modifier: Callable[["BlockAccessList"], "BlockAccessList"] | None = PrivateAttr(default=None)
209207

210208
def modify(
211209
self, *modifiers: Callable[["BlockAccessList"], "BlockAccessList"]
@@ -228,7 +226,7 @@ def modify(
228226
229227
"""
230228
new_instance = self.model_copy(deep=True)
231-
new_instance.modifier = compose(*modifiers)
229+
new_instance._modifier = compose(*modifiers)
232230
return new_instance
233231

234232
def to_fixture_bal(self, t8n_bal: "BlockAccessList") -> "BlockAccessList":
@@ -249,8 +247,8 @@ def to_fixture_bal(self, t8n_bal: "BlockAccessList") -> "BlockAccessList":
249247
self.verify_against(t8n_bal)
250248

251249
# Apply modifier if present (for invalid tests)
252-
if self.modifier:
253-
return self.modifier(t8n_bal)
250+
if self._modifier:
251+
return self._modifier(t8n_bal)
254252

255253
return t8n_bal
256254

src/pytest_plugins/eels_resolutions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@
5555
"Amsterdam": {
5656
"git_url": "https://github.com/fselmo/execution-specs.git",
5757
"branch": "feat/amsterdam-fork-and-block-access-lists",
58-
"commit": "a5c7b29a658320c2432de78883d350e9f4444d14"
58+
"commit": "39e0b59613be4100d2efc86702ff594c54e5bd81"
5959
}
6060
}

tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py

Lines changed: 38 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
)
2121
from ethereum_test_types.block_access_list import (
2222
BalAccountChange,
23+
BalAccountExpectation,
2324
BalBalanceChange,
2425
BalNonceChange,
2526
BalStorageChange,
@@ -73,12 +74,11 @@ def test_bal_invalid_missing_nonce(
7374
txs=[tx],
7475
exception=BlockException.INCORRECT_BLOCK_FORMAT,
7576
expected_block_access_list=BlockAccessListExpectation(
76-
account_changes=[
77-
BalAccountChange(
78-
address=sender,
77+
account_expectations={
78+
sender: BalAccountExpectation(
7979
nonce_changes=[BalNonceChange(tx_index=1, post_nonce=1)],
8080
),
81-
]
81+
}
8282
).modify(remove_nonces(sender)),
8383
)
8484
],
@@ -113,12 +113,11 @@ def test_bal_invalid_nonce_value(
113113
txs=[tx],
114114
exception=BlockException.INCORRECT_BLOCK_FORMAT,
115115
expected_block_access_list=BlockAccessListExpectation(
116-
account_changes=[
117-
BalAccountChange(
118-
address=sender,
116+
account_expectations={
117+
sender: BalAccountExpectation(
119118
nonce_changes=[BalNonceChange(tx_index=1, post_nonce=1)],
120119
),
121-
]
120+
}
122121
).modify(modify_nonce(sender, tx_index=1, nonce=42)),
123122
)
124123
],
@@ -158,9 +157,8 @@ def test_bal_invalid_storage_value(
158157
txs=[tx],
159158
exception=BlockException.INCORRECT_BLOCK_FORMAT,
160159
expected_block_access_list=BlockAccessListExpectation(
161-
account_changes=[
162-
BalAccountChange(
163-
address=contract,
160+
account_expectations={
161+
contract: BalAccountExpectation(
164162
storage_changes=[
165163
BalStorageSlot(
166164
slot=0x01,
@@ -176,7 +174,7 @@ def test_bal_invalid_storage_value(
176174
),
177175
],
178176
),
179-
]
177+
}
180178
).modify(
181179
# Corrupt storage value for slot 0x02
182180
modify_storage(contract, tx_index=1, slot=0x02, value=0xFF)
@@ -223,23 +221,20 @@ def test_bal_invalid_tx_order(
223221
txs=[tx1, tx2],
224222
exception=BlockException.INCORRECT_BLOCK_FORMAT,
225223
expected_block_access_list=BlockAccessListExpectation(
226-
account_changes=[
227-
BalAccountChange(
228-
address=sender1,
224+
account_expectations={
225+
sender1: BalAccountExpectation(
229226
nonce_changes=[BalNonceChange(tx_index=1, post_nonce=1)],
230227
),
231-
BalAccountChange(
232-
address=sender2,
228+
sender2: BalAccountExpectation(
233229
nonce_changes=[BalNonceChange(tx_index=2, post_nonce=1)],
234230
),
235-
BalAccountChange(
236-
address=receiver,
231+
receiver: BalAccountExpectation(
237232
balance_changes=[
238233
BalBalanceChange(tx_index=1, post_balance=10**15),
239234
BalBalanceChange(tx_index=2, post_balance=3 * 10**15),
240235
],
241236
),
242-
]
237+
}
243238
).modify(swap_tx_indices(1, 2)),
244239
)
245240
],
@@ -276,12 +271,11 @@ def test_bal_invalid_account(
276271
txs=[tx],
277272
exception=BlockException.INCORRECT_BLOCK_FORMAT,
278273
expected_block_access_list=BlockAccessListExpectation(
279-
account_changes=[
280-
BalAccountChange(
281-
address=sender,
274+
account_expectations={
275+
sender: BalAccountExpectation(
282276
nonce_changes=[BalNonceChange(tx_index=1, post_nonce=1)],
283277
),
284-
]
278+
}
285279
).modify(
286280
append_account(
287281
BalAccountChange(
@@ -323,16 +317,14 @@ def test_bal_invalid_duplicate_account(
323317
txs=[tx],
324318
exception=BlockException.INCORRECT_BLOCK_FORMAT,
325319
expected_block_access_list=BlockAccessListExpectation(
326-
account_changes=[
327-
BalAccountChange(
328-
address=sender,
320+
account_expectations={
321+
sender: BalAccountExpectation(
329322
nonce_changes=[BalNonceChange(tx_index=1, post_nonce=1)],
330323
),
331-
BalAccountChange(
332-
address=receiver,
324+
receiver: BalAccountExpectation(
333325
balance_changes=[BalBalanceChange(tx_index=1, post_balance=10**15)],
334326
),
335-
]
327+
}
336328
).modify(duplicate_account(sender)),
337329
)
338330
],
@@ -367,16 +359,14 @@ def test_bal_invalid_account_order(
367359
txs=[tx],
368360
exception=BlockException.INCORRECT_BLOCK_FORMAT,
369361
expected_block_access_list=BlockAccessListExpectation(
370-
account_changes=[
371-
BalAccountChange(
372-
address=sender,
362+
account_expectations={
363+
sender: BalAccountExpectation(
373364
nonce_changes=[BalNonceChange(tx_index=1, post_nonce=1)],
374365
),
375-
BalAccountChange(
376-
address=receiver,
366+
receiver: BalAccountExpectation(
377367
balance_changes=[BalBalanceChange(tx_index=1, post_balance=10**15)],
378368
),
379-
]
369+
}
380370
).modify(reverse_accounts()),
381371
)
382372
],
@@ -424,16 +414,14 @@ def test_bal_invalid_complex_corruption(
424414
txs=[tx1, tx2],
425415
exception=BlockException.INCORRECT_BLOCK_FORMAT,
426416
expected_block_access_list=BlockAccessListExpectation(
427-
account_changes=[
428-
BalAccountChange(
429-
address=sender,
417+
account_expectations={
418+
sender: BalAccountExpectation(
430419
nonce_changes=[
431420
BalNonceChange(tx_index=1, post_nonce=1),
432421
BalNonceChange(tx_index=2, post_nonce=2),
433422
],
434423
),
435-
BalAccountChange(
436-
address=contract,
424+
contract: BalAccountExpectation(
437425
storage_changes=[
438426
BalStorageSlot(
439427
slot=0x01,
@@ -445,11 +433,10 @@ def test_bal_invalid_complex_corruption(
445433
),
446434
],
447435
),
448-
BalAccountChange(
449-
address=receiver,
436+
receiver: BalAccountExpectation(
450437
balance_changes=[BalBalanceChange(tx_index=2, post_balance=10**15)],
451438
),
452-
]
439+
}
453440
).modify(
454441
remove_nonces(sender),
455442
modify_storage(contract, tx_index=1, slot=0x01, value=0xFF),
@@ -489,16 +476,14 @@ def test_bal_invalid_missing_account(
489476
txs=[tx],
490477
exception=BlockException.INCORRECT_BLOCK_FORMAT,
491478
expected_block_access_list=BlockAccessListExpectation(
492-
account_changes=[
493-
BalAccountChange(
494-
address=sender,
479+
account_expectations={
480+
sender: BalAccountExpectation(
495481
nonce_changes=[BalNonceChange(tx_index=1, post_nonce=1)],
496482
),
497-
BalAccountChange(
498-
address=receiver,
483+
receiver: BalAccountExpectation(
499484
balance_changes=[BalBalanceChange(tx_index=1, post_balance=10**15)],
500485
),
501-
]
486+
}
502487
).modify(remove_accounts(receiver)),
503488
)
504489
],
@@ -533,12 +518,11 @@ def test_bal_invalid_balance_value(
533518
txs=[tx],
534519
exception=BlockException.INCORRECT_BLOCK_FORMAT,
535520
expected_block_access_list=BlockAccessListExpectation(
536-
account_changes=[
537-
BalAccountChange(
538-
address=receiver,
521+
account_expectations={
522+
receiver: BalAccountExpectation(
539523
balance_changes=[BalBalanceChange(tx_index=1, post_balance=10**15)],
540524
),
541-
]
525+
}
542526
).modify(modify_balance(receiver, tx_index=1, balance=999999)),
543527
)
544528
],

0 commit comments

Comments
 (0)