Skip to content

Commit 984af99

Browse files
authored
eip7732: deal with zero value bids correctly (#4646)
This PR adds two changes 1. When processing a bid for zero value, do not add a builder pending payment. 2. When processing attestations, only add to the payment quorum if the payment is not trivial
1 parent b417c5f commit 984af99

File tree

2 files changed

+45
-14
lines changed

2 files changed

+45
-14
lines changed

specs/gloas/beacon-chain.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,17 +1023,20 @@ def process_execution_payload_bid(state: BeaconState, block: BeaconBlock) -> Non
10231023
assert bid.parent_block_hash == state.latest_block_hash
10241024
assert bid.parent_block_root == block.parent_root
10251025

1026-
# Record the pending payment
1027-
pending_payment = BuilderPendingPayment(
1028-
weight=0,
1029-
withdrawal=BuilderPendingWithdrawal(
1030-
fee_recipient=bid.fee_recipient,
1031-
amount=amount,
1032-
builder_index=builder_index,
1033-
withdrawable_epoch=FAR_FUTURE_EPOCH,
1034-
),
1035-
)
1036-
state.builder_pending_payments[SLOTS_PER_EPOCH + bid.slot % SLOTS_PER_EPOCH] = pending_payment
1026+
# Record the pending payment if there is some payment
1027+
if amount > 0:
1028+
pending_payment = BuilderPendingPayment(
1029+
weight=0,
1030+
withdrawal=BuilderPendingWithdrawal(
1031+
fee_recipient=bid.fee_recipient,
1032+
amount=amount,
1033+
builder_index=builder_index,
1034+
withdrawable_epoch=FAR_FUTURE_EPOCH,
1035+
),
1036+
)
1037+
state.builder_pending_payments[SLOTS_PER_EPOCH + bid.slot % SLOTS_PER_EPOCH] = (
1038+
pending_payment
1039+
)
10371040

10381041
# Cache the signed execution payload bid
10391042
state.latest_execution_payload_bid = bid
@@ -1145,7 +1148,11 @@ def process_attestation(state: BeaconState, attestation: Attestation) -> None:
11451148
# [New in Gloas:EIP7732]
11461149
# Add weight for same-slot attestations when any new flag is set
11471150
# This ensures each validator contributes exactly once per slot
1148-
if will_set_new_flag and is_attestation_same_slot(state, data):
1151+
if (
1152+
will_set_new_flag
1153+
and is_attestation_same_slot(state, data)
1154+
and payment.withdrawal.amount > 0
1155+
):
11491156
payment.weight += state.validators[index].effective_balance
11501157

11511158
# Reward proposer

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

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,20 @@ def test_builder_payment_weight_tracking(spec, state):
186186

187187
sign_attestation(spec, state, attestation)
188188

189-
# Store initial weight for slot 0
189+
# Manually set up a non-zero builder pending payment for slot 0
190190
payment_slot_index = spec.SLOTS_PER_EPOCH + attestation_slot % spec.SLOTS_PER_EPOCH
191+
test_payment_amount = spec.Gwei(1000000000)
192+
state.builder_pending_payments[payment_slot_index] = spec.BuilderPendingPayment(
193+
weight=spec.Gwei(0),
194+
withdrawal=spec.BuilderPendingWithdrawal(
195+
fee_recipient=spec.ExecutionAddress(),
196+
amount=test_payment_amount,
197+
builder_index=spec.ValidatorIndex(0),
198+
withdrawable_epoch=spec.Epoch(0),
199+
),
200+
)
201+
202+
# Store initial weight for slot 0
191203
initial_weight = state.builder_pending_payments[payment_slot_index].weight
192204

193205
# Process attestation
@@ -227,8 +239,20 @@ def test_builder_payment_weight_no_double_counting(spec, state):
227239

228240
sign_attestation(spec, state, attestation1)
229241

230-
# Store initial weight for slot 0
242+
# Manually set up a non-zero builder pending payment for slot 0
231243
payment_slot_index = spec.SLOTS_PER_EPOCH + attestation_slot % spec.SLOTS_PER_EPOCH
244+
test_payment_amount = spec.Gwei(1000000000)
245+
state.builder_pending_payments[payment_slot_index] = spec.BuilderPendingPayment(
246+
weight=spec.Gwei(0),
247+
withdrawal=spec.BuilderPendingWithdrawal(
248+
fee_recipient=spec.ExecutionAddress(),
249+
amount=test_payment_amount,
250+
builder_index=spec.ValidatorIndex(0),
251+
withdrawable_epoch=spec.Epoch(0),
252+
),
253+
)
254+
255+
# Store initial weight for slot 0
232256
initial_weight = state.builder_pending_payments[payment_slot_index].weight
233257

234258
# Process first attestation (this should set flags and increase weight)

0 commit comments

Comments
 (0)