Skip to content

Commit 62b914c

Browse files
authored
fix(tests): call delegation access disambiguation (#2882)
call with insufficient balance shoudn't access delegation
1 parent db42a89 commit 62b914c

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_opcodes.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,11 +2422,12 @@ def test_bal_call_revert_insufficient_funds(
24222422
24232423
Caller (balance=100): SLOAD(0x01) → call_opcode(target, value=1000)
24242424
→ SSTORE(0x02, result). The call fails because 1000 > 100. The
2425-
failure happens after delegation resolution, so when the target is
2426-
a 7702-delegated EOA both target and delegation target appear in
2427-
the BAL — distinct from the OOG case (see
2428-
test_bal_call_7702_delegation_and_oog) where the static-check
2429-
optimization keeps the delegation target out of the BAL.
2425+
failure happens after delegation resolution. However, the delegation
2426+
target's account has not been read yet.
2427+
So when the target is a 7702-delegated EOA, the target itself appears in
2428+
the BAL since it is already read. The delegation target however,
2429+
does not appear in the BAL, since it does not need to be read
2430+
for verifying sufficient balance.
24302431
24312432
Access-list warming does NOT add to BAL on its own — only EVM
24322433
access does — so the BAL is identical across warm/cold variants.
@@ -2477,7 +2478,7 @@ def test_bal_call_revert_insufficient_funds(
24772478
access_list=access_list,
24782479
)
24792480

2480-
account_expectations: Dict[Address, BalAccountExpectation] = {
2481+
account_expectations: Dict[Address, BalAccountExpectation | None] = {
24812482
alice: BalAccountExpectation(
24822483
nonce_changes=[BalNonceChange(block_access_index=1, post_nonce=1)],
24832484
),
@@ -2495,10 +2496,13 @@ def test_bal_call_revert_insufficient_funds(
24952496
# Target accessed before balance check fails.
24962497
target: BalAccountExpectation.empty(),
24972498
}
2499+
24982500
if delegated:
24992501
assert delegation_target is not None
2500-
# Delegation resolved before balance check fails.
2501-
account_expectations[delegation_target] = BalAccountExpectation.empty()
2502+
# Delegation target must NOT appear in the BAL — get_account
2503+
# for code_address only runs inside generic_call, which is
2504+
# never invoked when the balance check fails.
2505+
account_expectations[delegation_target] = None
25022506

25032507
block = Block(
25042508
txs=[tx],

0 commit comments

Comments
 (0)