mirror of https://github.com/poanetwork/hbbft.git
Fix CI.
Fix a few new Clippy lints, and some broken dependencies.
This commit is contained in:
parent
3b1f587521
commit
d52be00d0e
|
@ -1,6 +1,6 @@
|
||||||
language: rust
|
language: rust
|
||||||
rust:
|
rust:
|
||||||
- 1.36.0
|
- 1.42.0
|
||||||
cache:
|
cache:
|
||||||
cargo: true
|
cargo: true
|
||||||
timeout: 2400
|
timeout: 2400
|
||||||
|
|
12
Cargo.toml
12
Cargo.toml
|
@ -23,7 +23,7 @@ travis-ci = { repository = "poanetwork/hbbft" }
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bincode = "1.2.0"
|
bincode = "1.2.0"
|
||||||
byteorder = "1.3.2"
|
byteorder = "1.3.2"
|
||||||
derivative = "1.0.3"
|
derivative = "2.0.2"
|
||||||
env_logger = "0.7.1"
|
env_logger = "0.7.1"
|
||||||
failure = "0.1.6"
|
failure = "0.1.6"
|
||||||
hex_fmt = "0.3"
|
hex_fmt = "0.3"
|
||||||
|
@ -31,7 +31,7 @@ init_with = "1.1.0"
|
||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
rand = "0.6.5"
|
rand = "0.6.5"
|
||||||
rand_derive = "0.5.0"
|
rand_derive = "0.5.0"
|
||||||
reed-solomon-erasure = "3.1.1"
|
reed-solomon-erasure = "4.0.1"
|
||||||
serde = { version = "1.0.102", features = ["derive", "rc"] }
|
serde = { version = "1.0.102", features = ["derive", "rc"] }
|
||||||
threshold_crypto = { rev = "624eeee", git = "https://github.com/poanetwork/threshold_crypto" }
|
threshold_crypto = { rev = "624eeee", git = "https://github.com/poanetwork/threshold_crypto" }
|
||||||
tiny-keccak = { version = "2.0.1", features = ["sha3"]}
|
tiny-keccak = { version = "2.0.1", features = ["sha3"]}
|
||||||
|
@ -42,8 +42,8 @@ crossbeam = "0.7.3"
|
||||||
crossbeam-channel = "0.4.0"
|
crossbeam-channel = "0.4.0"
|
||||||
docopt = "1.1.0"
|
docopt = "1.1.0"
|
||||||
hbbft_testing = { path = "hbbft_testing", features = ["use-insecure-test-only-mock-crypto"] }
|
hbbft_testing = { path = "hbbft_testing", features = ["use-insecure-test-only-mock-crypto"] }
|
||||||
itertools = "0.8.1"
|
itertools = "0.9.0"
|
||||||
signifix = "0.10.0"
|
number_prefix = "0.3.0"
|
||||||
proptest = "0.9.4"
|
proptest = "0.9.4"
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
|
@ -60,6 +60,4 @@ overflow-checks = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
use-insecure-test-only-mock-crypto = ["threshold_crypto/use-insecure-test-only-mock-crypto"]
|
use-insecure-test-only-mock-crypto = ["threshold_crypto/use-insecure-test-only-mock-crypto"]
|
||||||
# TODO: Remove this feature once https://github.com/darrenldl/reed-solomon-erasure/issues/28 is
|
simd-accel = ["reed-solomon-erasure/simd-accel"]
|
||||||
# resolved.
|
|
||||||
no-simd = ["reed-solomon-erasure/pure-rust"]
|
|
||||||
|
|
|
@ -9,21 +9,18 @@
|
||||||
//! use std::net::SocketAddr;
|
//! use std::net::SocketAddr;
|
||||||
//! use std::vec::Vec;
|
//! use std::vec::Vec;
|
||||||
//!
|
//!
|
||||||
//! fn main() {
|
//! let bind_address = "127.0.0.1:10001".parse().unwrap();
|
||||||
//! let bind_address = "127.0.0.1:10001".parse().unwrap();
|
//! let remote_addresses = vec!["192.168.1.2:10002",
|
||||||
//! let remote_addresses = vec!["192.168.1.2:10002",
|
//! "192.168.1.3:10003",
|
||||||
//! "192.168.1.3:10003",
|
//! "192.168.1.4:10004"]
|
||||||
//! "192.168.1.4:10004"]
|
//! .iter()
|
||||||
//! .iter()
|
//! .map(|s| s.parse().unwrap())
|
||||||
//! .map(|s| s.parse().unwrap())
|
//! .collect();
|
||||||
//! .collect();
|
|
||||||
//!
|
//!
|
||||||
//! let value = "Value #1".as_bytes().to_vec();
|
//! let value = "Value #1".as_bytes().to_vec();
|
||||||
//!
|
//!
|
||||||
//! let result = Node::new(bind_address, remote_addresses, Some(value))
|
//! let result = Node::new(bind_address, remote_addresses, Some(value)).run();
|
||||||
//! .run();
|
//! println!("Consensus result {:?}", result);
|
||||||
//! println!("Consensus result {:?}", result);
|
|
||||||
//! }
|
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! Similar code shall then run on hosts 192.168.1.2, 192.168.1.3 and
|
//! Similar code shall then run on hosts 192.168.1.2, 192.168.1.3 and
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
use std::collections::{BTreeMap, VecDeque};
|
use std::collections::{BTreeMap, VecDeque};
|
||||||
use std::convert::TryFrom;
|
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
use std::{cmp, u64};
|
use std::{cmp, u64};
|
||||||
|
|
||||||
use colored::*;
|
use colored::*;
|
||||||
use docopt::Docopt;
|
use docopt::Docopt;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
use number_prefix::{NumberPrefix, Prefixed, Standalone};
|
||||||
use rand::{distributions::Standard, rngs::OsRng, seq::SliceRandom, Rng};
|
use rand::{distributions::Standard, rngs::OsRng, seq::SliceRandom, Rng};
|
||||||
use rand_derive::Rand;
|
use rand_derive::Rand;
|
||||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
||||||
use signifix::metric;
|
|
||||||
|
|
||||||
use hbbft::crypto::SecretKey;
|
use hbbft::crypto::SecretKey;
|
||||||
use hbbft::dynamic_honey_badger::DynamicHoneyBadger;
|
use hbbft::dynamic_honey_badger::DynamicHoneyBadger;
|
||||||
|
@ -362,8 +361,11 @@ impl EpochInfo {
|
||||||
max_t.as_secs() * 1000 + u64::from(max_t.subsec_nanos()) / 1_000_000,
|
max_t.as_secs() * 1000 + u64::from(max_t.subsec_nanos()) / 1_000_000,
|
||||||
txs,
|
txs,
|
||||||
network.message_count() / network.nodes.len(),
|
network.message_count() / network.nodes.len(),
|
||||||
metric::Signifix::try_from(network.message_size() / network.nodes.len() as u64)
|
match NumberPrefix::decimal(network.message_size() as f64 / network.nodes.len() as f64)
|
||||||
.unwrap(),
|
{
|
||||||
|
Standalone(bytes) => format!("{:3.0} ", bytes),
|
||||||
|
Prefixed(prefix, n) => format!("{:3.0} {}", n, prefix),
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,7 +151,7 @@ impl ValueTree for NetworkDimensionTree {
|
||||||
self.high = self.current;
|
self.high = self.current;
|
||||||
self.current = (self.low + self.high) / 2;
|
self.current = (self.low + self.high) / 2;
|
||||||
|
|
||||||
(prev.high != self.high || prev.current != self.current)
|
prev.high != self.high || prev.current != self.current
|
||||||
}
|
}
|
||||||
|
|
||||||
fn complicate(&mut self) -> bool {
|
fn complicate(&mut self) -> bool {
|
||||||
|
@ -164,7 +164,7 @@ impl ValueTree for NetworkDimensionTree {
|
||||||
self.low = self.current + 1;
|
self.low = self.current + 1;
|
||||||
self.current = (self.low + self.high) / 2;
|
self.current = (self.low + self.high) / 2;
|
||||||
|
|
||||||
(prev.current != self.current || prev.low != self.low)
|
prev.current != self.current || prev.low != self.low
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use hex_fmt::{HexFmt, HexList};
|
||||||
use log::{debug, warn};
|
use log::{debug, warn};
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use reed_solomon_erasure as rse;
|
use reed_solomon_erasure as rse;
|
||||||
use reed_solomon_erasure::ReedSolomon;
|
use reed_solomon_erasure::{galois_8::Field as Field8, ReedSolomon};
|
||||||
|
|
||||||
use super::merkle::{Digest, MerkleTree, Proof};
|
use super::merkle::{Digest, MerkleTree, Proof};
|
||||||
use super::message::HexProof;
|
use super::message::HexProof;
|
||||||
|
@ -638,7 +638,7 @@ impl<N: NodeIdT> fmt::Display for Broadcast<N> {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum Coding {
|
enum Coding {
|
||||||
/// A `ReedSolomon` instance with at least one parity shard.
|
/// A `ReedSolomon` instance with at least one parity shard.
|
||||||
ReedSolomon(Box<ReedSolomon>),
|
ReedSolomon(Box<ReedSolomon<Field8>>),
|
||||||
/// A no-op replacement that doesn't encode or decode anything.
|
/// A no-op replacement that doesn't encode or decode anything.
|
||||||
Trivial(usize),
|
Trivial(usize),
|
||||||
}
|
}
|
||||||
|
@ -681,7 +681,7 @@ impl Coding {
|
||||||
/// If enough shards are present, reconstructs the missing ones.
|
/// If enough shards are present, reconstructs the missing ones.
|
||||||
fn reconstruct_shards(&self, shards: &mut [Option<Box<[u8]>>]) -> RseResult<()> {
|
fn reconstruct_shards(&self, shards: &mut [Option<Box<[u8]>>]) -> RseResult<()> {
|
||||||
match *self {
|
match *self {
|
||||||
Coding::ReedSolomon(ref rs) => rs.reconstruct_shards(shards),
|
Coding::ReedSolomon(ref rs) => rs.reconstruct(shards),
|
||||||
Coding::Trivial(_) => {
|
Coding::Trivial(_) => {
|
||||||
if shards.iter().all(Option::is_some) {
|
if shards.iter().all(Option::is_some) {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use std::cmp::Ordering;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::{fmt, result};
|
use std::{fmt, result};
|
||||||
|
@ -235,8 +236,12 @@ where
|
||||||
message: Message<N>,
|
message: Message<N>,
|
||||||
rng: &mut R,
|
rng: &mut R,
|
||||||
) -> Result<Step<C, N>> {
|
) -> Result<Step<C, N>> {
|
||||||
if message.era() == self.era {
|
match message.era().cmp(&self.era) {
|
||||||
match message {
|
Ordering::Greater => {
|
||||||
|
Ok(Fault::new(sender_id.clone(), FaultKind::UnexpectedDhbMessageEra).into())
|
||||||
|
}
|
||||||
|
Ordering::Less => Ok(Step::default()), // The message is late; discard it.
|
||||||
|
Ordering::Equal => match message {
|
||||||
Message::HoneyBadger(_, hb_msg) => {
|
Message::HoneyBadger(_, hb_msg) => {
|
||||||
self.handle_honey_badger_message(sender_id, hb_msg, rng)
|
self.handle_honey_badger_message(sender_id, hb_msg, rng)
|
||||||
}
|
}
|
||||||
|
@ -247,12 +252,7 @@ where
|
||||||
.vote_counter
|
.vote_counter
|
||||||
.add_pending_vote(sender_id, signed_vote)
|
.add_pending_vote(sender_id, signed_vote)
|
||||||
.map(FaultLog::into),
|
.map(FaultLog::into),
|
||||||
}
|
},
|
||||||
} else if message.era() > self.era {
|
|
||||||
Ok(Fault::new(sender_id.clone(), FaultKind::UnexpectedDhbMessageEra).into())
|
|
||||||
} else {
|
|
||||||
// The message is late; discard it.
|
|
||||||
Ok(Step::default())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ fn test_broadcast<A: Adversary<Broadcast<NodeId>>>(
|
||||||
// verify that all other correct nodes have empty output as well.
|
// verify that all other correct nodes have empty output as well.
|
||||||
let first = net
|
let first = net
|
||||||
.correct_nodes()
|
.correct_nodes()
|
||||||
.nth(0)
|
.next()
|
||||||
.expect("At least one correct node needs to exist");
|
.expect("At least one correct node needs to exist");
|
||||||
assert!(first.outputs().is_empty());
|
assert!(first.outputs().is_empty());
|
||||||
break;
|
break;
|
||||||
|
@ -136,7 +136,7 @@ fn test_broadcast<A: Adversary<Broadcast<NodeId>>>(
|
||||||
|
|
||||||
if proposer_is_faulty {
|
if proposer_is_faulty {
|
||||||
// If the proposer was faulty it is sufficient for all correct nodes having the same value.
|
// If the proposer was faulty it is sufficient for all correct nodes having the same value.
|
||||||
let first = net.correct_nodes().nth(0).unwrap().outputs();
|
let first = net.correct_nodes().next().unwrap().outputs();
|
||||||
assert!(net.nodes().all(|node| node.outputs() == first));
|
assert!(net.nodes().all(|node| node.outputs() == first));
|
||||||
} else {
|
} else {
|
||||||
// In the case where the proposer was valid it must be the value it proposed.
|
// In the case where the proposer was valid it must be the value it proposed.
|
||||||
|
|
|
@ -41,7 +41,7 @@ where
|
||||||
// Make two copies of all public keys.
|
// Make two copies of all public keys.
|
||||||
let pub_keys_add = net
|
let pub_keys_add = net
|
||||||
.correct_nodes()
|
.correct_nodes()
|
||||||
.nth(0)
|
.next()
|
||||||
.expect("At least one correct node needs to exist")
|
.expect("At least one correct node needs to exist")
|
||||||
.algorithm()
|
.algorithm()
|
||||||
.algo()
|
.algo()
|
||||||
|
@ -52,7 +52,7 @@ where
|
||||||
let mut pub_keys_rm = pub_keys_add.clone();
|
let mut pub_keys_rm = pub_keys_add.clone();
|
||||||
|
|
||||||
// Get the first correct node id as candidate for removal/re-adding.
|
// Get the first correct node id as candidate for removal/re-adding.
|
||||||
let first_correct_node = *net.correct_nodes().nth(0).unwrap().id();
|
let first_correct_node = *net.correct_nodes().next().unwrap().id();
|
||||||
|
|
||||||
// Remove the first correct node, which is to be removed.
|
// Remove the first correct node, which is to be removed.
|
||||||
Arc::make_mut(&mut pub_keys_rm).remove(&first_correct_node);
|
Arc::make_mut(&mut pub_keys_rm).remove(&first_correct_node);
|
||||||
|
|
|
@ -40,7 +40,7 @@ fn test_subset<A>(
|
||||||
// or drop this TODO if we decide to abandon that concept.
|
// or drop this TODO if we decide to abandon that concept.
|
||||||
let expected_value: BTreeSet<_> = net
|
let expected_value: BTreeSet<_> = net
|
||||||
.correct_nodes()
|
.correct_nodes()
|
||||||
.nth(0)
|
.next()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.outputs()
|
.outputs()
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
@ -66,7 +66,7 @@ where
|
||||||
while !net.nodes().all(|node| node.algorithm().terminated()) {
|
while !net.nodes().all(|node| node.algorithm().terminated()) {
|
||||||
let _ = net.crank_expect(&mut rng);
|
let _ = net.crank_expect(&mut rng);
|
||||||
}
|
}
|
||||||
let node0 = net.correct_nodes().nth(0).unwrap();
|
let node0 = net.correct_nodes().next().unwrap();
|
||||||
// Verify that all instances output the same value.
|
// Verify that all instances output the same value.
|
||||||
assert_eq!(1, node0.outputs().len());
|
assert_eq!(1, node0.outputs().len());
|
||||||
assert!(net.nodes().all(|node| node.outputs() == node0.outputs()));
|
assert!(net.nodes().all(|node| node.outputs() == node0.outputs()));
|
||||||
|
@ -136,7 +136,7 @@ where
|
||||||
while !net.nodes().all(|node| node.algorithm().terminated()) {
|
while !net.nodes().all(|node| node.algorithm().terminated()) {
|
||||||
let _ = net.crank_expect(&mut rng);
|
let _ = net.crank_expect(&mut rng);
|
||||||
}
|
}
|
||||||
let node0 = net.correct_nodes().nth(0).unwrap();
|
let node0 = net.correct_nodes().next().unwrap();
|
||||||
// Verify that all instances output the same value.
|
// Verify that all instances output the same value.
|
||||||
assert_eq!(1, node0.outputs().len());
|
assert_eq!(1, node0.outputs().len());
|
||||||
assert!(net.nodes().all(|node| node.outputs() == node0.outputs()));
|
assert!(net.nodes().all(|node| node.outputs() == node0.outputs()));
|
||||||
|
|
Loading…
Reference in New Issue