Commit Graph

36 Commits

Author SHA1 Message Date
Andreas Fackler d52be00d0e Fix CI.
Fix a few new Clippy lints, and some broken dependencies.
2020-03-20 10:37:31 +01:00
Andreas Fackler 4e525432c8 Test that self is always omitted from Target. 2019-09-17 09:55:59 +02:00
Andreas Fackler d15467eb09 Remove NetworkInfo from Broadcast. 2019-08-27 20:51:24 +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 bd74cc2fa9 Use Rust 2018 idioms consistently.
Apply `cargo fix --edition-idioms`.
2019-01-09 11:56:40 +01:00
Andreas Fackler 87b1d45d97 Rename DistAlgorithm to ConsensusProtocol. 2019-01-08 14:14:34 +01:00
phahulin 5bfcd6c692 Split FaultKind. (#371) 2019-01-02 13:55:50 +03:00
Andreas Fackler 8689e6501e Remove impossible Reed-Solomon errors. 2018-12-18 09:58:59 +01:00
Andreas Fackler 7677f6343c Remove unwrap and expect calls from production code. 2018-12-17 15:38:18 +01:00
Marc Brinkmann eafa77d5fc OsRng / external RNG Refactoring (#357)
* Use `OsRng` in place of `thread_rng`.

This changes the defaults of any builder by instantiating an `OsRng` instead of
a `thread_rng`, the former being much more secure than the latter.

Additionally, all the unit tests that still instantiate RNGs manually used `OsRng`s
as well; while there is no actual need for this level of security in tests, the performance overhead is very small and random number generation complexity has such a small impact on these tests that the convenience of being able to ban `thread_rng` from the codebase altogether, setting a good example and avoid issues when refactoring later greatly outweigh the negatives.

* Instead of storing random number generators in the various consensus algorithm instances, pass them in from the outside whenever they are needed.

This changes a large amount of interfaces (and in this commit is only partially done, since `DistAlgorithm` needs to be fundamentally altered as well.

It also obsoletes parts of the `util` module.

* Added an `R: Rng` type parameter to both methods of `DistAlgorithm`, forcing callers to pass in their own Rngs.

* Fixed documentation grammar and spelling in some of the altered interfaces due to RNG refactoring.

* Move `rng` argument to the end of the argument for most functions.

Also includes a reformatting due to Rust 1.30.

* Updated tests, accomodate `rng`-API changes.

* Fixed remaining compilation issues with new RNG code.

* Fix illegal `self` import outside curly braces.

* Cleaned up comments and fixed broken definition of `broadcast_input`.

* Updated existing test cases to properly work with static dispatch randomness.

* Do not use boxed `Rng`s for key generation in test networks.

* Use the passed-in `Rng` in `ReorderingAdversary`, instead of storing a boxed one.

* Fixed clippy lints after refactoring.

* Removed some no-longer necessary manual `fmt::Debug` implementations in test framework.

* Use `OsRng` even in tests in `binary_agreement_mitm`.

* Use a proper deterministic RNG in tests `binary_agreement_mitm`.

* Refactor `examples/simulation.rs` by not using `ThreadRng`, passing generic `Rng` parameters throughout and using a type alias instead of a newtype as the `Transaction`.

* Remove `thread_rng` use from `examples/node.rs`.

* Explicitly construct `InternalContrib` in `DynamicHoneyBadger::propose`.

* Fixed typo in description of `DistAlgorithm` trait.
2018-12-14 12:51:09 +00:00
Demi Marie Obenour 7fb172cda2 Switch to 2018 edition idioms (#359)
* Switch to 2018 edition idioms

* Fix build with Rust 2018.

* Remove unnecessary cloning, make `max_faulty` const.

* Remove unneeded `extern crate` statements.
2018-12-11 14:44:36 +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 7f784e7852 Make Step independent of DistAlgorithm. 2018-11-08 08:51:17 +01:00
Andreas Fackler 2456db2d9e Rewrite Subset.
This merges the four maps into a single map, each entry of which tracks
the progress of both the `Broadcast` and the `BinaryAgreement`
subalgorithm for an individual proposer. Two advantages:
* A slight optimization, because the `Broadcast` instance is dropped as
soon as it is not needed anymore.
* The static guarantee that certain impossible situations (inserting a
broadcast value twice) cannot happen.

The module is also split up into smaller files.
2018-11-06 09:21:40 +01:00
Andreas Fackler 13340d7ad0 Remove redundant log statements, minor cleanups. 2018-11-03 15:36:32 +01:00
Andreas Fackler 7e4bffa825 Subset: Remove obsolete TODO.
Just like in `Broadcast`, let's keep the value a `Vec<u8>`. The user
should handle serialization.
2018-10-31 17:18:11 +01:00
Andreas Fackler f536587856 Broadcast: Remove TODO, redundant field.
Since `Broadcast` operates on a `Vec<u8>` anyway, let's not make it
generic in a serializable value. This removes the TODO.

The `data_shard_num` field is also removed; it was redundant now.
2018-10-31 15:51:21 +01:00
Andreas Fackler df36258715 Instead of macro_use, use use. 2018-10-30 08:11:03 +01:00
Andreas Fackler dda2f54a06
Minor improvements to the Step API. (#292)
* Minor improvements to the Step API.

* Make use of DistAlgorithm::our_id.

* Rename Step::and to join.
2018-10-25 14:44:28 +02:00
Andreas Fackler 3981b37fa3 Minor API and documentation improvements. 2018-10-24 17:38:41 +02:00
Andreas Fackler 26ef33e4d1 Return fault on duplicate broadcast values. Remove obsolete TODOs. 2018-10-24 16:20:02 +02:00
Andreas Fackler bc6a67dc01 Extend API to work without DistAlgorithm.
Extends all APIs so that the user doesn't need to import the
`DistAlgorithm` trait.

Also, removes the error on inputting too late into `BinaryAgreement`:
whether the input still matters is an implementation detail.
2018-10-23 22:10:28 +02:00
Andreas Fackler 8a84109c88 Use threshold_crypto 0.2.0-beta2 to fix overflow. (#273)
* Use threshold_crypto 0.2.0-beta1 to fix overflow.

* Upgrade to hex_fmt 0.2.

* Depend on threshold_crypto 0.2.0-beta2.

This avoids depending on two different versions of hex_fmt.
2018-10-17 12:04:13 +02:00
Andreas Fackler 00e1674349 Move Message out of broadcast::broadcast. 2018-10-11 22:24:13 +02:00
Andreas Fackler 7345132066 Replace HexBytes with the hex_fmt crate. 2018-10-11 22:24:13 +02:00
Andreas Fackler 8d1361e6ae Split up messaging module. 2018-10-10 17:29:59 +02:00
Andreas Fackler 058044959f Remove itertools dependency. 2018-09-20 11:38:02 +02:00
Andreas Fackler 05b04bba39 Use Formatter debug helpers. 2018-09-03 23:30:17 +02:00
Marc Brinkmann fc3d578eea
Advance to Rust beta (#221)
Update Rust version to `beta` in CI, paving the way for 1.29 stable.
2018-08-31 15:57:10 +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
Andreas Fackler 51315a56c3 Update docs: missing algorithms, private merkle, whitespace.
* Make the `merkle` module private.
* Make sure the algorithm names are consistent.
* Add the Threshold Decryption and Synchronous Key Generation algorithms
  to the list in the main crate documentation.
* Remove some trailing whitespace from the README.
* Remove checkboxes: all algorithms are implemented.
* Link to the algorithm implementations, not the modules.
* Use relative links in the README.
2018-08-27 17:07:33 +02:00
Andreas Fackler e4ddd6a079 Replace ring with tiny-keccak. 2018-08-10 09:23:27 +02:00
Andreas Fackler b90a7bf450 Replace merkle.rs with custom implementation. 2018-08-10 09:23:27 +02:00
Andreas Fackler 5cc7b54c06 Split up the broadcast module.
Also, rename broadcast and agreement messages to just `Message`.
2018-08-08 15:46:43 +02:00