Gloas payload bid consensus (#8801)

- [x] Consensus changes for execution payload bids
- [x] EF tests for bids (and `block_header` -- no changes required).


Co-Authored-By: Michael Sproul <michael@sigmaprime.io>
This commit is contained in:
Michael Sproul
2026-02-12 15:26:23 +11:00
committed by GitHub
parent 711971f269
commit b8072c5b77
10 changed files with 358 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
use crate::test_utils::TestRandom;
use crate::{Address, Epoch, ForkName};
use crate::{Address, ChainSpec, Epoch, ForkName};
use bls::PublicKeyBytes;
use context_deserialize::context_deserialize;
use serde::{Deserialize, Serialize};
@@ -24,3 +24,12 @@ pub struct Builder {
pub deposit_epoch: Epoch,
pub withdrawable_epoch: Epoch,
}
impl Builder {
/// Check if a builder is active in a state with `finalized_epoch`.
///
/// This implements `is_active_builder` from the spec.
pub fn is_active_at_finalized_epoch(&self, finalized_epoch: Epoch, spec: &ChainSpec) -> bool {
self.deposit_epoch < finalized_epoch && self.withdrawable_epoch == spec.far_future_epoch
}
}

View File

@@ -9,7 +9,7 @@ use fixed_bytes::FixedBytesExtended;
use int_to_bytes::{int_to_bytes4, int_to_bytes8};
use metastruct::{NumFields, metastruct};
use milhouse::{List, Vector};
use safe_arith::{ArithError, SafeArith};
use safe_arith::{ArithError, SafeArith, SafeArithIter};
use serde::{Deserialize, Deserializer, Serialize};
use ssz::{Decode, DecodeError, Encode, ssz_encode};
use ssz_derive::{Decode, Encode};
@@ -218,6 +218,7 @@ pub enum BeaconStateError {
envelope_epoch: Epoch,
},
InvalidIndicesCount,
InvalidBuilderPendingPaymentsIndex(usize),
InvalidExecutionPayloadAvailabilityIndex(usize),
}
@@ -2749,6 +2750,30 @@ impl<E: EthSpec> BeaconState<E> {
Ok(pending_balance)
}
pub fn get_pending_balance_to_withdraw_for_builder(
&self,
builder_index: BuilderIndex,
) -> Result<u64, BeaconStateError> {
let pending_withdrawals_total = self
.builder_pending_withdrawals()?
.iter()
.filter_map(|withdrawal| {
(withdrawal.builder_index == builder_index).then_some(withdrawal.amount)
})
.safe_sum()?;
let pending_payments_total = self
.builder_pending_payments()?
.iter()
.filter_map(|payment| {
(payment.withdrawal.builder_index == builder_index)
.then_some(payment.withdrawal.amount)
})
.safe_sum()?;
pending_withdrawals_total
.safe_add(pending_payments_total)
.map_err(Into::into)
}
// ******* Electra mutators *******
pub fn queue_excess_active_balance(