Skip to content

Commit

Permalink
Use the correct validated state on restart (#1482)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbearer authored May 17, 2024
2 parents 68aa605 + e7ad4b0 commit 3e50daa
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion sequencer/src/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,14 @@ pub trait SequencerPersistence: Sized + Send + Sync + 'static {
(Leaf::genesis(&state), QuorumCertificate::genesis(&state))
}
};
let validated_state = Some(Arc::new(ValidatedState::genesis(&state).0));
let validated_state = if leaf.get_block_header().height == 0 {
// If we are starting from genesis, we can provide the full state.
Some(Arc::new(ValidatedState::genesis(&state).0))
} else {
// Otherwise, we will have to construct a sparse state and fetch missing data during
// catchup.
None
};

// If we are not starting from genesis, we start from the view following the maximum view
// between `highest_voted_view` and `leaf.view_number`. This prevents double votes from
Expand All @@ -161,6 +168,7 @@ pub trait SequencerPersistence: Sized + Send + Sync + 'static {
?leaf,
?view,
?high_qc,
?validated_state,
?undecided_leaves,
?undecided_state,
"loaded consensus state"
Expand Down

0 comments on commit 3e50daa

Please sign in to comment.