-
Notifications
You must be signed in to change notification settings - Fork 32
[WIP] Add basic API for certificate validation #1655
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
base: peras-staging
Are you sure you want to change the base?
Conversation
The PR still needs a lot of work, but I think it would be good to get some early feedback on 7212954. I pushed a bunch of changes adapting call sites to use
Based on my current understanding, there is a tension between keeping either
Do you think (1) is the right approach here? Or is (2) something more akin to what we would want at this stage in the dev cycle? |
c5beff6
to
7212954
Compare
I think (1) is indeed the right approach, the benefits seem compelling even at this stage. (In the standup, we just briefly talked about some of the implications this has once we store certificates on disk, such as whether we also want to store the weight boost of a certificate on disk, or recompute it on startup. But this is not important for now.)
This is actually a desired outcome of this change, see the last paragraph in the issue description of #94. To keep this PR minimal, still always using |
7212954
to
4f487d9
Compare
(perasCertRound (validatedPerasCert cert)) | ||
(perasCertBoostedBlock (validatedPerasCert cert)) |
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 pattern pops up everywhere, so we might want to introduce some helpers:
validatedPerasCertRound :: ValidatedPerasCert blk -> PerasRoundNo
validatedPerasCertBoostedBlock :: ValidatedPerasCert blk -> Point blk
This naming would be consistent with the existing validatedPerasCertBoost
projection.
@@ -14,6 +14,8 @@ module Ouroboros.Consensus.Block.SupportsPeras | |||
, boostPerCert | |||
, BlockSupportsPeras (..) | |||
, PerasCert (..) | |||
, ValidatedPerasCert (..) | |||
, defaultPerasCfg |
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 will have to be turned into an external parameter at some point, IIUC.
defaultPerasCfg :: PerasCfg blk | ||
defaultPerasCfg = PerasCfg{perasCfgWeightBoost = boostPerCert} |
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.
Another value that will have to be computed upon some external parameters, IIUC.
let perasRoundNo = PerasRoundNo 999 | ||
-- TODO ^ not the value we want, but the value we have |
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.
Mocked-up value for now.
I'm not sure whether we need to parameterize makePerasCertPoolWriterFromChainDB
, or if there's a way to extract the current PerasRoundNo
from the monadic context somehow.
throw (userError (show validationError)) | ||
-- TODO ^ refine this exception |
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.
Do we have a concrete exception type in mind for this (e.g. some existing one to add a variant to, or perhaps a new PerasException
).
A quick (and rather uninformed) search didn't reveal any obvious candidate 🤔
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.
There's also the question of whether we want to short-circuit and throw an exception upon the first validation error (at it happens now with sequence
), or to be pedantic and collect all the validation errors in the current batch and report them at once.
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.
Not sure exactly what these synonyms are currently capturing. The changes in this module were needed after massaging the rest of the code.
However, having ended up with the duality:
*Inbound
|*Writer
->PerasCert
, and*Outbound
|*Reader
->ValidatedPerasCert
Makes me feel this might make a bit of sense. Please let me know if I am way off-base here 😅
PerasCertDbEnv m blk -> SlotNo -> m () | ||
PerasCertDbEnv m blk -> | ||
SlotNo -> | ||
m () |
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 signature didn't change, so I'm not sure why this change crept in.
If fourmolu running on some lenient/not-strict mode?
Closes tweag/cardano-peras#94