Skip to content

Commit 68a9c02

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

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

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

Lines changed: 45 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,45 @@ 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+
"""
366+
367+
# Get past genesis
368+
next_epoch(spec, state)
369+
next_epoch(spec, state)
370+
371+
block, builder_index = prepare_block_with_non_proposer_builder(spec, state)
372+
373+
value = spec.Gwei(1_000_000)
374+
state.balances[builder_index] = value + spec.MIN_ACTIVATION_BALANCE
375+
376+
# Create a bid with value amount
377+
signed_bid = prepare_signed_execution_payload_bid(
378+
spec,
379+
state,
380+
builder_index=builder_index,
381+
value=value,
382+
slot=block.slot,
383+
parent_block_root=block.parent_root,
384+
)
385+
386+
block.body.signed_execution_payload_bid = signed_bid
387+
spec.process_block(state, block)
388+
# Slash validator
389+
spec.slash_validator(state, builder_index)
390+
391+
payment_slot = spec.SLOTS_PER_EPOCH + (block.slot % spec.SLOTS_PER_EPOCH)
392+
payment = state.builder_pending_payments[payment_slot]
393+
assert payment.withdrawal.amount == value
394+
assert payment.withdrawal.builder_index == builder_index
395+
351396

352397
@with_gloas_and_later
353398
@spec_state_test

0 commit comments

Comments
 (0)