From 9c6f25cf3642c2ddfe40138098618066cd20f542 Mon Sep 17 00:00:00 2001 From: hopinheimer Date: Mon, 9 Mar 2026 19:06:50 -0400 Subject: [PATCH] fix migration `SszContainer` scripts --- consensus/fork_choice/src/fork_choice.rs | 2 +- .../src/fork_choice_test_definition.rs | 3 +-- .../proto_array/src/proto_array_fork_choice.rs | 8 ++------ consensus/proto_array/src/ssz_container.rs | 16 ++++------------ 4 files changed, 8 insertions(+), 21 deletions(-) diff --git a/consensus/fork_choice/src/fork_choice.rs b/consensus/fork_choice/src/fork_choice.rs index d4c4fa2587..12258a03dc 100644 --- a/consensus/fork_choice/src/fork_choice.rs +++ b/consensus/fork_choice/src/fork_choice.rs @@ -1722,7 +1722,7 @@ where PersistedForkChoice { proto_array: self .proto_array() - .as_ssz_container(self.justified_checkpoint(), self.finalized_checkpoint()), + .as_ssz_container(), queued_attestations: self.queued_attestations().to_vec(), queued_payload_attestations: self.queued_payload_attestations.clone(), } diff --git a/consensus/proto_array/src/fork_choice_test_definition.rs b/consensus/proto_array/src/fork_choice_test_definition.rs index f88cf06349..4ff91638f8 100644 --- a/consensus/proto_array/src/fork_choice_test_definition.rs +++ b/consensus/proto_array/src/fork_choice_test_definition.rs @@ -522,8 +522,7 @@ fn get_checkpoint(i: u64) -> Checkpoint { } fn check_bytes_round_trip(original: &ProtoArrayForkChoice) { - // The checkpoint are ignored `ProtoArrayForkChoice::from_bytes` so any value is ok - let bytes = original.as_bytes(Checkpoint::default(), Checkpoint::default()); + let bytes = original.as_bytes(); let decoded = ProtoArrayForkChoice::from_bytes(&bytes, original.balances.clone()) .expect("fork choice should decode from bytes"); assert!( diff --git a/consensus/proto_array/src/proto_array_fork_choice.rs b/consensus/proto_array/src/proto_array_fork_choice.rs index 01a8f10064..15062367bf 100644 --- a/consensus/proto_array/src/proto_array_fork_choice.rs +++ b/consensus/proto_array/src/proto_array_fork_choice.rs @@ -1037,18 +1037,14 @@ impl ProtoArrayForkChoice { pub fn as_ssz_container( &self, - justified_checkpoint: Checkpoint, - finalized_checkpoint: Checkpoint, ) -> SszContainer { - SszContainer::from_proto_array(self, justified_checkpoint, finalized_checkpoint) + SszContainer::from_proto_array(self) } pub fn as_bytes( &self, - justified_checkpoint: Checkpoint, - finalized_checkpoint: Checkpoint, ) -> Vec { - self.as_ssz_container(justified_checkpoint, finalized_checkpoint) + self.as_ssz_container() .as_ssz_bytes() } diff --git a/consensus/proto_array/src/ssz_container.rs b/consensus/proto_array/src/ssz_container.rs index b7d4fa91b0..02c3e33345 100644 --- a/consensus/proto_array/src/ssz_container.rs +++ b/consensus/proto_array/src/ssz_container.rs @@ -49,10 +49,6 @@ pub struct SszContainerV28 { pub struct SszContainerV29 { pub votes: Vec, 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, pub indices: Vec<(Hash256, usize)>, pub previous_proposer_boost: ProposerBoost, @@ -61,16 +57,12 @@ pub struct SszContainerV29 { impl SszContainerV29 { pub fn from_proto_array( from: &ProtoArrayForkChoice, - justified_checkpoint: Checkpoint, - finalized_checkpoint: Checkpoint, ) -> 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, @@ -134,8 +126,6 @@ impl From for SszContainerV29 { Self { votes: v28.votes, prune_threshold: v28.prune_threshold, - justified_checkpoint: v28.justified_checkpoint, - finalized_checkpoint: v28.finalized_checkpoint, nodes: v28.nodes.into_iter().map(ProtoNode::V17).collect(), indices: v28.indices, previous_proposer_boost: v28.previous_proposer_boost, @@ -149,8 +139,10 @@ impl From for SszContainerV28 { Self { votes: v29.votes, prune_threshold: v29.prune_threshold, - justified_checkpoint: v29.justified_checkpoint, - finalized_checkpoint: v29.finalized_checkpoint, + // 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()