Commit Graph

54 Commits

Author SHA1 Message Date
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
Andreas Fackler bb17bd7a9c Add NetworkInfo::other_ids. 2019-07-23 13:30:02 +02: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
David Forstenlechner c1e634ecf2 Ported more integration tests to the new net simulator (#387)
* Ported threshold_sign test to the new framework

* Ported the first three broadcast tests to the new framework

* Extracted messages storting and random swapping to reusable functions

Used to compose ProposeAdversary's behavior without having to duplicate code

* Implemented ProposeAdversary for the new integration testing framework

Added "id()" function to the "NodeMutHandle", required for sending messages to all nodes

ProposeAdversary needs access to all faulty node's netinfo. We follow the example of the binary_agreement_mitm integration test of using an reference counted Mutex to make netinfo available on both Consensus Protocol construction and in the Adversary implementation.
Unlike binary_agreement_mitm every faulty node needs to use its own netinfo for the broadcast algorithm, so we store all nodeinfo structures in a Map instead of just the nodeinfo of the first node.
Ideallly the new network simulation library should provide netinfo similar to the old library to avoid these hideous workarounds.

* Migrated test_broadcast_random_delivery_adv_propose to the new network simulator

Refactored the implementation of ProposeAdversary to closely resemble the behavior in the old network simulator library.
Implemented a pick_random_node function to sort messages for a random node id. Switched from using "inject_message" to joining messages generated by adversaries' temporary Broadcast Consensus Protocols with the Step generated by regular operation.

* Ported RandomAdversary to the new network simulator library

Ported all broadcast integration tests and replaced the old tests with the new.

* Eliminated the old broadcast integration test, replaced with the new

* Ported subset test to the new framework

Adjusted message queue size as suggested by Andreas

* Ported the first three honey_badger tests to the new framework

* Re-implemented FaultyShareAdversary for the new framework

Eliminated the old honey_badger integration tests, replaced with implementations using the new net simulator framework

* Fixed issues reported by clippy

* Fixed issues reported on code review

* Fixed issues reported by clippy

* Implemented a broadcast test dropping messages similar to the tests written in the old framework

* Picking the proposer id at random, verifying all possible output cases

If the proposer is faulty the message queue may starve, but the outputs of all correct nodes need to be empty, if the broadcast protocol produces output nonetheless all correct nodes need to have the same output.
If the proposer was correct all correct nodes need to output its proposed value.

* Eliminated duplicated semicolon

* Consistently using TestRng and proptest in all newly ported tests

* Increased the drop_and_re_add test message limit to 20k per node

* Removed unnecessary closure

* Increased the tolerance for deviations from the expected value range to eliminate random test failures
2019-03-14 13:41:23 +00:00
Andreas Fackler 87b1d45d97 Rename DistAlgorithm to ConsensusProtocol. 2019-01-08 14:14:34 +01: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
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 da3d50d1b0 Fix some TODOs, make key share in net info optional. 2018-11-29 12:45:39 +01:00
Andreas Fackler ae37879239 Remove the random_value option. 2018-11-22 13:07:58 +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
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
Andrew Lyjak 9a8836cf15 Rename `ThresholdDecryption` to `ThresholdDecrypt` 2018-11-07 11:13:10 -05:00
Vladimir Komendantskiy ee46dd4b81 sender queue implementation 2018-11-05 11:11:00 +00:00
Andreas Fackler df36258715 Instead of macro_use, use use. 2018-10-30 08:11:03 +01:00
Vladimir Komendantskiy 59444fcf7b Support a global RNG in transaction queue (#257)
* adds an RNG argument to the transaction queue

* minimal support of transaction queue RNG in tests

* added the TransactionQueue trait object

* review comments and streamlining of trait bounds

* removed the RNG from the transaction Q and placed it into QueueingHoneyBadger

* formatting fix
2018-10-11 15:33:03 +02:00
Andreas Fackler 8d1361e6ae Split up messaging module. 2018-10-10 17:29:59 +02:00
Vladimir Komendantskiy af05c44659 Revert "Spam protection part 1: remote epoch tracking in HoneyBadger (#219)"
This reverts commit b649dc6268.
2018-10-10 11:31:50 +02:00
Andreas Fackler 7002dad54c Remove unused pairing import.
Also use the new `Iterator::flatten`.
2018-10-09 11:53:20 +02:00
Vladimir Komendantskiy b649dc6268
Spam protection part 1: remote epoch tracking in HoneyBadger (#219)
* spam protection part 1: remote epoch tracking in HoneyBadger

* moved handling of EpochStarted out of EpochState

* allowed EpochStarted from observers

* removed an unnecessary function call

* updated formatting to beta

* removed an unnecessary variable
2018-09-03 11:29:03 +01: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 46a8728792 Split out Threshold Decryption from Honey Badger. 2018-08-06 10:50:30 -07:00
Nick Sanders c5977d1ab8
Revert "Reorganize `dynamic_honey_badger` and `agreement` modules slightly." 2018-08-02 12:24:25 -07:00
c0gent 7824b7a0ea
Reorganize `dynamic_honey_badger` and `agreement` modules slightly.
* Move `CoinState` and `Agreement` definitions from `agreement/mod.rs`
  to `.../agreement.rs`.
* Move `DynamicHoneyBadger` definition from `dynamic_honey_badger/mod.rs`
  to `.../dynamic_honey_badger.rs`.
2018-08-02 11:24:15 -07:00
Andreas Fackler eeb519862f Simplify Honey Badger tests and example. 2018-08-01 18:52:32 +02:00
Vladimir Komendantskiy 77ed1d50d4 separated crypto module into its own crate 2018-07-31 12:15:05 +01:00
Andreas Fackler 15cc6ffddd Separate keys and key shares. 2018-07-18 14:44:35 +02:00
Vladimir Komendantskiy 9979e790aa added must_use to tests and removed Clone from FaultLog 2018-07-16 14:31:21 +01:00
Andreas Fackler 55ad2eae44 Fix DHB test with 1 validator; purge key gen msgs.
This adds a bit of special handling to make sure messages don't stay in
the queue forever in the `dynamic_honey_badger` tests, even if there is
only one validator: the problem was that the single validator is always
ready for input, so it never processed incoming messages. However, to
add the new validator, it needs to process the joining node's key
generation messages.

`DynamicHoneyBadger` now also removes committed key generation messages
from the queue, to avoid committing duplicates.
2018-07-15 12:12:27 +02:00
Vladimir Komendantskiy 72f7b1c06d
Merge branch 'master' into afck-dhb-votes 2018-07-14 08:20:02 +01:00
Marc Brinkmann 5336fbe707 Added `RandomAdversary` and the necessary auxiliary functions.
Random adversaries are created for `broadcast` and `honey_badger`.  Random value generation was added for all type-dependencies of these algorithms, causing the `Rand` trait to be implement for a large portion of the codebase.

Additionally, `MessageWithSender` turned into an actual struct, making it much easier to handle. Tuple-like construction is still available through `MessageWithSender::new()`.
2018-07-13 13:27:49 +02:00
Marc Brinkmann 510c4478d4 Ensure the adversary is playing fair and give a more helpful error message if they are not. 2018-07-13 13:27:49 +02:00
Andreas Fackler 3f3ac7be13 Minor fixes and simplifications.
* Clear outdated key gen messages from the buffer.
* Process output after proposing, to make `HoneyBadger` work with a
  single validator.
* Print an error if threshold decryption fails.
* Verify decryption shares with the correct ciphertext.
* Insert all ciphertexts from an epoch at once; otherwise contributions
  can be omitted from a batch.
* Remove `BoolWithFaultLog`: It's easier to return a tuple, and it's
  used only in one place now.
* Avoid redundant signature verification in `VoteCounter`.
* Fix the tests for `QueueingHoneyBadger`.
* Use fewer network sizes to speed up tests a bit.
2018-07-12 17:54:27 +02:00
c0gent f0ed2e6e12 Make `*HoneyBadger` types thread safe.
Replaces `Rc` with `Arc`. This allows usage from different threads
which will be necessary for use with Parity.
2018-07-11 16:28:41 -07:00
Andreas Fackler c1b4381753 Separate queue from Honey Badger.
This makes Honey Badger a bit more complicated but a lot more flexible:
It is now unaware of transactions and basically just runs one Subset
instance per epoch.

That way, users can use any kind of external queue, control throttling
and prioritization.
2018-07-10 17:29:58 +02:00
Peter van Nostrand 6783ece9b0 Added faulty node logging to algorithms. 2018-07-09 13:45:11 -04:00
Andreas Fackler 6248e4079f Fix Subset for a single validator. 2018-07-09 11:38:56 +02:00
Andreas Fackler 6f7245f123 Prefer HB::builder over HBBuilder::new. 2018-07-05 11:47:19 +02:00
Andreas Fackler 1a3016d94d Add Honey Badger builder. 2018-07-05 11:47:19 +02:00
Andreas Fackler 0f92010fe4 Add a max_future_epochs option to Honey Badger.
This delays handling of messages from epochs that are too far ahead.
2018-07-05 11:47:19 +02:00
Vladimir Komendantskiy 6ce6899ca9 added output sequence verification in HoneyBadger test 2018-06-26 12:15:30 +01:00
Andreas Fackler b3b3994ec1
Merge pull request #82 from poanetwork/vk-test-decryption-shares
An adversary sending faulty decryption shares
2018-06-26 09:06:33 +02:00
Vladimir Komendantskiy 1c9ca201d5 corrected a comment and removed a redundant mut 2018-06-25 21:18:25 +01:00
Vladimir Komendantskiy 11ec39879b created an adversary to test against faulty decryption shares 2018-06-25 19:22:08 +01: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
Vladimir Komendantskiy af03158e00 tries to decrypt and output a batch on epoch update from already received messages 2018-06-22 10:12:38 +01: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 122f1fc6f1 updated the tests with key initialisation 2018-06-13 15:15:41 +01:00
Vladimir Komendantskiy 98f5304d4c top-level interface now requires providing a NetworkInfo parameter 2018-05-29 14:53:01 +01:00
Vladimir Komendantskiy 938d2f5c16 added a note about the use of NetworkInfo in tests 2018-05-29 14:53:01 +01:00