From 83b66d70247d1dfb244eb120413720674b7727a0 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 28 Apr 2024 20:55:22 +0200 Subject: [PATCH 1/4] validator logging for fork + fix not reinitializing --- crates/ethcore/src/engines/hbbft/hbbft_state.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/ethcore/src/engines/hbbft/hbbft_state.rs b/crates/ethcore/src/engines/hbbft/hbbft_state.rs index 90d55a913..52e293f03 100644 --- a/crates/ethcore/src/engines/hbbft/hbbft_state.rs +++ b/crates/ethcore/src/engines/hbbft/hbbft_state.rs @@ -105,7 +105,6 @@ impl HbbftState { } } - let mut has_forked = false; // https://github.com/DMDcoin/diamond-node/issues/98 // check here if we are in a fork scenario. // in a fork scenario, the new honeybadger keys will come from the config, @@ -125,6 +124,10 @@ impl HbbftState { ) { info!(target: "engine", "Forking at block {last_block_number}, starting new honeybadger instance with new validator set."); + for id in network_info.validator_set().all_ids() { + info!(target: "engine", "Fork Validator: {}", id); + } + self.public_master_key = Some(network_info.public_key_set().public_key()); self.honey_badger = Some(self.new_honey_badger(network_info.clone())?); @@ -134,15 +137,16 @@ impl HbbftState { self.network_info = Some(network_info); self.last_fork_start_block = Some(last_block_number); + self.current_posdao_epoch_start_block = last_block_number; - has_forked = true; + return Some(()); } } else { error!(target: "engine", "fork: could not get block number for block_id: {:?}", block_id); } // - if !force && self.current_posdao_epoch == target_posdao_epoch && !has_forked { + if !force && self.current_posdao_epoch == target_posdao_epoch { // hbbft state is already up to date. // @todo Return proper error codes. return Some(()); From 660b1552fd01181f950ff2420c53a0e3276d526f Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 1 May 2024 11:32:22 +0200 Subject: [PATCH 2/4] added debug log for initialize_synckeygen. --- crates/ethcore/src/engines/hbbft/contracts/keygen_history.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/ethcore/src/engines/hbbft/contracts/keygen_history.rs b/crates/ethcore/src/engines/hbbft/contracts/keygen_history.rs index 94c3724db..a8a642d60 100644 --- a/crates/ethcore/src/engines/hbbft/contracts/keygen_history.rs +++ b/crates/ethcore/src/engines/hbbft/contracts/keygen_history.rs @@ -229,6 +229,7 @@ pub fn initialize_synckeygen( block_id: BlockId, validator_type: ValidatorType, ) -> Result, CallError> { + debug!(target: "engine", "Initializing SyncKeyGen with block_id: {:?}", block_id); let vmap = get_validator_pubkeys(&*client, block_id, validator_type)?; let pub_keys: BTreeMap<_, _> = vmap .values() From 786ba14fa289a33ceee047c509f84b07f26dea7d Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 18 May 2024 09:56:34 +0200 Subject: [PATCH 3/4] encode ACKS ad PARTs as hex for Key Gen JSON https://github.com/DMDcoin/diamond-node/issues/112 --- Cargo.lock | 1 + .../src/engines/hbbft/hbbft_config_generator/Cargo.toml | 4 +++- .../hbbft_config_generator/src/keygen_history_helpers.rs | 4 ++++ .../src/engines/hbbft/hbbft_config_generator/src/main.rs | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index d33c539bf..60608d893 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2150,6 +2150,7 @@ dependencies = [ "rustc-hex 2.1.0", "serde", "serde_json", + "serde_with", "toml 0.5.8", ] diff --git a/crates/ethcore/src/engines/hbbft/hbbft_config_generator/Cargo.toml b/crates/ethcore/src/engines/hbbft/hbbft_config_generator/Cargo.toml index 91ef228f6..b5a162b7e 100644 --- a/crates/ethcore/src/engines/hbbft/hbbft_config_generator/Cargo.toml +++ b/crates/ethcore/src/engines/hbbft/hbbft_config_generator/Cargo.toml @@ -4,7 +4,8 @@ name = "hbbft_config_generator" version = "0.0.1" license = "GPL-3.0" authors = [ - "David Forstenlechner " + "David Forstenlechner ", + "Thomas Haller " ] [dependencies] @@ -22,6 +23,7 @@ rand = "0.7.3" rustc-hex = "2.1.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" +serde_with = { version = "3.6", features = [ "hex", "std", "macros" ] } toml = "0.5.6" [dev-dependencies] diff --git a/crates/ethcore/src/engines/hbbft/hbbft_config_generator/src/keygen_history_helpers.rs b/crates/ethcore/src/engines/hbbft/hbbft_config_generator/src/keygen_history_helpers.rs index 095011159..e86d8cad4 100644 --- a/crates/ethcore/src/engines/hbbft/hbbft_config_generator/src/keygen_history_helpers.rs +++ b/crates/ethcore/src/engines/hbbft/hbbft_config_generator/src/keygen_history_helpers.rs @@ -5,6 +5,7 @@ use hbbft::sync_key_gen::{AckOutcome, Part, PartOutcome, PublicKey, SecretKey, S use parity_crypto::publickey::{public_to_address, Address, Public, Secret}; use serde::{Deserialize, Serialize}; use std::{collections::BTreeMap, sync::Arc}; +use serde_with::serde_as; #[derive(Clone)] pub struct KeyPairWrapper { @@ -110,13 +111,16 @@ pub fn enodes_to_pub_keys(enodes: &Vec) -> Arc, staking_addresses: Vec, public_keys: Vec, ip_addresses: Vec, + #[serde_as(as = "Vec")] parts: Vec>, + #[serde_as(as = "Vec>")] acks: Vec>>, } diff --git a/crates/ethcore/src/engines/hbbft/hbbft_config_generator/src/main.rs b/crates/ethcore/src/engines/hbbft/hbbft_config_generator/src/main.rs index 714fd9988..e5084f94a 100644 --- a/crates/ethcore/src/engines/hbbft/hbbft_config_generator/src/main.rs +++ b/crates/ethcore/src/engines/hbbft/hbbft_config_generator/src/main.rs @@ -11,6 +11,7 @@ extern crate parity_crypto; extern crate rand; extern crate rustc_hex; extern crate serde; +extern crate serde_with; extern crate serde_json; extern crate toml; From 330f2fb184607913c2e0ab6245ed50f9d97ad625 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 21 May 2024 12:24:47 +0200 Subject: [PATCH 4/4] cargo fmt --all -- --config imports_granularity=Crate --- .../hbbft/hbbft_config_generator/src/keygen_history_helpers.rs | 2 +- .../src/engines/hbbft/hbbft_config_generator/src/main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ethcore/src/engines/hbbft/hbbft_config_generator/src/keygen_history_helpers.rs b/crates/ethcore/src/engines/hbbft/hbbft_config_generator/src/keygen_history_helpers.rs index e86d8cad4..dba6e142a 100644 --- a/crates/ethcore/src/engines/hbbft/hbbft_config_generator/src/keygen_history_helpers.rs +++ b/crates/ethcore/src/engines/hbbft/hbbft_config_generator/src/keygen_history_helpers.rs @@ -4,8 +4,8 @@ use ethjson::spec::hbbft::HbbftNetworkFork; use hbbft::sync_key_gen::{AckOutcome, Part, PartOutcome, PublicKey, SecretKey, SyncKeyGen}; use parity_crypto::publickey::{public_to_address, Address, Public, Secret}; use serde::{Deserialize, Serialize}; -use std::{collections::BTreeMap, sync::Arc}; use serde_with::serde_as; +use std::{collections::BTreeMap, sync::Arc}; #[derive(Clone)] pub struct KeyPairWrapper { diff --git a/crates/ethcore/src/engines/hbbft/hbbft_config_generator/src/main.rs b/crates/ethcore/src/engines/hbbft/hbbft_config_generator/src/main.rs index e5084f94a..3c7f83c10 100644 --- a/crates/ethcore/src/engines/hbbft/hbbft_config_generator/src/main.rs +++ b/crates/ethcore/src/engines/hbbft/hbbft_config_generator/src/main.rs @@ -11,8 +11,8 @@ extern crate parity_crypto; extern crate rand; extern crate rustc_hex; extern crate serde; -extern crate serde_with; extern crate serde_json; +extern crate serde_with; extern crate toml; mod keygen_history_helpers;