Implement Gloas withdrawals and refactor (#8692)

Co-Authored-By: Michael Sproul <michael@sigmaprime.io>

Co-Authored-By: Michael Sproul <michaelsproul@users.noreply.github.com>
This commit is contained in:
Michael Sproul
2026-02-03 18:36:20 +11:00
committed by GitHub
parent ed7354d460
commit d42327bb86
14 changed files with 651 additions and 212 deletions

View File

@@ -23,13 +23,13 @@ use tree_hash_derive::TreeHash;
use typenum::Unsigned;
use crate::{
Builder, BuilderIndex, BuilderPendingPayment, BuilderPendingWithdrawal, ExecutionBlockHash,
ExecutionPayloadBid, Withdrawal,
ExecutionBlockHash, ExecutionPayloadBid, Withdrawal,
attestation::{
AttestationData, AttestationDuty, BeaconCommittee, Checkpoint, CommitteeIndex, PTC,
ParticipationFlags, PendingAttestation,
},
block::{BeaconBlock, BeaconBlockHeader, SignedBeaconBlockHash},
builder::{Builder, BuilderIndex, BuilderPendingPayment, BuilderPendingWithdrawal},
consolidation::PendingConsolidation,
core::{ChainSpec, Domain, Epoch, EthSpec, Hash256, RelativeEpoch, RelativeEpochError, Slot},
deposit::PendingDeposit,
@@ -68,6 +68,7 @@ pub enum BeaconStateError {
EpochOutOfBounds,
SlotOutOfBounds,
UnknownValidator(usize),
UnknownBuilder(BuilderIndex),
UnableToDetermineProducer,
InvalidBitfield,
EmptyCommittee,

View File

@@ -0,0 +1,29 @@
use crate::{EthSpec, Withdrawals};
use superstruct::superstruct;
#[superstruct(
variants(Capella, Electra, Gloas),
variant_attributes(derive(Debug, PartialEq, Clone))
)]
#[derive(Debug, PartialEq, Clone)]
pub struct ExpectedWithdrawals<E: EthSpec> {
pub withdrawals: Withdrawals<E>,
#[superstruct(only(Gloas), partial_getter(copy))]
pub processed_builder_withdrawals_count: u64,
#[superstruct(only(Electra, Gloas), partial_getter(copy))]
pub processed_partial_withdrawals_count: u64,
#[superstruct(only(Gloas), partial_getter(copy))]
pub processed_builders_sweep_count: u64,
#[superstruct(getter(copy))]
pub processed_sweep_withdrawals_count: u64,
}
impl<E: EthSpec> From<ExpectedWithdrawals<E>> for Withdrawals<E> {
fn from(expected_withdrawals: ExpectedWithdrawals<E>) -> Withdrawals<E> {
match expected_withdrawals {
ExpectedWithdrawals::Capella(ew) => ew.withdrawals,
ExpectedWithdrawals::Electra(ew) => ew.withdrawals,
ExpectedWithdrawals::Gloas(ew) => ew.withdrawals,
}
}
}

View File

@@ -1,8 +1,13 @@
mod expected_withdrawals;
mod pending_partial_withdrawal;
mod withdrawal;
mod withdrawal_credentials;
mod withdrawal_request;
pub use expected_withdrawals::{
ExpectedWithdrawals, ExpectedWithdrawalsCapella, ExpectedWithdrawalsElectra,
ExpectedWithdrawalsGloas,
};
pub use pending_partial_withdrawal::PendingPartialWithdrawal;
pub use withdrawal::{Withdrawal, Withdrawals};
pub use withdrawal_credentials::WithdrawalCredentials;