Skip to content

Commit 6218f55

Browse files
committed
✨ feat(tests): EIP-7928 test_bal_2930_slot_listed_and_unlisted_reads
1 parent 31be0c7 commit 6218f55

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,3 +403,60 @@ def test_bal_2930_slot_listed_and_unlisted_writes(
403403
storage_writer: Account(storage={0x01: 0x42, 0x02: 0x43}),
404404
},
405405
)
406+
407+
408+
@pytest.mark.valid_from("Amsterdam")
409+
def test_bal_2930_slot_listed_and_unlisted_reads(
410+
pre: Alloc,
411+
blockchain_test: BlockchainTestFiller,
412+
fork,
413+
):
414+
"""Ensure BAL includes storage reads regardless of access list presence."""
415+
alice = pre.fund_eoa()
416+
storage_reader = pre.deploy_contract(
417+
code=Op.SLOAD(0x01) + Op.SLOAD(0x02),
418+
storage={0x01: 0x42, 0x02: 0x43}, # Pre-populate storage with values
419+
)
420+
421+
# Access list only includes slot 0x01, but contract reads from both 0x01 and 0x02
422+
access_list = AccessList(
423+
address=storage_reader,
424+
storage_keys=[Hash(0x01)],
425+
)
426+
427+
intrinsic_gas_calculator = fork.transaction_intrinsic_cost_calculator()
428+
gas_limit = (
429+
intrinsic_gas_calculator(
430+
calldata=b"",
431+
contract_creation=False,
432+
access_list=[access_list],
433+
)
434+
+ 50000
435+
) # intrinsic + buffer for storage reads
436+
437+
tx = Transaction(
438+
ty=1, sender=alice, to=storage_reader, gas_limit=gas_limit, access_list=[access_list]
439+
)
440+
441+
block = Block(
442+
txs=[tx],
443+
expected_block_access_list=BlockAccessListExpectation(
444+
account_expectations={
445+
alice: BalAccountExpectation(
446+
nonce_changes=[BalNonceChange(tx_index=1, post_nonce=1)],
447+
),
448+
storage_reader: BalAccountExpectation(
449+
storage_reads=[0x01, 0x02],
450+
),
451+
}
452+
),
453+
)
454+
455+
blockchain_test(
456+
pre=pre,
457+
blocks=[block],
458+
post={
459+
alice: Account(nonce=1),
460+
storage_reader: Account(storage={0x01: 0x42, 0x02: 0x43}),
461+
},
462+
)

tests/amsterdam/eip7928_block_level_access_lists/test_cases.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
| `test_bal_code_changes` | Ensure BAL captures changes to account code | Alice deploys factory contract that creates new contract | BAL MUST include code changes for newly deployed contract | ✅ Completed |
1010
| `test_bal_2930_slot_listed_but_untouched` | Ensure BAL excludes listed but untouched storage slots | Alice sends tx with EIP-2930 access list including `(PureCalculator, slot=0x01)`; PureCalculator executes pure arithmetic (adding two numbers) without touching slot `0x01` | BAL MUST NOT include any entry for PureCalculator's slot `0x01` because it doesn't access state | ✅ Completed |
1111
| `test_bal_2930_slot_listed_and_unlisted_writes` | Ensure BAL includes storage writes regardless of access list presence | Alice sends tx with EIP-2930 access list including `(StorageWriter, slot=0x01)`; StorageWriter executes `SSTORE` to slots `0x01` and `0x02` | BAL MUST include `storage_changes` for StorageWriter's slots `0x01` and `0x02` | ✅ Completed |
12-
| `test_bal_2930_slot_listed_and_unlisted_reads` | Ensure BAL includes storage reads regardless of access list presence | Alice sends tx with EIP-2930 access list including `(Contract, slot=0x01)`; Contract executes `SLOAD` from slots `0x01` and `0x02` | BAL MUST include storage_access for Contract's slots `0x01` and `0x02` | 🟡 Planned |
12+
| `test_bal_2930_slot_listed_and_unlisted_reads` | Ensure BAL includes storage reads regardless of access list presence | Alice sends tx with EIP-2930 access list including `(StorageReader, slot=0x01)`; StorageReader executes `SLOAD` from slots `0x01` and `0x02` | BAL MUST include `storage_reads` for StorageReader's slots `0x01` and `0x02` | ✅ Completed |
1313
| `test_bal_7702_delegated_create` | BAL tracks EIP-7702 delegation indicator write and contract creation | Alice sends a type-4 (7702) tx authorizing herself to delegate to `Deployer` code which executes `CREATE` | BAL MUST include for **Alice**: `code_changes` (delegation indicator), `nonce_changes` (increment from 7702 processing), and `balance_changes` (post-gas). For **Child**: `code_changes` (runtime bytecode) and `nonce_changes = 1`. | 🟡 Planned |
1414
| `test_bal_self_transfer` | BAL handles self-transfers correctly | Alice sends `1 ETH` to **Alice** | BAL MUST include **one** entry for Alice with `balance_changes` reflecting **gas only** (value cancels out) and a nonce change; Coinbase balance updated for fees; no separate recipient row. | 🟡 Planned |
1515
| `test_bal_system_contracts_2935_4788` | BAL includes pre-exec system writes for parent hash & beacon root | Build a block with `N` normal txs; 2935 & 4788 active | BAL MUST include `HISTORY_STORAGE_ADDRESS` (EIP-2935) and `BEACON_ROOTS_ADDRESS` (EIP-4788) with `storage_changes` to ring-buffer slots; each write uses `tx_index = N` (system op). | 🟡 Planned |

0 commit comments

Comments
 (0)