Merge sigp/unstable into gloas-walk-always

This commit is contained in:
dapplion
2026-03-25 21:37:51 -05:00
20 changed files with 46 additions and 1587 deletions

View File

@@ -6,7 +6,6 @@ use proto_array::{
Block as ProtoBlock, DisallowedReOrgOffsets, ExecutionStatus, JustifiedBalances, LatestMessage,
PayloadStatus, ProposerHeadError, ProposerHeadInfo, ProtoArrayForkChoice, ReOrgThreshold,
};
use ssz::{Decode, Encode};
use ssz_derive::{Decode, Encode};
use state_processing::{
per_block_processing::errors::AttesterSlashingValidationError, per_epoch_processing,
@@ -1811,13 +1810,11 @@ where
///
/// This is used when persisting the state of the fork choice to disk.
#[superstruct(
variants(V17, V28, V29),
variants(V28, V29),
variant_attributes(derive(Encode, Decode, Clone)),
no_enum
)]
pub struct PersistedForkChoice {
#[superstruct(only(V17))]
pub proto_array_bytes: Vec<u8>,
#[superstruct(only(V28))]
pub proto_array_v28: proto_array::core::SszContainerV28,
#[superstruct(only(V29))]
@@ -1829,21 +1826,6 @@ pub struct PersistedForkChoice {
pub type PersistedForkChoice = PersistedForkChoiceV29;
impl TryFrom<PersistedForkChoiceV17> for PersistedForkChoiceV28 {
type Error = ssz::DecodeError;
fn try_from(v17: PersistedForkChoiceV17) -> Result<Self, Self::Error> {
let container_v17 =
proto_array::core::SszContainerV17::from_ssz_bytes(&v17.proto_array_bytes)?;
let container_v28: proto_array::core::SszContainerV28 = container_v17.into();
Ok(Self {
proto_array_v28: container_v28,
queued_attestations: v17.queued_attestations,
})
}
}
impl From<PersistedForkChoiceV28> for PersistedForkChoiceV29 {
fn from(v28: PersistedForkChoiceV28) -> Self {
Self {
@@ -1854,19 +1836,6 @@ impl From<PersistedForkChoiceV28> for PersistedForkChoiceV29 {
}
}
impl From<(PersistedForkChoiceV28, JustifiedBalances)> for PersistedForkChoiceV17 {
fn from((v28, balances): (PersistedForkChoiceV28, JustifiedBalances)) -> Self {
let container_v17 =
proto_array::core::SszContainerV17::from((v28.proto_array_v28, balances));
let proto_array_bytes = container_v17.as_ssz_bytes();
Self {
proto_array_bytes,
queued_attestations: v28.queued_attestations,
}
}
}
#[cfg(test)]
mod tests {
use types::MainnetEthSpec;

View File

@@ -5,8 +5,8 @@ mod metrics;
pub use crate::fork_choice::{
AttestationFromBlock, Error, ForkChoice, ForkChoiceView, ForkchoiceUpdateParameters,
InvalidAttestation, InvalidBlock, PayloadVerificationStatus, PersistedForkChoice,
PersistedForkChoiceV17, PersistedForkChoiceV28, PersistedForkChoiceV29, QueuedAttestation,
QueuedPayloadAttestation, ResetPayloadStatuses,
PersistedForkChoiceV28, PersistedForkChoiceV29, QueuedAttestation, QueuedPayloadAttestation,
ResetPayloadStatuses,
};
pub use fork_choice_store::ForkChoiceStore;
pub use proto_array::{

View File

@@ -16,7 +16,5 @@ pub use error::Error;
pub mod core {
pub use super::proto_array::{ProposerBoost, ProtoArray, ProtoNode};
pub use super::proto_array_fork_choice::VoteTracker;
pub use super::ssz_container::{
SszContainer, SszContainerV17, SszContainerV28, SszContainerV29,
};
pub use super::ssz_container::{SszContainer, SszContainerV28, SszContainerV29};
}

View File

@@ -7,6 +7,7 @@ use crate::{
use ssz::{Encode, four_byte_option_impl};
use ssz_derive::{Decode, Encode};
use std::collections::HashMap;
use superstruct::superstruct;
use types::{Checkpoint, Hash256};
// Define a "legacy" implementation of `Option<usize>` which uses four bytes for encoding the union
@@ -15,40 +16,23 @@ four_byte_option_impl!(four_byte_option_checkpoint, Checkpoint);
pub type SszContainer = SszContainerV29;
/// Proto-array container introduced in schema V17.
#[derive(Encode, Decode, Clone)]
pub struct SszContainerV17 {
#[superstruct(
variants(V28, V29),
variant_attributes(derive(Encode, Decode, Clone)),
no_enum
)]
pub struct SszContainer {
pub votes: Vec<VoteTracker>,
pub balances: Vec<u64>,
pub prune_threshold: usize,
// Deprecated, remove in a future schema migration
#[superstruct(only(V28))]
justified_checkpoint: Checkpoint,
// Deprecated, remove in a future schema migration
#[superstruct(only(V28))]
finalized_checkpoint: Checkpoint,
#[superstruct(only(V28))]
pub nodes: Vec<ProtoNodeV17>,
pub indices: Vec<(Hash256, usize)>,
pub previous_proposer_boost: ProposerBoost,
}
/// Proto-array container introduced in schema V28.
#[derive(Encode, Decode, Clone)]
pub struct SszContainerV28 {
pub votes: Vec<VoteTracker>,
pub prune_threshold: usize,
// Deprecated, remove in a future schema migration
justified_checkpoint: Checkpoint,
// Deprecated, remove in a future schema migration
finalized_checkpoint: Checkpoint,
pub nodes: Vec<ProtoNodeV17>,
pub indices: Vec<(Hash256, usize)>,
pub previous_proposer_boost: ProposerBoost,
}
/// Current container version. Uses union-encoded `ProtoNode` to support mixed V17/V29 nodes.
#[derive(Encode, Decode, Clone)]
pub struct SszContainerV29 {
pub votes: Vec<VoteTracker>,
pub prune_threshold: usize,
#[superstruct(only(V29))]
pub nodes: Vec<ProtoNode>,
pub indices: Vec<(Hash256, usize)>,
pub previous_proposer_boost: ProposerBoost,
@@ -87,37 +71,6 @@ impl TryFrom<(SszContainerV29, JustifiedBalances)> for ProtoArrayForkChoice {
}
}
// Convert legacy V17 to V28 by dropping balances.
impl From<SszContainerV17> for SszContainerV28 {
fn from(v17: SszContainerV17) -> Self {
Self {
votes: v17.votes,
prune_threshold: v17.prune_threshold,
justified_checkpoint: v17.justified_checkpoint,
finalized_checkpoint: v17.finalized_checkpoint,
nodes: v17.nodes,
indices: v17.indices,
previous_proposer_boost: v17.previous_proposer_boost,
}
}
}
// Convert legacy V28 to V17 by re-adding balances.
impl From<(SszContainerV28, JustifiedBalances)> for SszContainerV17 {
fn from((v28, balances): (SszContainerV28, JustifiedBalances)) -> Self {
Self {
votes: v28.votes,
balances: balances.effective_balances.clone(),
prune_threshold: v28.prune_threshold,
justified_checkpoint: v28.justified_checkpoint,
finalized_checkpoint: v28.finalized_checkpoint,
nodes: v28.nodes,
indices: v28.indices,
previous_proposer_boost: v28.previous_proposer_boost,
}
}
}
// Convert legacy V28 to current V29.
impl From<SszContainerV28> for SszContainerV29 {
fn from(v28: SszContainerV28) -> Self {