Skip to content

Commit

Permalink
Merge pull request #113 from SurfingNerd/i112-key-gen-as-hex
Browse files Browse the repository at this point in the history
i112 key gen as hex
integrated into dev-alpha2
  • Loading branch information
SurfingNerd authored May 21, 2024
2 parents bb35407 + 330f2fb commit c69c572
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ pub fn initialize_synckeygen(
block_id: BlockId,
validator_type: ValidatorType,
) -> Result<SyncKeyGen<Public, PublicWrapper>, 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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ name = "hbbft_config_generator"
version = "0.0.1"
license = "GPL-3.0"
authors = [
"David Forstenlechner <[email protected]>"
"David Forstenlechner <[email protected]>",
"Thomas Haller <[email protected]>"
]

[dependencies]
Expand All @@ -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]
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ 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 serde_with::serde_as;
use std::{collections::BTreeMap, sync::Arc};

#[derive(Clone)]
Expand Down Expand Up @@ -110,13 +111,16 @@ pub fn enodes_to_pub_keys(enodes: &Vec<Enode>) -> Arc<BTreeMap<Public, KeyPairWr
)
}

#[serde_as]
#[derive(Serialize, Deserialize)]
pub struct KeyGenHistoryData {
validators: Vec<String>,
staking_addresses: Vec<String>,
public_keys: Vec<String>,
ip_addresses: Vec<String>,
#[serde_as(as = "Vec<serde_with::hex::Hex>")]
parts: Vec<Vec<u8>>,
#[serde_as(as = "Vec<Vec<serde_with::hex::Hex>>")]
acks: Vec<Vec<Vec<u8>>>,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ extern crate rand;
extern crate rustc_hex;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate toml;

mod keygen_history_helpers;
Expand Down
10 changes: 7 additions & 3 deletions crates/ethcore/src/engines/hbbft/hbbft_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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())?);

Expand All @@ -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(());
Expand Down

0 comments on commit c69c572

Please sign in to comment.