From e7ad4b006fe83e147d50a3f64482557da22ab0ee Mon Sep 17 00:00:00 2001 From: Jeb Bearer Date: Fri, 17 May 2024 11:18:45 -0400 Subject: [PATCH] Use the correct validated state on restart --- sequencer/src/persistence.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sequencer/src/persistence.rs b/sequencer/src/persistence.rs index d9c1f894b5..ab9f8d13d2 100644 --- a/sequencer/src/persistence.rs +++ b/sequencer/src/persistence.rs @@ -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 @@ -161,6 +168,7 @@ pub trait SequencerPersistence: Sized + Send + Sync + 'static { ?leaf, ?view, ?high_qc, + ?validated_state, ?undecided_leaves, ?undecided_state, "loaded consensus state"