Skip to content

Commit

Permalink
Fix CI.
Browse files Browse the repository at this point in the history
Fix a few new Clippy lints, and some broken dependencies.
  • Loading branch information
afck committed Mar 20, 2020
1 parent 3b1f587 commit d52be00
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: rust
rust:
- 1.36.0
- 1.42.0
cache:
cargo: true
timeout: 2400
Expand Down
12 changes: 5 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ 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"
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"]}
Expand All @@ -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]]
Expand All @@ -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"]
23 changes: 10 additions & 13 deletions examples/network/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions examples/simulation.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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),
}
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions hbbft_testing/src/proptest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/broadcast/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
}
Expand Down Expand Up @@ -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(())
Expand Down
16 changes: 8 additions & 8 deletions src/dynamic_honey_badger/dynamic_honey_badger.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::cmp::Ordering;
use std::collections::BTreeMap;
use std::sync::Arc;
use std::{fmt, result};
Expand Down Expand Up @@ -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)
}
Expand All @@ -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())
},
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions tests/queueing_honey_badger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/subset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions tests/threshold_sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down Expand Up @@ -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()));
Expand Down

0 comments on commit d52be00

Please sign in to comment.