-
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
Abstract over the various data types needed by the consensus engine #8
Conversation
796f6d5
to
4e36931
Compare
Codecov Report
@@ Coverage Diff @@
## romac/rust-state-machine #8 +/- ##
============================================================
- Coverage 85.60% 83.12% -2.48%
============================================================
Files 15 17 +2
Lines 1007 794 -213
============================================================
- Hits 862 660 -202
+ Misses 145 134 -11
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
4e36931
to
94c8651
Compare
a80f2a4
to
492dc4b
Compare
a9af4d9
to
1d0ec33
Compare
* 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
60c20f6
to
59e04b3
Compare
I have also been experimenting with finer-grained generics instead of stuffing everything into a single It’s possible that I am going at this the wrong way but so far I would be in favor of keeping the |
Drop in coverage is likely because a bunch of code was moved to the test crate, ie. deleted from the main crates and added to the test crate. |
d8b4928
to
ddd0d8d
Compare
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
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.etc.
In test code, we define our own simple versions of these datatypes as well as a
TestConsensus
struct, for which we implement theConsensus
trait.