Commit Graph

489 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 3b1f587521 Fix QHB loop with 1 validator. 2020-03-20 10:37:31 +01:00
Andreas Fackler 4857b7f9c7 Sort IDs before assigning them indices in NetworkInfo. 2019-12-20 10:38:29 +01:00
Weiliang Li e43baa4b8b fix some clippy warnings 2019-11-12 11:12:47 +01:00
Weiliang Li d6ffccc06e update tiny-keccak 2019-11-12 11:12:47 +01:00
Weiliang Li 7c213fed71 update Cargo.toml 2019-11-12 11:12:47 +01:00
davidf 2f12266526 Added accessor to "our_id" for SyncKeyGen 2019-10-15 10:17:16 +02:00
Andreas Fackler 9d6b851466 Accept FnOnce/FnMut where possible. 2019-09-26 12:52:26 +02:00
Andreas Fackler 4e525432c8 Test that self is always omitted from Target. 2019-09-17 09:55:59 +02:00
Andreas Fackler 681cf480b0 Clean up threshold sign tests.
Add a test that actually verifies the signature, and refactors the tests
a bit.
2019-09-05 14:04:03 +02:00
Andreas Fackler fe17fc9850 Remove generic ciphertext argument from Part and Ack messages. 2019-09-03 14:17:55 +02:00
Andreas Fackler 824a43100b Make non-threshold crypto in SyncKeyGen pluggable. 2019-09-03 14:17:55 +02:00
Andreas Fackler ab3da7cf64 Validate JoinPlan. 2019-08-27 20:51:24 +02:00
Andreas Fackler 0e50c2f473 Remove non-threshold keys from NetworkInfo. 2019-08-27 20:51:24 +02:00
Andreas Fackler c146634686 Assert matching keys in NetworkInfo. 2019-08-27 20:51:24 +02:00
Andreas Fackler d15467eb09 Remove NetworkInfo from Broadcast. 2019-08-27 20:51:24 +02:00
Andreas Fackler 8ee999b73f Remove unused Step::new. 2019-08-07 12:24:24 +02:00
Weiliang Li 98aad993e0 Update sync_key_gen.rs
Indent code in comments
2019-08-06 09:17:55 +02:00
Andreas Fackler b0e3ad5d4c Pass AllExcept messages unconditionally. 2019-07-29 12:08:54 +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
Weiliang Li 7078387115 Fix unused error in test and fix markdown format error 2019-07-24 15:39:58 +02:00
Andreas Fackler bb17bd7a9c Add NetworkInfo::other_ids. 2019-07-23 13:30:02 +02:00
Andreas Fackler 8122a10179 Add HoneyBadger::skip_to_epoch. 2019-07-23 13:30:02 +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 15f7313706 Extract test framework into hbbft_testing crate. (#404)
* Extract test framework into hbbft_testing crate.

Also update Rust and some dependencies.

* Rename DHB tests.

They are only called `net_dynamic_hb` because we used to have two test
frameworks and two DHB test modules.
2019-04-26 15:54:11 +01:00
Andreas Fackler d83ef9cf67
Fix BA message handling on epoch change.
Binary agreement erroneously kept handling queued incoming messages for
an epoch `n`, even if during the handling, the epoch was incremented to
`n + 1`. This caused `DuplicateAux` faults in the tests, but it could
potentially break consensus.
2019-04-02 14:01:27 +02:00
Vladimir Komendantskiy 10dbf705e4 using serde derive feature 2019-04-02 12:42:51 +02:00
Andreas Fackler 2e046906f9 Don't drop re-added peers from sender queue. (#391)
If a previously removed peer gets added back as a validator,
`SenderQueue` now removes that peer from `last_epochs`, so it doesn't
drop it later.
2019-04-01 10:05:46 +01:00
Andreas Fackler 57455d47ae Fix a SyncKeyGen and a DHB test issue.
`SyncKeyGen` should tolerate duplicate `Part` messages as long as they
are identical.

The `drop_and_re_add` test had an arithmetic overflow, because it tried
to remove more faulty nodes than nodes in total.
2019-03-14 14:09:27 +01:00
C.Solovev 0e7edb2be7 Add `honey_badger` getter for `DynamicHoneyBadger` 2019-02-25 18:43:15 +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
Sebastian Geisler c887b6810b Enable DynamicHoneyBadgers to rejoin after connection loss (#366)
Implementing an epoch setter for the `DynamicHoneyBadgerBuilder` enables the creation of a `DynamicHoneyBadger` that will join the consensus at a given epoch.
2019-01-07 13:31:12 +00:00
Vladimir Komendantskiy 742ad7b83a
Fixes the net_dynamic_hb test (#372)
* started waiting for a full epoch after node removal in net_dynamic_hb

* clarified the use of the stored join plan

* go back to rejoining the node in the same epoch it was removed

* cleanup of debug prints

* clippy lints and more cleanup

* cleaned up unused methods

* review comments; cleaned up net_dynamic_hb

* relaxed the condition on the readd input epoch

* updated the fault error in tests
2019-01-03 09:22:44 +00:00
phahulin 5bfcd6c692 Split FaultKind. (#371) 2019-01-02 13:55:50 +03:00
Andreas Fackler 108ac574bb Migrate to rand 0.6. (#368)
* Migrate to rand 0.6.

* Prefer SliceRandom where it makes sense.
2018-12-27 10:34:34 +01:00
Andreas Fackler 8689e6501e Remove impossible Reed-Solomon errors. 2018-12-18 09:58:59 +01:00
Andreas Fackler ee99aad266 Make Step::extend_with must_use. 2018-12-17 15:38:18 +01:00
Andreas Fackler 7677f6343c Remove unwrap and expect calls from production code. 2018-12-17 15:38:18 +01:00
Vladimir Komendantskiy 14960a148e
Remove peers from sender queue (#352)
* impl. old validator removal from sender queue peer list

* provided current validators for sender queue peer removal

* renamed validators as nodes in the sender queue

* Revert "renamed validators as nodes in the sender queue"

This reverts commit 78e1e1569d5f624c469bf752a5bf874b434a61d2.

* cleaned up the SQ builder and moved removal of old validators to triggers

* computing participant transitions from batches in the sender queue

* added a missing comment

* removing old validators as soon as all messages are delivered up to the last epoch

* review comments

* rejoined Node 0 in the old DHB test

* DHB test uses the first step of the DHB algorithm on the restarted node

* changed test batch verification to account for node 0 removal

* updated net_dynamic_hb test to cope with the removal of node 0

* relaxed verification of batches to only check inclusion of node 0 transactions

* corrected test state transitions in DHB and QHB tests

* added a builder function for a joining QHB

* rejoin the pivot node instead of node 0

* changed VirtualNet::verify_batches to take a full node as an argument

* corrected a variable name

* correction: use the pivot node ID instead of indices

* corrected the pivot node ID

* simplified a find

* simplified a conditional statement

* corrected the inference of expected output in verify_batches

* WIP on DHB and QHB tests; VirtualNet::verify_batches made more general

* readded node 0 in the DHB test when InProgress change is output

* allowed node 0 to miss a few batches while it is removed in the QHB test

* edition and rebase fixes

* refactored the use of process_step

* added VirtualNet functionality of node insertion and removal

* restarting the pivot node after all validators add it as peer

* clippy lints in net_dynamic_hb

* added observer in the QHB test; removed the DHB TestNetwork test

* fixed rng usage in the QHB test

* check output length when verifying batches; comment correction
2018-12-17 13:27:46 +00: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
Andreas Fackler 1c7fc60db9 Add docs and assert that 3 * f < N. (#364) 2018-12-12 13:39:52 +01: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
Vladimir Komendantskiy c1c7ffff49
Added fault checking on every step in the net framework (#338)
* added fault checking in the net framework

* check that the node in the fault report is not faulty

* simplified a condition

* made error on fault a parameter of VirtualNet

* updated the BA test to error on fault

* explained errors and refactored an assignment

* typo fix
2018-12-11 08:12:38 +00:00
Andreas Fackler ceb416a6e1 Make received_proposals public.
We are going to need this if we use `HoneyBadger` directly, to replace
`DynamicHoneyBadger::should_propose`.
2018-12-03 17:51:49 +01:00
Andreas Fackler 54c882234b Keep key gen messages with values encrypted to self. Remove TODO.
Not only is the code easier this way, it also has the advantage that a
node that has crashed and is restarting can recompute its key share.
2018-11-29 18:49:47 +01:00
Andreas Fackler da3d50d1b0 Fix some TODOs, make key share in net info optional. 2018-11-29 12:45: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 ae37879239 Remove the random_value option. 2018-11-22 13:07:58 +01:00