Skip to content

Commit fe3e8d7

Browse files
committed
Fix Process same-slot slashings before builder payments in Gloas #4561
1 parent f96d3e7 commit fe3e8d7

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

tests/core/pyspec/eth2spec/test/gloas/block_processing/test_process_execution_payload_bid.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import random
2+
from eth2spec.test.helpers.state import next_epoch
3+
4+
from eth2spec.test.helpers.attestations import get_valid_attestation
5+
16
from eth2spec.test.context import (
27
always_bls,
38
spec_state_test,
@@ -9,6 +14,7 @@
914
set_builder_withdrawal_credential,
1015
set_builder_withdrawal_credential_with_balance,
1116
)
17+
from eth2spec.test.helpers.execution_payload import build_empty_execution_payload
1218

1319

1420
def run_execution_payload_bid_processing(spec, state, block, valid=True):
@@ -348,6 +354,46 @@ def test_process_execution_payload_bid_slashed_builder(spec, state):
348354

349355
yield from run_execution_payload_bid_processing(spec, state, block, valid=False)
350356

357+
@with_gloas_and_later
358+
@spec_state_test
359+
def test_process_block_then_slash_non_timely_builder(spec, state):
360+
"""
361+
Empty-case payment path:
362+
- A builder posts a successful bid in a block, but the payload is not revealed in time.
363+
- Builder is slashed
364+
- Proposer unconditional payment is enforced by moving the bid amount into
365+
- This test verifies that pipeline (no EL execution needed).
366+
"""
367+
368+
# Get past genesis
369+
next_epoch(spec, state)
370+
next_epoch(spec, state)
371+
372+
block, builder_index = prepare_block_with_non_proposer_builder(spec, state)
373+
374+
value = spec.Gwei(1_000_000)
375+
state.balances[builder_index] = value + spec.MIN_ACTIVATION_BALANCE
376+
377+
# Create a bid with value amount
378+
signed_bid = prepare_signed_execution_payload_bid(
379+
spec,
380+
state,
381+
builder_index=builder_index,
382+
value=value,
383+
slot=block.slot,
384+
parent_block_root=block.parent_root,
385+
)
386+
387+
block.body.signed_execution_payload_bid = signed_bid
388+
spec.process_block(state, block)
389+
# Slash validator
390+
spec.slash_validator(state, builder_index)
391+
392+
payment_slot = spec.SLOTS_PER_EPOCH + (block.slot % spec.SLOTS_PER_EPOCH)
393+
payment = state.builder_pending_payments[payment_slot]
394+
assert payment.withdrawal.amount == value
395+
assert payment.withdrawal.builder_index == builder_index
396+
351397

352398
@with_gloas_and_later
353399
@spec_state_test

0 commit comments

Comments
 (0)