mirror of https://github.com/poanetwork/hbbft.git
Merge pull request #36 from poanetwork/afck-rust-update
Update Rust, re-enable rustfmt.
This commit is contained in:
commit
7ad37f9029
|
@ -1,5 +1,6 @@
|
|||
language: rust
|
||||
rust: nightly-2018-04-19
|
||||
rust:
|
||||
- nightly-2018-05-19
|
||||
cache: cargo
|
||||
addons:
|
||||
apt:
|
||||
|
@ -12,18 +13,16 @@ before_install:
|
|||
- protoc --version
|
||||
- rm protoc-3.5.1-linux-x86_64.zip
|
||||
- rustup component add rustfmt-preview
|
||||
- cargo install clippy -f --vers=0.0.195
|
||||
- cargo install clippy -f --vers=0.0.202
|
||||
env:
|
||||
global:
|
||||
- RUST_BACKTRACE=1
|
||||
- RUSTFLAGS="-D warnings"
|
||||
script:
|
||||
# TODO: This currently fails, claiming that `src/proto/message.rs` does not
|
||||
# exist. Re-enable once the problem is resolved.
|
||||
# - cargo fmt -- --write-mode=diff
|
||||
- cargo clippy -- -D clippy
|
||||
- cargo clippy --tests -- -D clippy
|
||||
- cargo clippy --features="serialization-protobuf serialization-serde" -- -D clippy
|
||||
- cargo clippy --features="serialization-protobuf serialization-serde" --tests -- -D clippy
|
||||
- cargo fmt -- --check
|
||||
- cargo check --tests
|
||||
- cargo test
|
||||
|
|
|
@ -48,7 +48,8 @@ fn parse_args() -> Args {
|
|||
None
|
||||
},
|
||||
bind_address: args.get_str("--bind-address").parse().unwrap(),
|
||||
remote_addresses: args.get_vec("--remote-address")
|
||||
remote_addresses: args
|
||||
.get_vec("--remote-address")
|
||||
.iter()
|
||||
.map(|s| s.parse().unwrap())
|
||||
.collect(),
|
||||
|
|
|
@ -181,12 +181,14 @@ where
|
|||
|
||||
/// Handles a queued message in one of the nodes with the earliest timestamp.
|
||||
pub fn step(&mut self) -> NodeUid {
|
||||
let min_time = self.nodes
|
||||
let min_time = self
|
||||
.nodes
|
||||
.values()
|
||||
.filter_map(TestNode::next_event_time)
|
||||
.min()
|
||||
.expect("no more messages in queue");
|
||||
let min_ids: Vec<NodeUid> = self.nodes
|
||||
let min_ids: Vec<NodeUid> = self
|
||||
.nodes
|
||||
.iter()
|
||||
.filter(|(_, node)| node.next_event_time() == Some(min_time))
|
||||
.map(|(id, _)| *id)
|
||||
|
@ -220,7 +222,8 @@ impl EpochInfo {
|
|||
}
|
||||
// TODO: Once bandwidth, CPU time and/or randomized lag are simulated, `min_t` and `max_t`
|
||||
// will probably differ. Print both.
|
||||
let (_min_t, max_t) = self.nodes
|
||||
let (_min_t, max_t) = self
|
||||
.nodes
|
||||
.values()
|
||||
.map(|&(time, _)| time)
|
||||
.minmax()
|
||||
|
|
|
@ -183,7 +183,8 @@ impl<NodeUid: Clone + Debug + Eq + Hash + Ord> Agreement<NodeUid> {
|
|||
.entry(sender_id.clone())
|
||||
.or_insert_with(BTreeSet::new)
|
||||
.insert(b);
|
||||
let count_bval = self.received_bval
|
||||
let count_bval = self
|
||||
.received_bval
|
||||
.values()
|
||||
.filter(|values| values.contains(&b))
|
||||
.count();
|
||||
|
@ -244,7 +245,8 @@ impl<NodeUid: Clone + Debug + Eq + Hash + Ord> Agreement<NodeUid> {
|
|||
/// can, however, expect every good node to send an AUX value that will
|
||||
/// eventually end up in our bin_values.
|
||||
fn count_aux(&self) -> (usize, BTreeSet<bool>) {
|
||||
let (vals_cnt, vals) = self.received_aux
|
||||
let (vals_cnt, vals) = self
|
||||
.received_aux
|
||||
.values()
|
||||
.filter(|b| self.bin_values.contains(b))
|
||||
.tee();
|
||||
|
|
|
@ -355,7 +355,8 @@ impl<N: Eq + Debug + Clone + Ord> Broadcast<N> {
|
|||
/// Checks whether the condition for output are met for this hash, and if so, sets the output
|
||||
/// value.
|
||||
fn compute_output(&mut self, hash: &[u8]) -> BroadcastResult<()> {
|
||||
if self.decided || self.count_readys(hash) <= 2 * self.num_faulty_nodes
|
||||
if self.decided
|
||||
|| self.count_readys(hash) <= 2 * self.num_faulty_nodes
|
||||
|| self.count_echos(hash) <= self.num_faulty_nodes
|
||||
{
|
||||
return Ok(());
|
||||
|
@ -363,7 +364,8 @@ impl<N: Eq + Debug + Clone + Ord> Broadcast<N> {
|
|||
|
||||
// Upon receiving 2f + 1 matching Ready(h) messages, wait for N − 2f Echo messages.
|
||||
self.decided = true;
|
||||
let mut leaf_values: Vec<Option<Box<[u8]>>> = self.all_uids
|
||||
let mut leaf_values: Vec<Option<Box<[u8]>>> = self
|
||||
.all_uids
|
||||
.iter()
|
||||
.map(|id| {
|
||||
self.echos.get(id).and_then(|p| {
|
||||
|
|
|
@ -227,7 +227,8 @@ impl<NodeUid: Clone + Debug + Eq + Hash + Ord> CommonSubset<NodeUid> {
|
|||
F: FnOnce(&mut Broadcast<NodeUid>) -> Result<(), broadcast::Error>,
|
||||
{
|
||||
let value = {
|
||||
let broadcast = self.broadcast_instances
|
||||
let broadcast = self
|
||||
.broadcast_instances
|
||||
.get_mut(proposer_id)
|
||||
.ok_or(ErrorKind::NoSuchBroadcastInstance)?;
|
||||
f(broadcast)?;
|
||||
|
@ -255,7 +256,8 @@ impl<NodeUid: Clone + Debug + Eq + Hash + Ord> CommonSubset<NodeUid> {
|
|||
F: FnOnce(&mut Agreement<NodeUid>) -> Result<(), agreement::Error>,
|
||||
{
|
||||
let value = {
|
||||
let agreement = self.agreement_instances
|
||||
let agreement = self
|
||||
.agreement_instances
|
||||
.get_mut(proposer_id)
|
||||
.ok_or(ErrorKind::NoSuchAgreementInstance)?;
|
||||
if agreement.terminated() {
|
||||
|
@ -269,7 +271,8 @@ impl<NodeUid: Clone + Debug + Eq + Hash + Ord> CommonSubset<NodeUid> {
|
|||
return Ok(());
|
||||
}
|
||||
};
|
||||
if self.agreement_results
|
||||
if self
|
||||
.agreement_results
|
||||
.insert(proposer_id.clone(), value)
|
||||
.is_some()
|
||||
{
|
||||
|
@ -316,7 +319,8 @@ impl<NodeUid: Clone + Debug + Eq + Hash + Ord> CommonSubset<NodeUid> {
|
|||
}
|
||||
debug!("{:?} All Agreement instances have terminated", self.uid);
|
||||
// All instances of Agreement that delivered `true` (or "1" in the paper).
|
||||
let delivered_1: BTreeSet<&NodeUid> = self.agreement_results
|
||||
let delivered_1: BTreeSet<&NodeUid> = self
|
||||
.agreement_results
|
||||
.iter()
|
||||
.filter(|(_, v)| **v)
|
||||
.map(|(k, _)| k)
|
||||
|
@ -324,7 +328,8 @@ impl<NodeUid: Clone + Debug + Eq + Hash + Ord> CommonSubset<NodeUid> {
|
|||
debug!("Agreement instances that delivered 1: {:?}", delivered_1);
|
||||
|
||||
// Results of Broadcast instances in `delivered_1`
|
||||
let broadcast_results: BTreeMap<NodeUid, ProposedValue> = self.broadcast_results
|
||||
let broadcast_results: BTreeMap<NodeUid, ProposedValue> = self
|
||||
.broadcast_results
|
||||
.iter()
|
||||
.filter(|(k, _)| delivered_1.contains(k))
|
||||
.map(|(k, v)| (k.clone(), v.clone()))
|
||||
|
|
|
@ -104,7 +104,12 @@ where
|
|||
N: Eq + Hash + Ord + Clone + Debug,
|
||||
{
|
||||
/// Returns a new Honey Badger instance with the given parameters, starting at epoch `0`.
|
||||
pub fn new<I, TI>(id: N, all_uids_iter: I, batch_size: usize, txs: TI) -> HoneyBadgerResult<Self>
|
||||
pub fn new<I, TI>(
|
||||
id: N,
|
||||
all_uids_iter: I,
|
||||
batch_size: usize,
|
||||
txs: TI,
|
||||
) -> HoneyBadgerResult<Self>
|
||||
where
|
||||
I: IntoIterator<Item = N>,
|
||||
TI: IntoIterator<Item = T>,
|
||||
|
@ -238,7 +243,8 @@ where
|
|||
/// Removes all `CommonSubset` instances from _past_ epochs that have terminated.
|
||||
fn remove_terminated(&mut self, from_epoch: u64) {
|
||||
for epoch in from_epoch..self.epoch {
|
||||
if self.common_subsets
|
||||
if self
|
||||
.common_subsets
|
||||
.get(&epoch)
|
||||
.map_or(false, CommonSubset::terminated)
|
||||
{
|
||||
|
|
|
@ -55,7 +55,8 @@ impl Adversary<Broadcast<NodeUid>> for ProposeAdversary {
|
|||
return vec![];
|
||||
}
|
||||
self.has_sent = true;
|
||||
let node_ids: BTreeSet<NodeUid> = self.adv_nodes
|
||||
let node_ids: BTreeSet<NodeUid> = self
|
||||
.adv_nodes
|
||||
.iter()
|
||||
.chain(self.good_nodes.iter())
|
||||
.cloned()
|
||||
|
|
Loading…
Reference in New Issue