Commit Graph

401 Commits

Author SHA1 Message Date
Andreas Fackler c91fa13213 Make Broadcast handle large payloads. 2018-05-30 15:40:15 +02:00
Andreas Fackler a0a8582f0b Expand crypto tests. 2018-05-30 14:15:54 +02:00
Andreas Fackler 661bae6438 Implement threshold encryption. 2018-05-30 13:50:09 +02:00
Andreas Fackler 45a7c07106 Implement simple encryption. 2018-05-30 11:42:17 +02:00
Andreas Fackler 0017a2a7c0 Make public keys and signatures serializable. 2018-05-30 10:08:43 +02:00
Andreas Fackler 56ab6a5037 Simplify hash_g2. 2018-05-29 21:59:21 +02:00
Andreas Fackler 527b1c8c17 Use SHA256 and byteorder in hash_g2. 2018-05-29 17:59:50 +02:00
Andreas Fackler d999792234 Implement threshold signatures. 2018-05-29 17:06:02 +02:00
Vladimir Komendantskiy ede1c7d157 moved the own ID membership test to the NetworkInfo constructor 2018-05-29 14:58:17 +01:00
Vladimir Komendantskiy 98f5304d4c top-level interface now requires providing a NetworkInfo parameter 2018-05-29 14:53:01 +01:00
Vladimir Komendantskiy d09f3e26b4 introduced common shared network information 2018-05-29 14:53:01 +01:00
Vladimir Komendantskiy 2aac22f083 comment updates 2018-05-28 11:54:37 +01:00
Vladimir Komendantskiy 82643fb442 formatting 2018-05-24 19:48:10 +01:00
Vladimir Komendantskiy 67c7bf4f8b updated protobuf serialisation 2018-05-24 19:11:56 +01:00
Vladimir Komendantskiy 111ed03a47 review comments taken into account 2018-05-24 18:52:58 +01:00
Vladimir Komendantskiy 43a47e1f46 lints checked 2018-05-23 23:19:48 +01:00
Vladimir Komendantskiy 72d5cecbb9 Fixed non-termination in the suggested Cobalt fix.
The non-termination was due to the direct use of `bin_values` when invoking the
common coin. The fix amounts to making the CONF round depend only on the subset
of `bin_values` sent in the CONF message.
2018-05-23 23:00:19 +01:00
Vladimir Komendantskiy 751bb57ace CONF round added to Agreement 2018-05-23 18:38:33 +01:00
Andreas Fackler 9a0622f3f2 Update Rust, re-enable rustfmt. 2018-05-21 11:26:42 +02:00
Peter van Nostrand 19b982284b Added error-chain error handling. 2018-05-20 07:51:33 -04:00
Andreas Fackler ca65a014d6 Use an unambiguous name for proposer ID. 2018-05-19 17:17:02 +02:00
Andreas Fackler ab89dabde9 Add a few explaining comments. 2018-05-19 17:10:30 +02:00
Andreas Fackler b8a2463d1c Extend tests and fix CommonSubset.
Verify termination and more outputs.

`CommonSubset` now instantiates `Agreement` with the correct ID.
2018-05-19 15:56:49 +02:00
Vladimir Komendantskiy 962a618ffd ported Common Subset tests to TestNetwork 2018-05-18 22:04:09 +01:00
Andreas Fackler d5f9c4d40d Fix Agreement and re-enable HoneyBadger test. 2018-05-17 17:38:45 +02:00
Andreas Fackler 50d007b954 Remove protoc dep, use new MerkleTree methods. 2018-05-17 16:50:47 +02:00
Andreas Fackler 500ec81b2f Add a network simulation example. 2018-05-17 12:52:07 +02:00
Vladimir Komendantskiy a0627b2550 review comments taken 2018-05-17 11:36:09 +01:00
Vladimir Komendantskiy c8c8e1bb1f added a latch for the decided value in Agreement to remember the output value 2018-05-17 10:43:56 +01:00
Vladimir Komendantskiy 0c386276b1 defined a DistAlgorithm instance of Agreement 2018-05-16 22:50:23 +01:00
Andreas Fackler 4164af1702 Generalize TestNetwork and test HoneyBadger. 2018-05-16 16:21:30 +02:00
Vladimir Komendantskiy 5f916c4d08 formatting and lint check 2018-05-15 22:25:41 +01:00
Vladimir Komendantskiy c8034da332 corrected the CommonSubset module and test to decide on a map of values insetead of a set 2018-05-15 18:18:05 +01:00
Vladimir Komendantskiy ff3e819a4f a better check for when bin_values becomes non-empty 2018-05-15 16:00:37 +01:00
Vladimir Komendantskiy 322373a5ae started using the set of sent agreement values 2018-05-15 15:47:54 +01:00
Vladimir Komendantskiy eadd233fe4 added the Common Subset test module 2018-05-15 15:44:47 +01:00
Andreas Fackler 66898aee30 In agreement, set sent_bval correctly. 2018-05-15 16:15:41 +02:00
Andreas Fackler b8c534da2b Rename has_output to decided, add output iterator. 2018-05-15 16:05:55 +02:00
Andreas Fackler 3895949cf6 Fix broadcast for size < 4, and test more network sizes. 2018-05-15 15:53:37 +02:00
Andreas Fackler 10d9aa73e3 Rename UnexpectedMessage error. 2018-05-15 15:48:43 +02:00
Andreas Fackler 5528fc2de8 Define a common DistAlgorithm trait.
This will allow us to deduplicate network simulations in tests for the
different algorithms. More generally, it facilitates writing general
tools and applying them to all distributed algorithms.
2018-05-15 15:48:43 +02:00
Andreas Fackler b543b771a7 Rename util to fmt. 2018-05-15 08:31:13 +02:00
Andreas Fackler e2c66e9a0a Add optional serde support.
If the feature "serialization-serde" is specified, protocol messages
implement serde's `Serialize` and `Deserialize` traits.

Close #18
2018-05-14 18:32:59 +02:00
Andreas Fackler e8838f1491 Make protobuf support optional.
Protobuf support is now only built if the feature
"serialization-protobuf" is enabled.

Close #19
2018-05-14 17:29:04 +02:00
Vladimir Komendantskiy a20ee74254 added a test for Binary Agreement with 4 proposers 2018-05-14 12:35:28 +01:00
Andreas Fackler 71fa32c18f Remove interior mutability.
The `RwLock` is not needed anymore, since the broadcast implementation
doesn't handle any threading internally.
2018-05-14 09:35:34 +02:00
Andreas Fackler 0d005ebdc9 Fix build with protobuf 1.6.0.
Protobuf made backwards-incompatible changes but didn't increment the
major version, thus breaking the build.
2018-05-12 16:33:54 +02:00
Andreas Fackler 38cdd596a2 Start implementing the top-level Honey Badger algorithm.
This also contains a few fixes for the `common_subset` module:
* Rename `common_subset::Output` to `Message` to avoid confusing it
  with the value that the algorithm outputs as a result.
* Implement dispatch of messages to the right instance within
  `CommonSubset`, in a way that is transparent to the user.
2018-05-12 16:09:07 +02:00
Andreas Fackler 36183b1e27 Simplify the message types. 2018-05-10 17:52:12 +02:00
Vladimir Komendantskiy 57ff64cce0 correction: Agreement outputs a value only once 2018-05-10 12:44:33 +01:00
Vladimir Komendantskiy 68e6a7ae2d added the missing agreement broadcast message on epoch change 2018-05-10 12:33:01 +01:00
Vladimir Komendantskiy fb50e38ead replaced the map of estimated values with only one optional value for the current epoch 2018-05-10 12:09:22 +01:00
Vladimir Komendantskiy cf33bac533 added the proposer ID to common_subset::handle_broadcast and mae it an interface fn 2018-05-10 11:01:25 +01:00
Vladimir Komendantskiy 51ef11b55c fixed the count of matching AUX messages 2018-05-10 10:07:22 +01:00
Vladimir Komendantskiy 259d5369b0 corrected the count of AUX messages 2018-05-10 10:07:22 +01:00
Vladimir Komendantskiy b6a6bb35ea clear the received AUX messages on every epoch update 2018-05-10 10:07:22 +01:00
Vladimir Komendantskiy e0005a672b removed the separate field in Agreement and corrected computation of estimated values 2018-05-10 10:07:22 +01:00
Vladimir Komendantskiy 3e35cc665b added element_proposer_id to the Agreement input to the Common Subset algorithm 2018-05-10 10:07:22 +01:00
Vladimir Komendantskiy 394462c88b changed code according to review comments 2018-05-10 10:07:22 +01:00
Vladimir Komendantskiy 5215156ec5 defined the output from the Common Subset algorithm 2018-05-10 10:02:03 +01:00
Vladimir Komendantskiy d3b974f888 Binary Agreement implementation and its wiring into Common Subset 2018-05-10 10:02:03 +01:00
Andreas Fackler 047307be46 Revert to earlier ProtoIo implementation.
This fixes the issue where sometimes messages were skipped.
2018-05-09 14:18:12 +02:00
Andreas Fackler c790a1feba Improve example logging, add BinaryPath. 2018-05-09 13:38:49 +02:00
Andreas Fackler b98bbe9dcd Fix broadcast and example, enable more tests.
This fixes several issues with the broadcast algorithm and enables the
previously ignored tests that now pass:
* Don't decide on a root hash based on anyone's `Echo` message.
* Work around the `merkle` crate's inability to produce the proof of the
  `i`-th leaf for a given index `i`.
* Ignore messages from unknown nodes.
* Avoid decoding multiple times.
* Document the full algorithm.
* Don't count multiple `Echo` or `Ready` messages coming from the same
  node.
* Fix index computation for a given proof.
* Move `BroadcastMessage` into `broadcast` to make the module more
  self-contained.

The example now only executes a single broadcast instance, expecting the
first node (the one with the lexicographically lowest address) to
propose a value. A shell script is added that runs for example nodes.

Use env_logger instead of simple_logger, so the log level can be controlled
with an environment variable. You can e.g. log all output from the broadcast
test and the crate itself in debug mode with:
RUST_LOG=hbbft=debug,broadcast=debug

Some debugging messages are more concise now and use hexadecimal
notation instead of printing arrays of decimal values.

An indentation error in the Travis script is also fixed.
2018-05-08 17:04:38 +02:00
Vladimir Komendantskiy dda1570bfc Merge branch 'afck--examples' of github.com:poanetwork/hbbft 2018-05-06 22:49:41 +01:00
Andreas Fackler eec3102cbf Move node to examples, deduplicate code. 2018-05-05 17:54:29 +02:00
Andreas Fackler 7826987af1 added a Travis configuration file, fixed Clippy lints 2018-05-05 09:53:29 +02:00
Andreas Fackler e2cd4ca1b7 added (ignored) regression tests for some of the broadcast issues 2018-05-04 11:14:19 +02:00
Andreas Fackler 8bced81438 removed some unnecessary cloning
This also adds a few TODOs to the broadcast implementation: Some of
these issues need a regression test. (Oh, and a fix!)
2018-05-04 09:58:21 +02:00
Vladimir Komendantskiy cde3a879e5 modified Agreement::set_input to output a BVAL message 2018-05-03 10:13:41 +01:00
Vladimir Komendantskiy d64dec2bd1 added Agreement message type and protobuf boilerplate 2018-05-03 10:10:35 +01:00
Andreas Fackler babbd2f36a fixed broadcast failure with malicious value proposal 2018-05-03 11:07:37 +03:00
Andreas Fackler 0f3377c8e9 made broadcast handle its own echo and value messages 2018-05-03 08:47:31 +03:00
Vladimir Komendantskiy 13407c8774 Merge branch 'master' of github.com:poanetwork/hbbft 2018-05-02 15:47:54 +01:00
Vladimir Komendantskiy 98e3cf76a3 implementation of the last clause in Figure 4 2018-05-02 15:47:30 +01:00
Andreas Fackler 7096251b91 extended tests, make broadcast output only once 2018-05-02 16:34:54 +03:00
Vladimir Komendantskiy 7b04d5e084 created broadcast and agreement instances in Common Subset 2018-05-02 14:10:26 +01:00
Vladimir Komendantskiy 389855839f wrote CommonSubset::on_agreement_result and made related updates in agreement.rs 2018-05-02 11:57:28 +01:00
Vladimir Komendantskiy fbb69baa3c updated Common Subset with the new NodeUid type parameter 2018-05-02 08:15:47 +01:00
Vladimir Komendantskiy 579abbf415 merged changes in common_subset.rs into master 2018-05-01 20:21:13 +01:00
Vladimir Komendantskiy a792a209b5 Common Subset handler for input messages 2018-05-01 18:12:05 +01:00
Andreas Fackler f710806b17 test broadcast in a single thread 2018-05-01 19:38:11 +03:00
Vladimir Komendantskiy bb765cbb06 propose_value function in Broadcast 2018-05-01 15:28:31 +01:00
Vladimir Komendantskiy 2daaf7baf2 rewrote part of Common Subset to call Broadcast via a callback handler 2018-05-01 15:09:08 +01:00
Andreas Fackler d7882bae9c added Broadcast::handle_broadcast_message 2018-05-01 17:01:29 +03:00
Andreas Fackler 6117e11a9e applied rustfmt 2018-04-30 18:55:51 +03:00
Andreas Fackler f399ed2c07 fixed Clippy lint warnings 2018-04-30 18:50:24 +03:00
Vladimir Komendantskiy 329adc3c2b ported sharding and sending out Merkle tree proofs 2018-04-27 13:19:39 +01:00
Vladimir Komendantskiy 3ae0984733 fixed a potential RwLock panic in the Common Subset handler 2018-04-26 18:49:57 +01:00
Vladimir Komendantskiy eef846550f added the ACS algorithm with one clause not ready yet 2018-04-26 14:22:18 +01:00
Vladimir Komendantskiy 17678da06d separated the handler of remote broadcast messages into a fn for slightly better readability 2018-04-25 21:26:10 +01:00
Vladimir Komendantskiy db06e75d4e broadcast READY message handler ported from the older version 2018-04-25 21:00:22 +01:00
Vladimir Komendantskiy 8cd1f4748d broadcast ECHO message handler and mutable access solution for writeable state of broadcast 2018-04-25 20:41:46 +01:00
Vladimir Komendantskiy c7020e7b6a broadcast VALUE remote message handler written 2018-04-25 14:07:16 +01:00
Vladimir Komendantskiy 5428d928cc added receiver threads for remote nodes in the broadcast test 2018-04-25 10:59:46 +01:00
Vladimir Komendantskiy 93617f797d removed unnecessary mutability requirements 2018-04-25 10:59:46 +01:00
Vladimir Komendantskiy 08ff34c2a7 removed the algo error type, replacing it with type constraints and drafted adding handlers to a test node 2018-04-25 10:59:46 +01:00
Vladimir Komendantskiy 92d8c0d71a fold was not using the variable capturing the sequential data; I fixed that 2018-04-25 10:59:46 +01:00
Vladimir Komendantskiy 36cb880186 introduced a message handler trait and corrected the type of message handler container 2018-04-25 10:59:46 +01:00
Vladimir Komendantskiy 629c54494c added send_remote for sending a queue of messages to remote nodes through channels 2018-04-25 10:59:46 +01:00
Vladimir Komendantskiy b5e47d9a4f wrote essentials of the message loop and updated the message queue with required handles 2018-04-25 10:59:46 +01:00
Vladimir Komendantskiy 875f3cecbe updated the message loop state adding messages queued for sending to remote nodes 2018-04-25 10:59:46 +01:00
Vladimir Komendantskiy f801f0c1b0 test prototype of a message loop implementation 2018-04-25 10:59:46 +01:00
Vladimir Komendantskiy 7b82228b57 basic types for message passing between algorithms 2018-04-25 10:59:46 +01:00
Vladimir Komendantskiy 27e5ee679e Internal messaging was being stopped before broadcast threads finished. Corrected that. 2018-04-20 09:42:15 +01:00
Vladimir Komendantskiy b1cc8aee15 removed unused test module and refactored handling of Result using combinators 2018-04-16 15:17:36 +01:00
Vladimir Komendantskiy cdd86cbd6a added error handling in the local messaging task, so that channel errors don't cause a panic 2018-04-16 14:03:32 +01:00
Andreas Fackler 0494b4925d fixed value encoding, shortened debug messages
This adds a length byte to the values before padding with 0, so that we
can omit the padding at the end again. Shards are not converted to the
type parameter `T` anymore, because they are not necessarily valid
representations of a `T` value, e.g. valid UTF-8, as in the tests.

It also shortens some debug messages by printing byte arrays as
hexadecimal, and eliding some bytes.
2018-04-14 12:27:17 +02:00
Andreas Fackler fc3e502c5a fixed test build 2018-04-14 10:40:06 +02:00
Vladimir Komendantskiy d9bc81fe5f integration test of broadcast mostly ready; there is a thread termination issue however 2018-04-13 18:28:41 +01:00
Vladimir Komendantskiy efdb4467c5 added broadcast integration test concept 2018-04-12 17:17:33 +01:00
Vladimir Komendantskiy 40575402c8 replaced AsRef constraint by more precise Hashable and corrected doc example 2018-04-11 17:57:30 +01:00
Vladimir Komendantskiy b776087b26 removed redundant type constraint 2018-04-11 15:44:59 +01:00
Vladimir Komendantskiy 1105d15995 created an abstract interface to streaming serialised IO 2018-04-11 13:21:50 +01:00
Vladimir Komendantskiy fda6b04ab5 removed unnecessary vector cloning 2018-04-09 14:25:12 +01:00
Vladimir Komendantskiy 4a68365101 added the local message delivery system module 2018-04-09 14:06:30 +01:00
Vladimir Komendantskiy e0a24761aa corrected the calculation of the size of data shard padding 2018-04-06 19:31:20 +01:00
Vladimir Komendantskiy f620c7b000 broadcast instance now counts all Ready messages and doesn't derive node's hash from them 2018-04-06 18:42:04 +01:00
Vladimir Komendantskiy 99ff3c4863 introduced error forwarding in the broadcast module for IO operations 2018-04-06 17:39:15 +01:00
Vladimir Komendantskiy bc071d7a09 added Error return types of run() functions, and handled returned errors 2018-04-06 17:01:14 +01:00
Vladimir Komendantskiy fdb41d393f renamed Task -> CodecIo and added debug logging for root hashes 2018-04-06 16:04:28 +01:00
Vladimir Komendantskiy e9b0add188 removed redundant dependency on error_chain; corrected vector indices 2018-04-06 13:57:48 +01:00
Vladimir Komendantskiy 6eea0d443e migrated channel storage to within the message delivery struct 2018-04-05 17:10:08 +01:00
Vladimir Komendantskiy 4cb80ee789 Introduced a local message delivery system as a solution to message broadcasts. 2018-04-05 13:09:46 +01:00
Vladimir Komendantskiy 6b90917f79 removed deadlock in CommsTask::run between the socket reader and writer 2018-04-04 13:49:37 +01:00
Vladimir Komendantskiy 6cbfbace1c using the select_loop macro instead of explicit Select application 2018-04-04 12:49:11 +01:00
Vladimir Komendantskiy bad5fd47a7 select_loop macro is in fact not visible; fixed that temporarily 2018-04-04 12:20:32 +01:00
Vladimir Komendantskiy ef2ec016e4 node indexing fixes and more logging to debug messaging issues 2018-04-04 12:18:57 +01:00
Vladimir Komendantskiy 37620874ee fixed the operation of sending the Merkle tree proofs to each of N nodes 2018-04-03 23:08:26 +01:00
Vladimir Komendantskiy be605b9430 added channels to each of the comms threads to send proofs to remote nodes 2018-04-03 12:53:59 +01:00
Vladimir Komendantskiy 186a855d2f replaced lockable scoped channel variables with lock-free ones 2018-04-02 21:26:40 +01:00
Vladimir Komendantskiy e01a80dfa7 introduced a Connection struct and a procedure to start the network 2018-04-01 22:29:12 +01:00
Vladimir Komendantskiy 9554c3c543 added GNU license and removed obsolete comments 2018-04-01 21:41:49 +01:00
Vladimir Komendantskiy 4e9c8f0e36 corrected broadcast instance return value 2018-03-29 18:19:41 +01:00
Vladimir Komendantskiy d8c57280d3 decoder of broadcast value from Merkle tree leaves 2018-03-29 17:23:02 +01:00
Vladimir Komendantskiy 468cf90076 transitioning broadcast stage to broadcast instance, i.e. simplifying for a single root hash 2018-03-28 23:38:02 +01:00
Vladimir Komendantskiy eb3bbbdd4f
Merge pull request #1 from yrashk/remove-autogenerated-message.rs
Problem: proto::message is checked into the repo
2018-03-28 14:52:34 +01:00
Vladimir Komendantskiy 103e7c612d
Merge branch 'master' into remove-autogenerated-message.rs 2018-03-28 14:52:13 +01:00
Vladimir Komendantskiy 182c6e65f5 made the sharding step a function to reduce the size of inner_run 2018-03-28 14:51:58 +01:00
Vladimir Komendantskiy 264b72011c added example of intended use of Node and a draft of value encryption 2018-03-27 21:59:38 +01:00
Vladimir Komendantskiy cd98cd3bab added draft responses to Ready messages, started tree interpolation 2018-03-23 22:54:40 +00:00
Vladimir Komendantskiy 1cdec3c39b broadcast algorithm drafted up to tree interpolation 2018-03-22 22:47:44 +00:00
Vladimir Komendantskiy fc475004f0 lifted the static requirement for messages by using scoped threads 2018-03-20 16:32:19 +00:00
Vladimir Komendantskiy c38aad2c0a Refactored the comms from the consensus node module
I reduced the socket IO tasks to mere message forwarders. The algorithm
complexity lies in stage modules. Example: broadcast/mod.rs. Communication is
set up and modules are run from the node module.

There is a problem with this commit. std:🧵:spawn imposes a static
lifetime guarantee on type T in Message<T>.
2018-03-19 17:12:20 +00:00
Vladimir Komendantskiy 797f775008 solved the problem with receiver side of a comms channel located inside an OS thread 2018-03-17 00:36:32 +00:00
Vladimir Komendantskiy 4353b1bb3e added shared state of the broadcast stage to the main consensus node loop 2018-03-16 21:04:06 +00:00
Vladimir Komendantskiy 86e133d2b4 added a broadcast stage struct and drafted messaging between broadcast tasks 2018-03-16 18:12:14 +00:00
Vladimir Komendantskiy cb4c55a5c5 Task is refactored to provide a stream of messages 2018-03-15 23:43:58 +00:00
Vladimir Komendantskiy e8cde28f93 from_proto and into_proto methods now allow writing up the broadcast stage 2018-03-15 18:00:17 +00:00
Yurii Rashkovskii 8b652fd1c4
Problem: proto::message is checked into the repo
However, it is generated during build-time and therefor is
unnecessary to be kept around in the repository.

There are two potential solutions for this problem:

1. Don't generate it build-time and use a checked-in version
2. Don't check it in.

Solution: don't check it in

The reason why I picked this solution is because it is, generally
speaking, less error-prone as it prevents "I forgot to regenerate
files" type of situations.
2018-03-15 10:49:51 +07:00
Vladimir Komendantskiy 5301123872 initial commit: elements of profobuf interface 2018-03-15 00:03:21 +00:00