resolve merge conflicts

This commit is contained in:
Eitan Seri-Levi
2026-04-30 01:51:26 +02:00
544 changed files with 48684 additions and 18351 deletions

View File

@@ -1,8 +1,8 @@
use crate::proto_array::ProposerBoost;
use crate::{
Error, JustifiedBalances,
proto_array::{ProtoArray, ProtoNodeV17},
proto_array_fork_choice::{ElasticList, ProtoArrayForkChoice, VoteTracker},
proto_array::{ProtoArray, ProtoNode, ProtoNodeV17},
proto_array_fork_choice::{ElasticList, ProtoArrayForkChoice, VoteTracker, VoteTrackerV28},
};
use ssz::{Encode, four_byte_option_impl};
use ssz_derive::{Decode, Encode};
@@ -14,44 +14,44 @@ use types::{Checkpoint, Hash256, Slot};
// selector.
four_byte_option_impl!(four_byte_option_checkpoint, Checkpoint);
pub type SszContainer = SszContainerV28;
pub type SszContainer = SszContainerV29;
#[superstruct(
variants(V17, V28),
variants(V28, V29),
variant_attributes(derive(Encode, Decode, Clone)),
no_enum
)]
pub struct SszContainer {
#[superstruct(only(V28))]
pub votes_v28: Vec<VoteTrackerV28>,
#[superstruct(only(V29))]
pub votes: Vec<VoteTracker>,
#[superstruct(only(V17))]
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>,
#[superstruct(only(V29))]
pub nodes: Vec<ProtoNode>,
pub indices: Vec<(Hash256, usize)>,
#[superstruct(only(V28))]
pub previous_proposer_boost: ProposerBoost,
pub unsatisfied_inclusion_list_blocks: Vec<(Slot, Hash256)>,
}
impl SszContainer {
pub fn from_proto_array(
from: &ProtoArrayForkChoice,
justified_checkpoint: Checkpoint,
finalized_checkpoint: Checkpoint,
) -> Self {
impl SszContainerV29 {
pub fn from_proto_array(from: &ProtoArrayForkChoice) -> Self {
let proto_array = &from.proto_array;
Self {
votes: from.votes.0.clone(),
prune_threshold: proto_array.prune_threshold,
justified_checkpoint,
finalized_checkpoint,
nodes: proto_array.nodes.clone(),
indices: proto_array.indices.iter().map(|(k, v)| (*k, *v)).collect(),
previous_proposer_boost: proto_array.previous_proposer_boost,
unsatisfied_inclusion_list_blocks: proto_array
.unsatisfied_inclusion_list_blocks
.iter()
@@ -61,15 +61,15 @@ impl SszContainer {
}
}
impl TryFrom<(SszContainer, JustifiedBalances)> for ProtoArrayForkChoice {
impl TryFrom<(SszContainerV29, JustifiedBalances)> for ProtoArrayForkChoice {
type Error = Error;
fn try_from((from, balances): (SszContainer, JustifiedBalances)) -> Result<Self, Error> {
fn try_from((from, balances): (SszContainerV29, JustifiedBalances)) -> Result<Self, Error> {
let proto_array = ProtoArray {
prune_threshold: from.prune_threshold,
nodes: from.nodes,
indices: from.indices.into_iter().collect::<HashMap<_, _>>(),
previous_proposer_boost: from.previous_proposer_boost,
previous_proposer_boost: ProposerBoost::default(),
unsatisfied_inclusion_list_blocks: from
.unsatisfied_inclusion_list_blocks
.into_iter()
@@ -84,35 +84,51 @@ impl TryFrom<(SszContainer, JustifiedBalances)> for ProtoArrayForkChoice {
}
}
// Convert V17 to V28 by dropping balances.
impl From<SszContainerV17> for SszContainerV28 {
fn from(v17: SszContainerV17) -> Self {
// Convert legacy V28 to current V29.
impl From<SszContainerV28> for SszContainerV29 {
fn from(v28: SszContainerV28) -> 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,
unsatisfied_inclusion_list_blocks: v17.unsatisfied_inclusion_list_blocks,
votes: v28.votes_v28.into_iter().map(Into::into).collect(),
prune_threshold: v28.prune_threshold,
nodes: v28
.nodes
.into_iter()
.map(|mut node| {
// best_child/best_descendant are no longer used (replaced by
// the virtual tree walk). Clear during conversion.
node.best_child = None;
node.best_descendant = None;
ProtoNode::V17(node)
})
.collect(),
indices: v28.indices,
unsatisfied_inclusion_list_blocks: vec![],
}
}
}
// Convert V28 to V17 by re-adding balances.
impl From<(SszContainerV28, JustifiedBalances)> for SszContainerV17 {
fn from((v28, balances): (SszContainerV28, JustifiedBalances)) -> Self {
// Downgrade current V29 to legacy V28 (lossy: V29 nodes lose payload-specific fields).
impl From<SszContainerV29> for SszContainerV28 {
fn from(v29: SszContainerV29) -> 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,
unsatisfied_inclusion_list_blocks: v28.unsatisfied_inclusion_list_blocks,
votes_v28: v29.votes.into_iter().map(Into::into).collect(),
prune_threshold: v29.prune_threshold,
// These checkpoints are not consumed in v28 paths since the upgrade from v17,
// we can safely default the values.
justified_checkpoint: Checkpoint::default(),
finalized_checkpoint: Checkpoint::default(),
nodes: v29
.nodes
.into_iter()
.filter_map(|node| match node {
ProtoNode::V17(v17) => Some(v17),
ProtoNode::V29(_) => None,
})
.collect(),
indices: v29.indices,
// Proposer boost is not tracked in V29 (computed on-the-fly), so reset it.
previous_proposer_boost: ProposerBoost::default(),
unsatisfied_inclusion_list_blocks: v29.unsatisfied_inclusion_list_blocks,
}
}
}