Merge branch 'master' into master

This commit is contained in:
Weiliang Li 2019-07-24 09:19:56 +09:00 committed by GitHub
commit d2dc400e42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 29 additions and 18 deletions

View File

@ -1,6 +1,6 @@
language: rust
rust:
- 1.35.0
- 1.36.0
cache:
cargo: true
timeout: 1200

View File

@ -71,7 +71,7 @@ _**Note:** Additional examples are currently in progress._
### Build
Requires Rust 1.30 or higher and `cargo`: [installation instructions.](https://www.rust-lang.org/en-US/install.html) The library is tested against the `stable` release channel.
Requires Rust 1.36 or higher and `cargo`: [installation instructions.](https://www.rust-lang.org/en-US/install.html) The library is tested against the `stable` release channel.
$ cargo build [--release]

6
ci.sh
View File

@ -17,11 +17,13 @@ cargo fmt -- --check
cargo test --features=use-insecure-test-only-mock-crypto --release
cargo doc
cargo deadlinks --dir target/doc/hbbft/
cargo audit
# TODO: Remove exception once https://github.com/poanetwork/hbbft/issues/415 is fixed.
cargo audit --ignore RUSTSEC-2019-0011
cd hbbft_testing
cargo clippy --all-targets -- --deny clippy::all
cargo fmt -- --check
cargo test --release
cargo audit
# TODO: Remove exception once https://github.com/poanetwork/hbbft/issues/415 is fixed.
cargo audit --ignore RUSTSEC-2019-0011
cd ..

View File

@ -434,11 +434,7 @@ fn main() {
let new_honey_badger = |netinfo: NetworkInfo<NodeId>, rng: &mut OsRng| {
let our_id = *netinfo.our_id();
let peer_ids: Vec<_> = netinfo
.all_ids()
.filter(|&&them| them != our_id)
.cloned()
.collect();
let peer_ids: Vec<_> = netinfo.other_ids().cloned().collect();
let dhb = DynamicHoneyBadger::builder().build(netinfo);
let (qhb, qhb_step) = QueueingHoneyBadger::builder(dhb)
.batch_size(args.flag_b)

View File

@ -131,6 +131,16 @@ where
self.epoch
}
/// Skips all epochs before the specified one.
///
/// This must only be called if it is guaranteed to be called in all instances that have not
/// progressed to that epoch yet. Otherwise an instance can be left behind in a skipped epoch.
pub fn skip_to_epoch(&mut self, epoch: u64) {
while self.epoch < epoch {
self.update_epoch();
}
}
/// Returns the number of validators from which we have already received a proposal for the
/// current epoch.
///

View File

@ -86,6 +86,13 @@ impl<N: NodeIdT> NetworkInfo<N> {
self.public_keys.keys()
}
/// ID of all nodes in the network except this one.
#[inline]
pub fn other_ids(&self) -> impl Iterator<Item = &N> + Clone {
let our_id = self.our_id.clone();
self.public_keys.keys().filter(move |id| **id != our_id)
}
/// The total number _N_ of nodes.
#[inline]
pub fn num_nodes(&self) -> usize {

View File

@ -109,11 +109,7 @@ fn do_drop_and_re_add(cfg: TestConfig) {
id
);
let dhb = DynamicHoneyBadger::builder().build(node.netinfo.clone());
SenderQueue::builder(
dhb,
node.netinfo.all_ids().filter(|&&them| them != id).cloned(),
)
.build(node.id)
SenderQueue::builder(dhb, node.netinfo.other_ids().cloned()).build(node.id)
})
.build(&mut rng)
.expect("could not construct test network");

View File

@ -188,12 +188,12 @@ where
fn new_honey_badger(
netinfo: Arc<NetworkInfo<NodeId>>,
) -> (UsizeHoneyBadger, Step<HoneyBadger<Vec<usize>, NodeId>>) {
let our_id = *netinfo.our_id();
let nc = netinfo.clone();
let peer_ids = nc.all_ids().filter(|&&them| them != our_id).cloned();
let peer_ids = nc.other_ids().cloned();
let hb = HoneyBadger::builder(netinfo)
.encryption_schedule(EncryptionSchedule::EveryNthEpoch(2))
.build();
let our_id = *nc.our_id();
SenderQueue::builder(hb, peer_ids).build(our_id)
}

View File

@ -225,13 +225,13 @@ fn new_queueing_hb(
seed: TestRngSeed,
) -> (QHB, Step<QueueingHoneyBadger<usize, NodeId, Vec<usize>>>) {
let mut rng: TestRng = TestRng::from_seed(seed);
let our_id = *netinfo.our_id();
let peer_ids = netinfo.all_ids().filter(|&&them| them != our_id).cloned();
let peer_ids = netinfo.other_ids().cloned();
let dhb = DynamicHoneyBadger::builder().build((*netinfo).clone());
let (qhb, qhb_step) = QueueingHoneyBadger::builder(dhb)
.batch_size(3)
.build(&mut rng)
.expect("failed to build QueueingHoneyBadger");
let our_id = *netinfo.our_id();
let (sq, mut step) = SenderQueue::builder(qhb, peer_ids).build(our_id);
let output = step.extend_with(qhb_step, |fault| fault, Message::from);
assert!(output.is_empty());