Skip to content

Commit 21a9e32

Browse files
committed
chore(fix) revert call changes and add target to bal
1 parent a3d653f commit 21a9e32

File tree

2 files changed

+27
-33
lines changed

2 files changed

+27
-33
lines changed

src/ethereum/forks/amsterdam/vm/instructions/system.py

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -402,19 +402,6 @@ def call(evm: Evm) -> None:
402402
evm,
403403
access_gas_cost + transfer_gas_cost + extend_memory.cost,
404404
)
405-
# Early balance check - before accessing target state.
406-
# This ensures target is NOT in BAL when call fails due to insufficient funds.
407-
sender_balance = get_account(
408-
evm.message.block_env.state, evm.message.current_target
409-
).balance
410-
if sender_balance < value:
411-
# Only charge transfer + memory (not cold access, since we didn't access)
412-
charge_gas(evm, transfer_gas_cost + extend_memory.cost)
413-
evm.memory += b"\x00" * extend_memory.expand_by
414-
push(evm.stack, U256(0))
415-
evm.return_data = b""
416-
evm.pc += Uint(1)
417-
return
418405

419406
# need to access account to check if account is alive, check gas before
420407
create_gas_cost = GAS_NEW_ACCOUNT
@@ -465,23 +452,30 @@ def call(evm: Evm) -> None:
465452
if evm.message.is_static and value != U256(0):
466453
raise WriteInStaticContext
467454
evm.memory += b"\x00" * extend_memory.expand_by
468-
469-
generic_call(
470-
evm,
471-
message_call_gas.sub_call,
472-
value,
473-
evm.message.current_target,
474-
to,
475-
code_address,
476-
True,
477-
False,
478-
memory_input_start_position,
479-
memory_input_size,
480-
memory_output_start_position,
481-
memory_output_size,
482-
code,
483-
disable_precompiles,
484-
)
455+
sender_balance = get_account(
456+
evm.message.block_env.state, evm.message.current_target
457+
).balance
458+
if sender_balance < value:
459+
push(evm.stack, U256(0))
460+
evm.return_data = b""
461+
evm.gas_left += message_call_gas.sub_call
462+
else:
463+
generic_call(
464+
evm,
465+
message_call_gas.sub_call,
466+
value,
467+
evm.message.current_target,
468+
to,
469+
code_address,
470+
True,
471+
False,
472+
memory_input_start_position,
473+
memory_input_size,
474+
memory_output_start_position,
475+
memory_output_size,
476+
code,
477+
disable_precompiles,
478+
)
485479

486480
# PROGRAM COUNTER
487481
evm.pc += Uint(1)

tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2708,7 +2708,7 @@ def test_bal_revert_insufficient_funds(
27082708
27092709
Expected BAL:
27102710
- Contract: storage_reads [0x01], storage_changes slot 0x02 (value=0)
2711-
- Target: MUST NOT appear (balance check fails before target access)
2711+
- Target: appears in BAL (accessed before balance check fails)
27122712
"""
27132713
alice = pre.fund_eoa()
27142714

@@ -2772,8 +2772,8 @@ def test_bal_revert_insufficient_funds(
27722772
)
27732773
],
27742774
),
2775-
# Target MUST NOT appear in BAL - balance check fails before
2776-
# target state is accessed, so no witness is needed for target
2775+
# Target appears in BAL - accessed before balance check fails
2776+
target_address: BalAccountExpectation.empty(),
27772777
}
27782778
),
27792779
)

0 commit comments

Comments
 (0)