Commit Graph

714 Commits

Author SHA1 Message Date
Andreas Fackler 3f82db6071 Add docs.rs and crates.io badges. 2019-01-10 14:36:26 +01:00
Vladimir Komendantskiy ae4d77096b
Merge pull request #378 from poanetwork/afck-2018
Use Rust 2018 idioms consistently.
2019-01-09 12:19:17 +00: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
Andreas Fackler a71611d8f2 Link to the security audit. Update dependencies. (#376)
* Link to the security audit.

* Update dependencies.
2019-01-07 15:16:18 +00: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
Vladimir Komendantskiy 3a0e512798
Merge pull request #363 from poanetwork/afck-consensus-node
Fix consensus-node --help.
2018-12-12 09:25:31 +00:00
Andreas Fackler cea579803b Fix consensus-node --help. 2018-12-12 09:55:28 +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
Vladimir Komendantskiy f297d84514
Added a test for expected participants when receiving a batch from a correct node (#355)
* test expected participants when receiving a batch from a correct node

* restrict the batch participant check to correct participants

* check only for the absence of unexpected batch participants

* check the minimum number of contributors for each batch

* corrected the minimum number of batch contributions

* removed an irrelevant FIXME

* added an equivalence check for batches output in the same epoch

* comment correction
2018-12-11 07:28:27 +00:00
Vladimir Komendantskiy 99d01bf428
Update the crossbeam dependency to 0.5 (#361)
* updated crossbeam to 0.5

* removed an obsolete Clippy directive
2018-12-10 17:10:13 +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
Andrew Gross a9c3f96047
Merge pull request #348 from poanetwork/ag-README-diagram
README update
2018-11-21 08:44:18 -07:00
Andrew Gross c505a64d46
Updated links, reorg sections, added visualization 2018-11-21 08:19:43 -07:00
Andreas Fackler c2a76add5d Include the full Params in JoinPlan.
This ensures that a new node runs with exactly the same parameters as
the rest of the network.
2018-11-21 10:28:56 +01:00
Vladimir Komendantskiy 5735cf23a1
Binary Agreement test updated to the proptest framework (#336)
* converted the BA test to net framework

* fixed lints and corrected docs

* seeded the Rng and removed logging

* allowed pass by value of binary_agreement argument

* handling of input via proptest and doc correction
2018-11-20 15:16:15 +00:00
Andreas Fackler 9049dd1793 Add a `Params` struct with HB parameters.
This removes some duplication between DHB, HB and their builders.
2018-11-19 14:01:46 +01:00
Andreas Fackler c94e3ff16f Add epoch getters to JoinPlan, HB, DHB and QHB. 2018-11-18 10:48:38 +01:00
Andreas Fackler e89688bbd8
Allow arbitrary validator set changes in DHB. (#339)
* Allow arbitrary validator set changes in DHB.

This replaces `NodeChange` with a full list of IDs and public keys,
instead of just a single to-be-added or to-be-removed node, to allow
completely replacing the set of validators by any arbitrary new set in a
single key generation step.

* Address review comments: added_nodes, comments.

* Fix MessageScheduler::First.

Make sure every node eventually gets to handle its messages.
2018-11-18 10:17:33 +01:00
Andreas Fackler 767944c0f6 Fix random_value doc comment. 2018-11-12 14:16:21 +01:00
Andreas Fackler 30cce9bed8 Add a random_value option to HB and DHB.
This includes a threshold signature in each batch that can be used as a
pseudorandom value.

Also moves `EncryptionSchedule` from `threshold_decrypt` to
`honey_badger`.
2018-11-12 14:16:21 +01:00
Vladimir Komendantskiy e4435d5622
Make the incoming message queue finite in Binary Agreement (#329)
* added BA max_future_epochs and limited incoming messages in an epoch

* corrected a comment
2018-11-12 11:15:02 +00:00
Andreas Fackler b3c63774a7 Remove Epoched bound from SenderQueueableMessage. 2018-11-08 13:14:43 +01:00
Andreas Fackler d0b96f2dc8 Simplify the sender queue.
Remove the distinction between linearized and regular epochs.
Avoid iterating through the whole outgoing queue on epoch change.
2018-11-08 13:14:43 +01:00
Andreas Fackler 5ea0b92484 Minor simplification for SenderQueue. 2018-11-08 08:51:17 +01:00
Andreas Fackler 7f784e7852 Make Step independent of DistAlgorithm. 2018-11-08 08:51:17 +01:00
Vladimir Komendantskiy 9d4a477835
Merge pull request #327 from alyjak/issue326-rename-ThresholdDecryption
Rename `ThresholdDecryption` to `ThresholdDecrypt`
2018-11-07 17:36:26 +00:00
Andrew Lyjak 9a8836cf15 Rename `ThresholdDecryption` to `ThresholdDecrypt` 2018-11-07 11:13:10 -05:00
Andreas Fackler 62686afa05 Add a no-simd feature.
This disables SIMD in reed-solomon-erasure to work around problems on
Android.
2018-11-07 11:48:02 +01:00
Vladimir Komendantskiy 697565c97a
Move sender queue impls out of Honey Badger algorithms (#321)
* moved SenderQueueable impls out of HB algorithm modules and into sender_queue

* added sender_queue::honey_badger
2018-11-06 17:22:28 +00:00
alyjak bb64be55af issue286: make `ThresholdSign` and `ThresholdDecryption` APIs consistent (#316)
* issue286: make `ThresholdSign` and `ThresholdDecryption` APIs consistent

This gives both methods a `set_message(payload)` and a `sign()` method. If `sign` is called prior to
`set_message` or if was already called, then an empty step is returned. Otherwise share messages are
sent out to peers and `try_output` is called.

* Incorporating feedback from review of pull request #316

* Fixing the stack overflow and responding to further feedback

* Updates module documentation to reflect the API change from #286

* adds a new constructor to `ThresholdSign` and `ThresholdDecryption`

The `new_with_<payloadname>` function allows setting payload on construction
instead of as a separate call.
2018-11-06 16:26:48 +00:00
Andreas Fackler b71f9142f6 Add SenderQueue convenience methods for voting. 2018-11-06 14:12:31 +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
Vladimir Komendantskiy 62cd29e4ca
Merge pull request #308 from poanetwork/vk-extern-sender-queue
External sender queue implementation
2018-11-05 17:30:01 +00:00
Vladimir Komendantskiy f02bbbb9da Updated documentation and removed a debug print 2018-11-05 14:25:59 +00:00