Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimized broadcast #309 #405

Merged
merged 35 commits into from
Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
7bdaad9
Added extra message types
pawanjay176 Apr 22, 2019
a09c74b
Add send functions for new message types
pawanjay176 Apr 24, 2019
e19a1fa
Store original value message received from proposer
pawanjay176 Apr 29, 2019
116b3f9
Modify handle_value for optimized broadcast
pawanjay176 Apr 29, 2019
e3e5077
Modify handle_echo for optimized broadcast
pawanjay176 Apr 29, 2019
cb20757
Add handle_echo_hash function for optimized broadcast
pawanjay176 Apr 29, 2019
48b56af
Add handle_can_decode function for optimized broadcast
pawanjay176 Apr 29, 2019
140f6b6
Fixes handle_ready and send_echo functions:
pawanjay176 Apr 29, 2019
876262e
Remove value_message and fix typos
pawanjay176 Apr 30, 2019
b0cfa62
Add functions for filtering all_ids
pawanjay176 May 2, 2019
e7e474c
Separate send_echo to send_echo_left and send_echo_remaining
pawanjay176 May 3, 2019
d568ec3
Rename pessimism_factor to fault_estimate
pawanjay176 May 3, 2019
d1fac6c
Remove redundant bools from Broadcast struct
pawanjay176 May 3, 2019
6670693
Fix multiple counting of nodes who sent both `Echo` and `EchoHash` by…
pawanjay176 May 3, 2019
279c482
Allow conflicting `CanDecode`s from same node
pawanjay176 May 3, 2019
6abc5fe
Fix left and right iterators for `Echo` and `EchoHash` messages
pawanjay176 May 3, 2019
447df73
Fixes bugs in left and right iterators and adds additional checks in …
pawanjay176 May 4, 2019
491d71a
Change can_decodes to BTreeMap<Digest, BTreeSet<N>> and fix send_can_…
pawanjay176 May 4, 2019
2db02d0
Minor fixes
pawanjay176 May 5, 2019
6d3bfc8
Modify send_echo_remaining to take a hash parameter
pawanjay176 May 5, 2019
7565998
Fix bug in left and right iterators.
pawanjay176 May 5, 2019
afbf56a
Fix bug in handle_echo and compute_output
pawanjay176 May 6, 2019
3e45d13
Refactor `echos` map to take an EchoContent Enum for `Echo` and `Echo…
pawanjay176 May 7, 2019
a37be5d
Run rustfmt
pawanjay176 May 7, 2019
a0d6edf
Refactor to avoid index access and multiple map lookups
pawanjay176 May 8, 2019
461a4b1
Fix comments and minor refactorings.
pawanjay176 May 14, 2019
7f46250
Add an`AllExcept(BTreeSet<N>)` type to `Target` enum to enable sendin…
pawanjay176 May 14, 2019
85e8e97
Rename `AllExcept` parameter from `known` to `exclude`.
pawanjay176 May 16, 2019
047fa81
Modify send_can_decode to send to all nodes who haven't sent an `Echo`.
pawanjay176 May 22, 2019
429642a
Update docs for broadcast
pawanjay176 May 25, 2019
9281f40
Improve formatting and add comments for broadcast docs.
pawanjay176 May 28, 2019
4b06774
Fix formatting.
pawanjay176 May 28, 2019
2764e1e
Allow for sending multiple `CanDecode` messages with different hashes.
pawanjay176 Jun 3, 2019
b9adbab
Fix comments.
pawanjay176 Jun 3, 2019
851f144
Fix bug in sending `Echo`s when node has not received `CanDecode`.
pawanjay176 Jun 12, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions examples/network/messaging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use crossbeam::thread::{Scope, ScopedJoinHandle};
use crossbeam_channel::{self, bounded, select, unbounded, Receiver, Sender};
use hbbft::{SourcedMessage, Target, TargetedMessage};
use std::collections::BTreeSet;

/// The queue functionality for messages sent between algorithm instances.
/// The messaging struct allows for targeted message exchange between comms
Expand Down Expand Up @@ -107,7 +108,7 @@ impl<M: Send> Messaging<M> {
select! {
recv(rx_from_algo) -> tm => {
if let Ok(tm) = tm {
match tm.target {
match &tm.target {
Target::All => {
// Send the message to all remote nodes, stopping at the first
// error.
Expand All @@ -120,9 +121,26 @@ impl<M: Send> Messaging<M> {
}
}).map_err(Error::from);
},
Target::AllExcept(exclude) => {
// Send the message to all remote nodes not in `exclude`, stopping at the first
// error.
let filtered_txs: Vec<_> = (0..txs_to_comms.len())
.collect::<BTreeSet<_>>()
.difference(exclude)
.cloned()
.collect();
result = filtered_txs.iter()
.fold(Ok(()), |result, i| {
if result.is_ok() {
txs_to_comms[*i].send(tm.message.clone())
} else {
result
}
}).map_err(Error::from);
},
Target::Node(i) => {
result = if i < txs_to_comms.len() {
txs_to_comms[i].send(tm.message)
result = if *i < txs_to_comms.len() {
txs_to_comms[*i].send(tm.message)
.map_err(Error::from)
} else {
Err(Error::NoSuchTarget)
Expand Down
9 changes: 8 additions & 1 deletion examples/simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,21 @@ where
Q: IntoIterator<Item = TimestampedMessage<D>>,
{
for ts_msg in msgs {
match ts_msg.target {
match &ts_msg.target {
Target::All => {
for node in self.nodes.values_mut() {
if node.id != ts_msg.sender_id {
node.add_message(ts_msg.clone())
}
}
}
Target::AllExcept(exclude) => {
for node in self.nodes.values_mut().filter(|n| !exclude.contains(&n.id)) {
if node.id != ts_msg.sender_id {
node.add_message(ts_msg.clone())
}
}
}
Target::Node(to_id) => {
if let Some(node) = self.nodes.get_mut(&to_id) {
node.add_message(ts_msg);
Expand Down
16 changes: 16 additions & 0 deletions hbbft_testing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,22 @@ where
message_count = message_count.saturating_add(1);
}

dest.push_back(NetworkMessage::new(
stepped_id.clone(),
tmsg.message.clone(),
to.clone(),
));
}
}
hbbft::Target::AllExcept(exclude) => {
for to in nodes
.keys()
.filter(|&to| to != &stepped_id && !exclude.contains(to))
{
if !faulty {
message_count = message_count.saturating_add(1);
}

dest.push_back(NetworkMessage::new(
stepped_id.clone(),
tmsg.message.clone(),
Expand Down
Loading