Commit Graph

10 Commits

Author SHA1 Message Date
Vladimir Komendantskiy 10dbf705e4 using serde derive feature 2019-04-02 12:42:51 +02: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 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
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