Skip to content

Commit 54ded28

Browse files
committed
Use 0u8 inside DiffBaseState::Snapshot
1 parent 1184d72 commit 54ded28

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

beacon_node/store/src/hot_cold_store.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3594,7 +3594,8 @@ pub struct HotStateSummary {
35943594
#[derive(Debug, Clone, Copy, Encode, Decode)]
35953595
#[ssz(enum_behaviour = "union")]
35963596
pub enum OptionalDiffBaseState {
3597-
Snapshot(Slot),
3597+
// The SSZ crate requires *something* in each variant so we just store a u8 set to 0.
3598+
Snapshot(u8),
35983599
BaseState(DiffBaseState),
35993600
}
36003601

@@ -3611,16 +3612,7 @@ impl OptionalDiffBaseState {
36113612

36123613
pub fn get_root(&self, slot: Slot) -> Result<Hash256, Error> {
36133614
match *self {
3614-
Self::Snapshot(stored_slot) => {
3615-
if slot == stored_slot {
3616-
Err(Error::SnapshotDiffBaseState { slot })
3617-
} else {
3618-
Err(Error::MismatchedDiffBaseState {
3619-
expected_slot: slot,
3620-
stored_slot,
3621-
})
3622-
}
3623-
}
3615+
Self::Snapshot(_) => Err(Error::SnapshotDiffBaseState { slot }),
36243616
Self::BaseState(DiffBaseState {
36253617
slot: stored_slot,
36263618
state_root,
@@ -3642,7 +3634,7 @@ impl OptionalDiffBaseState {
36423634
impl std::fmt::Display for OptionalDiffBaseState {
36433635
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
36443636
match self {
3645-
Self::Snapshot(slot) => write!(f, "{slot}/snapshot"),
3637+
Self::Snapshot(_) => write!(f, "snapshot"),
36463638
Self::BaseState(base_state) => write!(f, "{base_state}"),
36473639
}
36483640
}
@@ -3698,7 +3690,7 @@ impl HotStateSummary {
36983690
let diff_base_state = if let Some(diff_base_slot) = diff_base_slot {
36993691
OptionalDiffBaseState::new(diff_base_slot, get_state_root(diff_base_slot)?)
37003692
} else {
3701-
OptionalDiffBaseState::Snapshot(state.slot())
3693+
OptionalDiffBaseState::Snapshot(0)
37023694
};
37033695

37043696
let previous_state_root = if state.slot() == 0 {

0 commit comments

Comments
 (0)