From e6bd8042d6951268c56a87a53b568107d6b41925 Mon Sep 17 00:00:00 2001 From: Juhyung Park Date: Fri, 15 Nov 2019 18:07:52 +0900 Subject: [PATCH] Set finalized_view to None when restoring in the Commit step 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. After we introduce the `finalized_view_of_current_block` variable, the variable should be changed to `None` when CodeChain sets the state to Precommit in the restoring process. --- core/src/consensus/tendermint/worker.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/consensus/tendermint/worker.rs b/core/src/consensus/tendermint/worker.rs index 93386a0df5..19b12e96c0 100644 --- a/core/src/consensus/tendermint/worker.rs +++ b/core/src/consensus/tendermint/worker.rs @@ -1033,6 +1033,11 @@ impl Worker { let client = self.client(); let backup = restore(client.get_kvdb().as_ref()); if let Some(backup) = backup { + if backup.step == Step::Commit { + self.finalized_view_of_current_block = None; + } else { + self.finalized_view_of_current_block = backup.finalized_view_of_current_block; + } let backup_step = match backup.step { Step::Propose => TendermintState::Propose, Step::Prevote => TendermintState::Prevote, @@ -1046,7 +1051,6 @@ impl Worker { self.height = backup.height; self.view = backup.view; self.finalized_view_of_previous_block = backup.finalized_view_of_previous_block; - self.finalized_view_of_current_block = backup.finalized_view_of_current_block; if let Some(proposal) = backup.proposal { if client.block(&BlockId::Hash(proposal)).is_some() {