From 89b43ff29807f7903b8670a4841d2384bdd8d55a Mon Sep 17 00:00:00 2001 From: SeongChan Lee Date: Tue, 19 Nov 2019 17:09:37 +0900 Subject: [PATCH 1/3] Revert "Set finalized_view to None when restoring in the Commit step" This reverts commit 59e9ebd0bbf93ff0eeac9e9e93ad302ab4a45ce0. --- core/src/consensus/tendermint/worker.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/core/src/consensus/tendermint/worker.rs b/core/src/consensus/tendermint/worker.rs index 19b12e96c0..93386a0df5 100644 --- a/core/src/consensus/tendermint/worker.rs +++ b/core/src/consensus/tendermint/worker.rs @@ -1033,11 +1033,6 @@ 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, @@ -1051,6 +1046,7 @@ 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() { From 24db5a40c8e965b67140078dcd86da1653f3f980 Mon Sep 17 00:00:00 2001 From: Juhyung Park Date: Mon, 18 Nov 2019 13:45:52 +0900 Subject: [PATCH 2/3] 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. --- core/src/consensus/tendermint/worker.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/src/consensus/tendermint/worker.rs b/core/src/consensus/tendermint/worker.rs index 93386a0df5..5f3aa0ead7 100644 --- a/core/src/consensus/tendermint/worker.rs +++ b/core/src/consensus/tendermint/worker.rs @@ -612,8 +612,11 @@ impl Worker { } /// Do we need this function? - fn set_finalized_view_in_current_height(&mut self, view: View) { - assert_eq!(self.finalized_view_of_current_block, None); + fn set_finalized_view_in_current_height(&mut self, view: View, is_restoring: bool) { + if !is_restoring { + assert_eq!(self.finalized_view_of_current_block, None); + } + self.finalized_view_of_current_block = Some(view); } @@ -774,7 +777,7 @@ impl Worker { Step::Commit => { cinfo!(ENGINE, "move_to_step: Commit."); let (view, block_hash) = state.committed().expect("commit always has committed_view"); - self.set_finalized_view_in_current_height(view); + self.set_finalized_view_in_current_height(view, is_restoring); let proposal_received = self.is_proposal_received(self.height, view, block_hash); let proposal_imported = self.client().block(&block_hash.into()).is_some(); From 305e732d6cf4abbfde8b0adb58729705ea16015e Mon Sep 17 00:00:00 2001 From: SeongChan Lee Date: Fri, 15 Nov 2019 19:05:46 +0900 Subject: [PATCH 3/3] Bump the version 2.2.1 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 03e029e5e9..d5c0f5c708 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -209,7 +209,7 @@ dependencies = [ [[package]] name = "codechain" -version = "2.2.0" +version = "2.2.1" dependencies = [ "app_dirs 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "cidr 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index d58ec13776..aad3f3e977 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "codechain" -version = "2.2.0" +version = "2.2.1" license = "AGPL-3.0" authors = ["CodeChain Team "] exclude = [