Skip to content

Commit ca2edb3

Browse files
committed
process_execution_payload_bid updates per consensus spec v1.6.0-beta.1 release
1 parent ea17762 commit ca2edb3

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

consensus/state_processing/src/per_block_processing.rs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ pub fn per_block_processing<E: EthSpec, Payload: AbstractExecPayload<E>>(
177177
let body = block.body();
178178
if state.fork_name_unchecked().gloas_enabled() {
179179
process_withdrawals::gloas::process_withdrawals::<E>(state, spec)?;
180-
// TODO(EIP-7732) Mark had process_execution_payload_bid above process_randao so need to clarify if makes more sense here or there
181180
process_execution_payload_bid(state, block, verify_signatures, spec)?;
182181
} else {
183182
process_withdrawals::capella::process_withdrawals::<E, Payload>(
@@ -820,27 +819,29 @@ pub fn process_execution_payload_bid<E: EthSpec, Payload: AbstractExecPayload<E>
820819
.into()
821820
);
822821

823-
// Record the pending payment
824-
let pending_payment = BuilderPendingPayment {
825-
weight: 0,
826-
withdrawal: BuilderPendingWithdrawal {
827-
fee_recipient: bid.fee_recipient,
828-
amount,
829-
builder_index,
830-
// TODO(EIP7732): verify if ok to use default here, withdrawable_epoch is not set in the python spec, https://ethereum.github.io/consensus-specs/specs/_features/eip7732/beacon-chain/#new-process_execution_payload_header
831-
..Default::default()
832-
},
833-
};
822+
// Record the pending payment if there is some payment
823+
if amount > 0 {
824+
let pending_payment = BuilderPendingPayment {
825+
weight: 0,
826+
withdrawal: BuilderPendingWithdrawal {
827+
fee_recipient: bid.fee_recipient,
828+
amount,
829+
builder_index,
830+
withdrawable_epoch: spec.far_future_epoch,
831+
},
832+
};
834833

835-
let payment_index =
836-
(E::slots_per_epoch() + (bid.slot.as_u64() % E::slots_per_epoch())) as usize;
834+
let payment_index = (E::slots_per_epoch()
835+
.safe_add(bid.slot.as_u64().safe_rem(E::slots_per_epoch())?)?)
836+
as usize;
837837

838-
*state
839-
.builder_pending_payments_mut()?
840-
.get_mut(payment_index)
841-
.ok_or(BlockProcessingError::BeaconStateError(
842-
BeaconStateError::BuilderPendingPaymentsIndexNotSupported(payment_index),
843-
))? = pending_payment;
838+
*state
839+
.builder_pending_payments_mut()?
840+
.get_mut(payment_index)
841+
.ok_or(BlockProcessingError::BeaconStateError(
842+
BeaconStateError::BuilderPendingPaymentsIndexNotSupported(payment_index),
843+
))? = pending_payment;
844+
}
844845

845846
// Cache the execution bid
846847
*state.latest_execution_payload_bid_mut()? = bid.clone();

0 commit comments

Comments
 (0)