Fix a few new Clippy lints, and some broken dependencies.
This commit is contained in:
Andreas Fackler 2020-03-12 12:28:07 +01:00 committed by Andreas Fackler
parent 3b1f587521
commit d52be00d0e
11 changed files with 42 additions and 45 deletions

View File

@ -1,6 +1,6 @@
language: rust
rust:
- 1.36.0
- 1.42.0
cache:
cargo: true
timeout: 2400

View File

@ -23,7 +23,7 @@ travis-ci = { repository = "poanetwork/hbbft" }
[dependencies]
bincode = "1.2.0"
byteorder = "1.3.2"
derivative = "1.0.3"
derivative = "2.0.2"
env_logger = "0.7.1"
failure = "0.1.6"
hex_fmt = "0.3"
@ -31,7 +31,7 @@ init_with = "1.1.0"
log = "0.4.8"
rand = "0.6.5"
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"] }
threshold_crypto = { rev = "624eeee", git = "https://github.com/poanetwork/threshold_crypto" }
tiny-keccak = { version = "2.0.1", features = ["sha3"]}
@ -42,8 +42,8 @@ crossbeam = "0.7.3"
crossbeam-channel = "0.4.0"
docopt = "1.1.0"
hbbft_testing = { path = "hbbft_testing", features = ["use-insecure-test-only-mock-crypto"] }
itertools = "0.8.1"
signifix = "0.10.0"
itertools = "0.9.0"
number_prefix = "0.3.0"
proptest = "0.9.4"
[[example]]
@ -60,6 +60,4 @@ overflow-checks = true
[features]
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
# resolved.
no-simd = ["reed-solomon-erasure/pure-rust"]
simd-accel = ["reed-solomon-erasure/simd-accel"]

View File

@ -9,21 +9,18 @@
//! use std::net::SocketAddr;
//! use std::vec::Vec;
//!
//! fn main() {
//! let bind_address = "127.0.0.1:10001".parse().unwrap();
//! let remote_addresses = vec!["192.168.1.2:10002",
//! "192.168.1.3:10003",
//! "192.168.1.4:10004"]
//! .iter()
//! .map(|s| s.parse().unwrap())
//! .collect();
//! let bind_address = "127.0.0.1:10001".parse().unwrap();
//! let remote_addresses = vec!["192.168.1.2:10002",
//! "192.168.1.3:10003",
//! "192.168.1.4:10004"]
//! .iter()
//! .map(|s| s.parse().unwrap())
//! .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))
//! .run();
//! println!("Consensus result {:?}", result);
//! }
//! let result = Node::new(bind_address, remote_addresses, Some(value)).run();
//! println!("Consensus result {:?}", result);
//! ```
//!
//! Similar code shall then run on hosts 192.168.1.2, 192.168.1.3 and

View File

@ -1,15 +1,14 @@
use std::collections::{BTreeMap, VecDeque};
use std::convert::TryFrom;
use std::time::{Duration, Instant};
use std::{cmp, u64};
use colored::*;
use docopt::Docopt;
use itertools::Itertools;
use number_prefix::{NumberPrefix, Prefixed, Standalone};
use rand::{distributions::Standard, rngs::OsRng, seq::SliceRandom, Rng};
use rand_derive::Rand;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use signifix::metric;
use hbbft::crypto::SecretKey;
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,
txs,
network.message_count() / network.nodes.len(),
metric::Signifix::try_from(network.message_size() / network.nodes.len() as u64)
.unwrap(),
match NumberPrefix::decimal(network.message_size() as f64 / network.nodes.len() as f64)
{
Standalone(bytes) => format!("{:3.0} ", bytes),
Prefixed(prefix, n) => format!("{:3.0} {}", n, prefix),
}
);
}
}

View File

@ -151,7 +151,7 @@ impl ValueTree for NetworkDimensionTree {
self.high = self.current;
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 {
@ -164,7 +164,7 @@ impl ValueTree for NetworkDimensionTree {
self.low = self.current + 1;
self.current = (self.low + self.high) / 2;
(prev.current != self.current || prev.low != self.low)
prev.current != self.current || prev.low != self.low
}
}

View File

@ -8,7 +8,7 @@ use hex_fmt::{HexFmt, HexList};
use log::{debug, warn};
use rand::Rng;
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::message::HexProof;
@ -638,7 +638,7 @@ impl<N: NodeIdT> fmt::Display for Broadcast<N> {
#[derive(Debug)]
enum Coding {
/// 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.
Trivial(usize),
}
@ -681,7 +681,7 @@ impl Coding {
/// If enough shards are present, reconstructs the missing ones.
fn reconstruct_shards(&self, shards: &mut [Option<Box<[u8]>>]) -> RseResult<()> {
match *self {
Coding::ReedSolomon(ref rs) => rs.reconstruct_shards(shards),
Coding::ReedSolomon(ref rs) => rs.reconstruct(shards),
Coding::Trivial(_) => {
if shards.iter().all(Option::is_some) {
Ok(())

View File

@ -1,3 +1,4 @@
use std::cmp::Ordering;
use std::collections::BTreeMap;
use std::sync::Arc;
use std::{fmt, result};
@ -235,8 +236,12 @@ where
message: Message<N>,
rng: &mut R,
) -> Result<Step<C, N>> {
if message.era() == self.era {
match message {
match message.era().cmp(&self.era) {
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) => {
self.handle_honey_badger_message(sender_id, hb_msg, rng)
}
@ -247,12 +252,7 @@ where
.vote_counter
.add_pending_vote(sender_id, signed_vote)
.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())
},
}
}

View File

@ -125,7 +125,7 @@ fn test_broadcast<A: Adversary<Broadcast<NodeId>>>(
// verify that all other correct nodes have empty output as well.
let first = net
.correct_nodes()
.nth(0)
.next()
.expect("At least one correct node needs to exist");
assert!(first.outputs().is_empty());
break;
@ -136,7 +136,7 @@ fn test_broadcast<A: Adversary<Broadcast<NodeId>>>(
if proposer_is_faulty {
// 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));
} else {
// In the case where the proposer was valid it must be the value it proposed.

View File

@ -41,7 +41,7 @@ where
// Make two copies of all public keys.
let pub_keys_add = net
.correct_nodes()
.nth(0)
.next()
.expect("At least one correct node needs to exist")
.algorithm()
.algo()
@ -52,7 +52,7 @@ where
let mut pub_keys_rm = pub_keys_add.clone();
// 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.
Arc::make_mut(&mut pub_keys_rm).remove(&first_correct_node);

View File

@ -40,7 +40,7 @@ fn test_subset<A>(
// or drop this TODO if we decide to abandon that concept.
let expected_value: BTreeSet<_> = net
.correct_nodes()
.nth(0)
.next()
.unwrap()
.outputs()
.iter()

View File

@ -66,7 +66,7 @@ where
while !net.nodes().all(|node| node.algorithm().terminated()) {
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.
assert_eq!(1, node0.outputs().len());
assert!(net.nodes().all(|node| node.outputs() == node0.outputs()));
@ -136,7 +136,7 @@ where
while !net.nodes().all(|node| node.algorithm().terminated()) {
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.
assert_eq!(1, node0.outputs().len());
assert!(net.nodes().all(|node| node.outputs() == node0.outputs()));