Fix the VoteTrackerV28 definition

This commit is contained in:
Michael Sproul
2026-04-01 14:54:18 +11:00
parent 4e44cec249
commit ab023a7231

View File

@@ -34,12 +34,12 @@ pub struct VoteTracker {
} }
// Can be deleted once the V28 schema migration is buried. // Can be deleted once the V28 schema migration is buried.
// Matches the on-disk format from schema v28: current_root, next_root, next_epoch.
#[derive(Default, PartialEq, Clone, Encode, Decode)] #[derive(Default, PartialEq, Clone, Encode, Decode)]
pub struct VoteTrackerV28 { pub struct VoteTrackerV28 {
current_root: Hash256, current_root: Hash256,
next_root: Hash256, next_root: Hash256,
current_slot: Slot, next_epoch: Epoch,
next_slot: Slot,
} }
// This impl is only used upon upgrade from pre-Gloas to Gloas with all pre-Gloas nodes. // This impl is only used upon upgrade from pre-Gloas to Gloas with all pre-Gloas nodes.
@@ -49,9 +49,10 @@ impl From<VoteTrackerV28> for VoteTracker {
VoteTracker { VoteTracker {
current_root: v.current_root, current_root: v.current_root,
next_root: v.next_root, next_root: v.next_root,
current_slot: v.current_slot, // The v28 format stored next_epoch rather than slots. Default to 0 since the
next_slot: v.next_slot, // vote tracker will be updated on the next attestation.
// TODO(gloas): check that this is correct current_slot: Slot::new(0),
next_slot: Slot::new(0),
current_payload_present: false, current_payload_present: false,
next_payload_present: false, next_payload_present: false,
} }
@@ -61,13 +62,14 @@ impl From<VoteTrackerV28> for VoteTracker {
// This impl is only used upon downgrade from V29 to V28, with exclusively pre-Gloas nodes. // This impl is only used upon downgrade from V29 to V28, with exclusively pre-Gloas nodes.
impl From<VoteTracker> for VoteTrackerV28 { impl From<VoteTracker> for VoteTrackerV28 {
fn from(v: VoteTracker) -> Self { fn from(v: VoteTracker) -> Self {
// Drop the payload_present, but this is safe because this is only called on pre-Gloas // Drop the payload_present fields. This is safe because this is only called on pre-Gloas
// nodes. // nodes.
VoteTrackerV28 { VoteTrackerV28 {
current_root: v.current_root, current_root: v.current_root,
next_root: v.next_root, next_root: v.next_root,
current_slot: v.current_slot, // The v28 format stored next_epoch. Default to 0 since the vote tracker will be
next_slot: v.next_slot, // updated on the next attestation.
next_epoch: Epoch::new(0),
} }
} }
} }