Commit Graph

80 Commits

Author SHA1 Message Date
Andreas Fackler 9d6b851466 Accept FnOnce/FnMut where possible. 2019-09-26 12:52:26 +02:00
Andreas Fackler 0e51bb3615 Change the `Target` variants.
`Target` now only has a `Nodes` and an `AllExcept` variant, to specify
a message's target via a whitelist or blacklist. This avoids cloning
the message content and simplifies the code in several places.
2019-07-29 12:08:54 +02:00
Pawan Dhananjay 61f4ed9800 Optimized broadcast #309 (#405)
* Added extra message types

* Add send functions for new message types

* Store original value message received from proposer

* Modify handle_value for optimized broadcast

* Modify handle_echo for optimized broadcast

* Add handle_echo_hash function for optimized broadcast

* Add handle_can_decode function for optimized broadcast

* Fixes handle_ready and send_echo functions:
1) Modify handle_ready function for optimized broadcast
2) Modify send_echo function to send `Echo` messages to different subset of nodes from
handle_value and handle_ready functions

* Remove value_message and fix typos

* Add functions for filtering all_ids

* Separate send_echo to send_echo_left and send_echo_remaining

* Rename pessimism_factor to fault_estimate

* Remove redundant bools from Broadcast struct

* Fix multiple counting of nodes who sent both `Echo` and `EchoHash` by changing
`echos` map structure

* Allow conflicting `CanDecode`s from same node

* Fix left and right iterators for `Echo` and `EchoHash` messages

* Fixes bugs in left and right iterators and adds additional checks in handle
functions

* Change can_decodes to BTreeMap<Digest, BTreeSet<N>> and fix send_can_decode

* Minor fixes

* Modify send_echo_remaining to take a hash parameter

* Fix bug in left and right iterators.

* Excluding proposer in iterator led to infinite loop when our_id == proposer_id

* Fix bug in handle_echo and compute_output
* send_can_decode call in handle_echo returned early
* compute_output needed `N - f` full `Echo`s to decode

* Refactor `echos` map to take an EchoContent Enum for `Echo` and `EchoHash` messages

* Run rustfmt

* Refactor to avoid index access and multiple map lookups

* Fix comments and minor refactorings.

* Add an`AllExcept(BTreeSet<N>)` type to `Target` enum to enable sending messages
to non-validators from Broadcast.
* Use `Target::AllExcept` in Broadcast to send `Echo` messages to all non-validator nodes.
* Add `AllExcept(_)` match arms for `Target` match expressions.

* Rename `AllExcept` parameter from `known` to `exclude`.

* Modify send_can_decode to send to all nodes who haven't sent an `Echo`.

* Update docs for broadcast

* Improve formatting and add comments for broadcast docs.

* Fix formatting.

* Allow for sending multiple `CanDecode` messages with different hashes.

* Fix comments.

* Fix bug in sending `Echo`s when node has not received `CanDecode`.
2019-06-12 16:02:39 +01:00
Andreas Fackler 5dc52e0e51 Apply review suggestions. 2018-11-27 12:25:50 +01:00
Andreas Fackler b2071fe2be Extend the documentation, simplify errors.
This changes and adds several doc comments, adds the `missing_docs` lint
and simplifies some of the error types.
2018-11-27 12:25:50 +01:00
Andreas Fackler 8d1361e6ae Split up messaging module. 2018-10-10 17:29:59 +02:00
c0gent 9d3e264b4f Add `Sync` req. on boxed rngs. 2018-10-04 11:42:00 -07:00
Marc Brinkmann 4b00bda555 Make `DistAlgorithm` require `Send`.
Using `hbbft` in other software that is based on frameworks like [tokio](https://tokio.rs), being `Send` is often a requirement on shared data structures.
2018-10-04 17:52:57 +02:00
Marc Brinkmann d2627272fe
Better proptest persistence through deterministic randomness. (#248)
* Add support for RNG instantiation in proptests.

* Use `proptest` module strategy to create the rng for `net_dynamic_honey_badger`.

* Use seed generation instead of RNG instantiation in tests.

* Remove fixed RNG in `generate_map`.

* `VirtualNet` now supports setting the random generator through the builder.

* Add missing `time_limit` field to `::std::fmt::Debug` trait implementation on `NetBuilder`.

* Pass an instantiated random number generator through `NewNodeInfo` as a convenience.

* Make the random number generator of `DynamicHoneyBadgerBuilder` configurable, at the cost of now requiring mutability to call `build_first_node()`.

* Ensure RNGs are derive from passed in seed in `net_dynamic_hb` tests.

* Correct inappropriate use of `random::Random` instead of `Rng::gen` to generate dependent values in `binary_agreement`.

The original implementation used `rand::random()`, which will always use the `thread_rng`, ignoring the fact that an RNG has actually been passed in.

* Do not use `OsRng` but passed in RNG instead.

* Use reference/non-reference passing of rngs more in line with the `rand` crates conventions.

* Document `rng` field on `DynamicHoneyBadger`.

* Make `SyncKeyGen` work with the extend (`encrypt_with_rng`) API of `threshold_crypto`.

* Use passed-in random number generator in `HoneyBadger`.

* Create `SubRng` crate in new `util` module to replace `create_rng()`.

* Use an RNG seeded from the configure RNG when reinitializing `DynamicHoneyBadger`.

* Use the correct branch of `threshold_crypto` with support for passing RNGs.
2018-10-02 16:24:51 +02:00
Andreas Fackler 7276621397 Rename uid to id. 2018-08-29 19:35:52 +02:00
Andreas Fackler f27eed4eef Rename input to handle_input.
Also update `.gitignore` to avoid checking in test logs.
2018-08-29 19:35:52 +02:00
Marc Brinkmann 85550fcf82
New test network implementation (#216)
Added new virtual network implementation for tests.

Added `net::VirtualNet` as an upcoming replacement for the current networking implementation in the test, along with auxiliary functions. The new system allows easier manipulation through implemented adversaries, better reporting and should offer a more friendly API.

Documentation for the functionality can be found in `tests/README.md`.
2018-08-29 10:09:35 +02:00
DrPeterVanNostrand 8ab58d35d4 Added error handling for mlock errors in threshold_crypto crate. 2018-08-09 15:44:36 -04:00
c0gent 697ba6f0a8
Add common supertraits and rename related type parameters.
* Add the `Contribution`, `NodeUidT`, and `Message` supertraits.
* Rename type parameters:
  * `Tx` -> `T` or `C`
  * `NodeUid` -> `N`
2018-08-02 14:52:12 -07:00
Andreas Fackler 3b65f0cead Fix agreement bugs, and refactor a few fields.
* Don't drop `Term` messages from previous epochs. They are still
  relevant for all future epochs.
* Restructure some fields to avoid unnecessary iteration and counting.
* Simplify the fields related to the common coin.
* Reorder the methods, so that the message handlers are all in one
  place.
* Handle the case where the coin value arrives before the required
  number of `Conf` messages.
2018-07-30 11:44:55 +02:00
Andreas Fackler 27898168e2
Merge pull request #163 from poanetwork/afck-queue-fields
Remove queue fields from Agreement, CommonCoin, Broadcast and CommonSubset.
2018-07-26 08:43:07 +02:00
Andreas Fackler 8d449eceb5
Merge pull request #159 from poanetwork/afck-into-fr
Accept more types in threshold crypto API.
2018-07-26 08:31:54 +02:00
Andreas Fackler 9d0f1b3d15 Remove output and message queue from CommonSubset. 2018-07-24 13:12:06 +02:00
Andreas Fackler 30c5805446 Remove output and message queue from CommonCoin. 2018-07-24 11:57:50 +02:00
Andreas Fackler 4327744976 Remove output and message queue from HoneyBadger. 2018-07-23 18:11:45 +02:00
Andreas Fackler 984bb49fdc Accept more types in threshold crypto API.
This removes some unnecessary allocation and conversion by accepting
more primitive types and references as the index in threshold decryption
and signing, and as the argument to a polynomial.
2018-07-23 15:56:45 +02:00
Andreas Fackler 432c865d4b Handle initial QHB messages, fix DHB. 2018-07-21 11:30:43 +02:00
Vladimir Komendantskiy 099fbc999e made Step depend on DistAlgorithm instead of base types 2018-07-20 12:47:19 +01:00
Vladimir Komendantskiy 65b3097238 message queue refactoring WIP 2018-07-20 12:43:15 +01:00
Andreas Fackler 15cc6ffddd Separate keys and key shares. 2018-07-18 14:44:35 +02:00
Vladimir Komendantskiy 22195c4b93 Merge branch 'master' into vk-api-refactor66 2018-07-16 14:20:50 +01:00
Vladimir Komendantskiy c6a0090859 removed cloning of FaultLog 2018-07-16 12:33:00 +01:00
Peter van Nostrand 53a891380f Replaced clear-on-drop with 'std::ptr::write_volatile'. 2018-07-13 20:58:30 -04:00
Vladimir Komendantskiy 92f0602dd7 formatting omission fix 2018-07-12 22:25:44 +01:00
Vladimir Komendantskiy 7fb1017bb1 changed Step::output to Vec but that didn't fix the dynamic HB test 2018-07-12 21:23:52 +01:00
Vladimir Komendantskiy 0ba06fdb76 added step output in DistAlgorithm 2018-07-12 14:54:05 +01:00
Peter van Nostrand 6783ece9b0 Added faulty node logging to algorithms. 2018-07-09 13:45:11 -04:00
Andreas Fackler bbc27e8a66 Update terminology: "observers" and "validators" 2018-07-02 14:14:19 +02:00
Andreas Fackler 2b4f77f11c Avoid redundant key computations. 2018-06-27 14:47:05 +02:00
Andreas Fackler fd8e7a5900 Add DynamicHoneyBadger. 2018-06-26 15:13:04 +02:00
Andreas Fackler f202ccfeb8 Compute is_peer on NetworkInfo creation. 2018-06-26 14:52:53 +02:00
Andreas Fackler 2db67df325 Rename is_full_node to is_peer. 2018-06-26 10:57:44 +02:00
Andreas Fackler 2a5f9f1bfe Allow observer nodes in all algorithms.
This allows nodes to join the network without sending any messages
themselves. They can't give any input and just observe the outcome.

Closes #81
2018-06-26 09:17:12 +02:00
Andreas Fackler 062b35ab3a Make SyncKeyGen NodeUid-aware.
This allows the caller to address nodes by ID instead of by index.

Also contains a few other minor changes that will be needed for
`DynamicHoneyBadger`.
2018-06-25 13:07:31 +02:00
Andreas Fackler e11f183db2 Remove generic E: Engine from crypto. 2018-06-22 10:08:23 +02:00
Peter van Nostrand 05da712c20 Added clear-on-drop secret-keys to 'NetworkInfo'. 2018-06-21 12:08:48 -04:00
Andreas Fackler 66f396e01c Remove more NodeUid trait bounds.
Use a `BTreeMap` instead of `HashMap` in `NetworkInfo`. The number of
nodes can't grow very large anyway.
2018-06-18 16:37:07 +02:00
Andreas Fackler 3f707a8e12 Return proposer info from HoneyBadger.
Also, consistently name generic arguments, and remove some unused trait
bounds.
2018-06-18 16:19:54 +02:00
Vladimir Komendantskiy 3393052b4b review comment coverage 2018-06-14 12:28:38 +01:00
Vladimir Komendantskiy 5008d11ada Revert "the set of node indices of common coin shares is now computed only once"
This reverts commit e9808efc61.
2018-06-14 10:05:05 +01:00
Vladimir Komendantskiy e9808efc61 the set of node indices of common coin shares is now computed only once 2018-06-13 22:05:11 +01:00
Vladimir Komendantskiy d5794cb5fe extended the common coin nonce with a global UID and the top-level epoch 2018-06-13 15:18:27 +01:00
Vladimir Komendantskiy cf45a4e3cb common coin implementation 2018-06-13 15:15:41 +01:00
Vladimir Komendantskiy b6587a21e8 get_coin interface to Common Coin 2018-06-13 15:09:12 +01:00
Vladimir Komendantskiy 17dc9df78e Common Coin module template; added keys in NetworkInfo 2018-06-13 15:09:12 +01:00