-
Notifications
You must be signed in to change notification settings - Fork 158
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
Define interfaces for consensus #1923
Conversation
Draft because this depends on #1902. |
df5427e
to
9d16f70
Compare
2cd6fed
to
0c5f00d
Compare
0c5f00d
to
1e3f617
Compare
#1902 has been merged. I have rebased this PR on master. Ready for review. |
( Eq (Block era), | ||
Show (Block era), | ||
NoThunks (Block era), | ||
FromCBOR (Annotator (Block era)), | ||
ToCBOR (Block era), | ||
Eq (BHeader (Crypto era)), | ||
Show (BHeader (Crypto era)), | ||
NoThunks (BHeader (Crypto era)), | ||
FromCBOR (Annotator (BHeader (Crypto era))), | ||
ToCBOR (Block era), | ||
Eq (ShelleyState era), | ||
Show (ShelleyState era), | ||
NoThunks (ShelleyState era), | ||
FromCBOR (ShelleyState era), | ||
ToCBOR (ShelleyState era), | ||
Eq (BlockTransitionError era), | ||
Show (BlockTransitionError era), | ||
NoThunks (BlockTransitionError era), | ||
Eq (STS.PredicateFailure (STS.CHAIN era)), | ||
Show (STS.PredicateFailure (STS.CHAIN era)), | ||
NoThunks (STS.PredicateFailure (STS.CHAIN era)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This list is already rather long, but I expect some things are missing. So at some point, I might have to add more constraints here.
import Shelley.Spec.Ledger.TxBody (EraIndependentTxBody) | ||
|
||
-- TODO #1304: add reapplyTxs | ||
class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might move these class definitions to Cardano.Ledger.API
since we now expect them to apply across eras. But can do that in a separate PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We decided to postpone this.
Show (Tx era), | ||
NoThunks (Tx era), | ||
FromCBOR (Annotator (Tx era)), | ||
ToCBOR (Tx era), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tim has proposed packaging these things up as ChainData
, which would make this list somewhat cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the last commit.
-- few header level checks, such as size constraints. | ||
applyTick :: | ||
Globals -> | ||
ShelleyState era -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[bikeshedding] ShelleyState
was an alias for downstream use, but now feels a bit awkward, since generally this won't be shelley. We could use the wrapped type NewEpochState
, or come up with a better name (but all the obvious ones are taken...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have gone for NewEpochState
for now.
1e3f617
to
40610c5
Compare
In the `Shelley.Spec.Ledger.API.*` modules, define type classes for the most important functionality consensus. These classes are parametric in the era. Instances should be provided for each era (Shelley, Allegra, Mary, etc.). At the moment, only instances for `ShelleyEra` are provided. These classes list a bunch of super-class constraints that consensus relies on. I have tried to be complete, but there's a good chance I forgot to add a few constraints that are currently already satisfied. Default implementations are provided for each method so that an empty instance declaration should be enough for each class + era combination. The constraints on these instances are what matters, they should be minimal, e.g., just `Crypto crypto` and `DSignable ..`. Note: the super-class constraints of the classes are what consensus needs, *not* what the default implementations of the methods need. If a default implementation needs more constraints, add them to the *default signature*.
It will be used by all eras, so having Shelley in the name is confusing.
40610c5
to
6cb87f9
Compare
These constraint synonyms make the contexts of the API classes much more readable.
6cb87f9
to
a0d58d3
Compare
2702: Update dependencies r=mrBliss a=mrBliss Highlights: * IntersectMBO/cardano-ledger#1915 * IntersectMBO/cardano-ledger#1922 * IntersectMBO/cardano-ledger#1902 * IntersectMBO/cardano-ledger#1923 * IntersectMBO/cardano-ledger#1927 * IntersectMBO/cardano-ledger#1929 Co-authored-by: Thomas Winant <thomas@well-typed.com>
In the
Shelley.Spec.Ledger.API.*
modules, define type classes for the mostimportant functionality consensus. These classes are parametric in the era.
Instances should be provided for each era (Shelley, Allegra, Mary, etc.). At the
moment, only instances for
ShelleyEra
are provided.These classes list a bunch of super-class constraints that consensus relies on.
I have tried to be complete, but there's a good chance I forgot to add a few
constraints that are currently already satisfied.
Default implementations are provided for each method so that an empty instance
declaration should be enough for each class + era combination. The constraints
on these instances are what matters, they should be minimal, e.g., just
Crypto crypto
andDSignable ..
.Note: the super-class constraints of the classes are what consensus needs, not
what the default implementations of the methods need. If a default
implementation needs more constraints, add them to the default signature.