-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
code: Initial implementation of the state machine, vote keeper and driver #1
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
romac
force-pushed
the
romac/rust-state-machine
branch
7 times, most recently
from
October 19, 2023 09:49
a394f81
to
176217e
Compare
romac
force-pushed
the
romac/rust-state-machine
branch
from
October 19, 2023 15:22
c5c2977
to
98b1203
Compare
* Add vote counting facility, with multi-value support * Show coverage summary in job output * Formatting * Comment out unused code * Fix code coverage workflow
Codecov Report
@@ Coverage Diff @@
## main #1 +/- ##
=======================================
Coverage ? 85.28%
=======================================
Files ? 26
Lines ? 1230
Branches ? 0
=======================================
Hits ? 1049
Misses ? 181
Partials ? 0 📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today! |
18 tasks
* Add a vote keeper * Rename `polka_round` to `pol_round` (Proof-Of-Lock) * Add unit tests to VoteKeeper * Add codecov settings * Add tests for precommit
* Add skeleton of consensus executor * Cleanup * Weight vote by its validators voting power * Add unit test for `ValidatorSet` * Split common lib into modules * WIP: Unit tests for state machine * Cleanup * Create new round state machine on NewRound * Propose checks, id in prevote and precommit (#7) * Propose checks, id in prevote and precommit * Disallow `unwrap` and `panic` * Add proper checks without unwraps * Add executor test with steps up to precommit * Formatting and clippy * Enable more lints * Finish the happy path test --------- Co-authored-by: Anca Zamfir <zamfiranca@gmail.com> --------- Co-authored-by: Anca Zamfir <zamfiranca@gmail.com>
Closes: #11 This gist of this PR is that it adds a `Consensus` trait which defines the various datatypes that the consensus engine operates over, as well as a trait per such datatype that defines the requirement for said datatype. ```rust pub trait Consensus where Self: Sized, { type Address: Address; type Height: Height; type Proposal: Proposal<Self>; type PublicKey: PublicKey; type Validator: Validator<Self>; type ValidatorSet: ValidatorSet<Self>; type Value: Value; type Vote: Vote<Self>; ``` ```rust pub trait Height where Self: Clone + Debug + PartialEq + Eq + PartialOrd + Ord, { } ``` etc. In test code, we define our own simple versions of these datatypes as well as a `TestConsensus` struct, for which we implement the `Consensus` trait. ```rust #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] pub struct Address(u64); impl Address { pub const fn new(value: u64) -> Self { Self(value) } } impl malachite_common::Address for Address {} ``` ```rust pub struct TestConsensus; impl Consensus for TestConsensus { type Address = Address; type Height = Height; type Proposal = Proposal; type PublicKey = PublicKey; type ValidatorSet = ValidatorSet; type Validator = Validator; type Value = Value; type Vote = Vote; } ``` --- * Attempt to abstract over the various data types needed by the consensus engine * Fix tests * Fix lints names * Move tests and associated data types into their own crate (#10) * Move tests and associated data types into their own crate * Add small threshold to codecov * Small cleanup * Move tests into `tests` folder * Adjust base when computing coverage in the presence of removed code See: https://docs.codecov.com/docs/commit-status#removed_code_behavior * Document the `Round` type and rename `Round::None` to `Round::Nil` * More doc comments * Remove `PublicKey::hash` requirement * Few more comments * Add propose+precommit timeout test
* Introduce `SignedVote` type and remove address from round `Vote` * Add facility for signing votes * Verify votes signatures * Better name for the module * Doc comments * Refactor signing facility into a `SigningScheme`
* executor: Rename input and outputs to `Event` and `Message` * votekeeper: Rename outputs to `Message`
* Move address from SignedVote into Vote * Rename a few fields for better clarity * Supply validator address to the state machine * Move `Transition` struct into its own module * Extract immutable data required to run the round state machine into a `RoundData` struct (#37)
* Event name changes and other small fixes * Add event multiplexing in executor and fix tests * Fix formatting * Fix executor handling of new round * Fix executor initialization * Add test step for NewRound, fix precommit for nil quorum to emit PrecommitAny * Review comments * Remove dead code --------- Co-authored-by: Anca Zamfir <zamfiranca@gmail.com>
* Rename `Threshold::Init` to `Unreached` * WIP: Pass votes directly to `VoteCount` * Cleanup * Split `compute_threshold` out of `add_vote` * Only count a single vote per validator address * Emit `PrecommitAny` message when we reach `Nil` threshold for precommits * Doc comment * Refactor `VoteCount` implementation * Fix tests * Split `vote` crate into more modules * Add Skip threshold * Refactor data kept by the `VoteKeeper` per-round * Move dealing with skip threshold into `VoteKeeper` * Rename `Event::RoundSkip` to `Event::SkipRound` * Cleanup * Include number of round to skip to in `SkipRound` message * Parametrize over thresholds
romac
changed the title
code: State machine implementation
code: Initial implementation of the state machine, vote keeper and driver
Nov 7, 2023
…of the state machine by the driver
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes: #49