Skip to content

Commit ce85bf6

Browse files
majectyforiequal0
authored andcommitted
Do not assert the finalized_view while restoring
In the Tendermint restoring process, if the backup state is the Commit step, CodeChain set the step to the Precommit step and handles the votes. The purpose of the behavior is that calling functions that are called when enters the Commit state. Changing the "step" in the restoring process is fragile. It is easy to miss to set some variables. The `finalized_view_of_current_block` variable should be changed when the step is changed. It was lost before. This commit fixes the problem by ignoring the assertion check in the restore process. Although it is not a perfect solution, it is consistent. There is some code already do differently in the restore process.
1 parent 80f0196 commit ce85bf6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

core/src/consensus/tendermint/worker.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,11 @@ impl Worker {
612612
}
613613

614614
/// Do we need this function?
615-
fn set_finalized_view_in_current_height(&mut self, view: View) {
616-
assert_eq!(self.finalized_view_of_current_block, None);
615+
fn set_finalized_view_in_current_height(&mut self, view: View, is_restoring: bool) {
616+
if !is_restoring {
617+
assert_eq!(self.finalized_view_of_current_block, None);
618+
}
619+
617620
self.finalized_view_of_current_block = Some(view);
618621
}
619622

@@ -774,7 +777,7 @@ impl Worker {
774777
Step::Commit => {
775778
cinfo!(ENGINE, "move_to_step: Commit.");
776779
let (view, block_hash) = state.committed().expect("commit always has committed_view");
777-
self.set_finalized_view_in_current_height(view);
780+
self.set_finalized_view_in_current_height(view, is_restoring);
778781

779782
let proposal_received = self.is_proposal_received(self.height, view, block_hash);
780783
let proposal_imported = self.client().block(&block_hash.into()).is_some();

0 commit comments

Comments
 (0)