Draft
Conversation
This commits introduces the module: Ouroboros.Consensus.Peras.Params To consolidate all the protocol parameters related to Peras in one place. Until we defined concrete BlockSupportsPeras for the different block types + HFC, all blocks satisfy: type PerasCfg blk = PerasParams Co-authored-by: Agustin Mista <[email protected]> Co-authored-by: Alexander Esgen <[email protected]> Co-authored-by: Georgy Lukyanov <[email protected]> Co-authored-by: Thomas BAGREL <[email protected]> Co-authored-by: Nicolas BACQUEY <[email protected]>
This commit adds a small helper to compute over Peras round numbers. Will be needed later on to implement the Peras voting rules. Co-authored-by: Agustin Mista <[email protected]> Co-authored-by: Alexander Esgen <[email protected]> Co-authored-by: Georgy Lukyanov <[email protected]> Co-authored-by: Thomas BAGREL <[email protected]> Co-authored-by: Nicolas BACQUEY <[email protected]>
This commit simplifies the interface of the HasPerasCertX typeclasses, removing the StandardHash superclass constraint, and splitting them into several smaller typeclasses. Co-authored-by: Agustin Mista <[email protected]> Co-authored-by: Alexander Esgen <[email protected]> Co-authored-by: Georgy Lukyanov <[email protected]> Co-authored-by: Thomas BAGREL <[email protected]> Co-authored-by: Nicolas BACQUEY <[email protected]>
This commit defines a generic WithArrivalTime combinator to wrap a value with its arrival time (as a Relative time). This is needed by Peras in several places, e.g., to evaluate the voting rules. Notably, we store a raw Relative time instead of a (arguably more apt) SlotNo or PerasRoundNo to defer as much as possible having to deal with the case where making this translation (timestamp -> slot/round) is not possible due to the HFC time translation horizon. Instead, the client will need to perform this translation in a context where such a failure cannot occur or can be more easily dealt with. Co-authored-by: Agustin Mista <[email protected]> Co-authored-by: Alexander Esgen <[email protected]> Co-authored-by: Georgy Lukyanov <[email protected]> Co-authored-by: Thomas BAGREL <[email protected]> Co-authored-by: Nicolas BACQUEY <[email protected]>
This commit wraps the existing ValidatedPerasCerts stored in the PerasCertDB with their corresponding arrival time. In addition, it adapts tests to use either a randomly generated arrival time, or (when appropriate) one generated by a monotonically increasing SystemTime. Co-authored-by: Agustin Mista <[email protected]> Co-authored-by: Alexander Esgen <[email protected]> Co-authored-by: Georgy Lukyanov <[email protected]> Co-authored-by: Thomas BAGREL <[email protected]> Co-authored-by: Nicolas BACQUEY <[email protected]>
This commit adds a method to the PerasCertDB API to retrieve the latest certificate seen. This is certificate needed to implement the Peras voting and must be kept around even after garbage collection. Because of this, we extend the internal state of the PerasCertDB to store this special certificate on the side, and (potentially) update it after new certificates are added to the database. Co-authored-by: Agustin Mista <[email protected]> Co-authored-by: Alexander Esgen <[email protected]> Co-authored-by: Georgy Lukyanov <[email protected]> Co-authored-by: Thomas BAGREL <[email protected]> Co-authored-by: Nicolas BACQUEY <[email protected]>
Co-authored-by: Agustin Mista <[email protected]> Co-authored-by: Alexander Esgen <[email protected]> Co-authored-by: Georgy Lukyanov <[email protected]> Co-authored-by: Thomas BAGREL <[email protected]> Co-authored-by: Nicolas BACQUEY <[email protected]>
This commit introduces a couple of new types to represent Peras votes and their corresponding certificate forging API. Notably, this requires an initial representation of notions like vote targets, vote stakes and stake distributions over multiple stake pools. Co-authored-by: Agustin Mista <[email protected]> Co-authored-by: Alexander Esgen <[email protected]> Co-authored-by: Georgy Lukyanov <[email protected]> Co-authored-by: Thomas BAGREL <[email protected]> Co-authored-by: Nicolas BACQUEY <[email protected]>
Co-authored-by: Agustin Mista <[email protected]> Co-authored-by: Alexander Esgen <[email protected]> Co-authored-by: Georgy Lukyanov <[email protected]> Co-authored-by: Thomas BAGREL <[email protected]> Co-authored-by: Nicolas BACQUEY <[email protected]>
This commit adds the vote aggregation routine used to turn sufficiently many Peras votes for the same block into a Peras certificate. Co-authored-by: Nicolas BACQUEY <[email protected]> Co-authored-by: Thomas BAGREL <[email protected]> Co-authored-by: Agustin Mista <[email protected]>
This commit defined the API and implements an initial in-memory version of the PerasVoteDB, used to keep track of Peras votes received through object diffusion. Co-authored-by: Nicolas BACQUEY <[email protected]> Co-authored-by: Thomas BAGREL <[email protected]> Co-authored-by: Agustin Mista <[email protected]>
This commit defines ObjectDiffusion instances for Peras votes using the PerasVoteDB as a storage backend. Co-authored-by: Nicolas BACQUEY <[email protected]> Co-authored-by: Thomas BAGREL <[email protected]> Co-authored-by: Agustin Mista <[email protected]>
Co-authored-by: Nicolas BACQUEY <[email protected]> Co-authored-by: Thomas BAGREL <[email protected]> Co-authored-by: Agustin Mista <[email protected]>
This commit splits the PerasCert and PerasVote types defined as part of the degenerate global BlockSupportsPeras instance into separate modules. This is the first step of a series of changes needed to define a proper BlockSupportsPeras instance for individual block types and the HFC.
e141a8b to
57602e0
Compare
77d474b to
1860284
Compare
1a3a058 to
109a836
Compare
57602e0 to
86e4177
Compare
bc855a0 to
023456f
Compare
86e4177 to
d15e94b
Compare
023456f to
cc3b2fd
Compare
d15e94b to
15c4cf0
Compare
7fdc36b to
62ca030
Compare
c679fad to
5611fa1
Compare
jasagredo
reviewed
Mar 3, 2026
| -- Ledger state is forecast into ledger view for the target 'PerasRoundNo'. | ||
| (OneEraLedgerView nsLedgerView) <- forecastToViewAtRound hfpcLedgerConfig ledgerState roundNo | ||
| nsVoteAndLedgerView <- ensureSameEraPair (nsVote, nsLedgerView) | ||
| -- Dispatch to the per-era forgePerasVote. |
Contributor
There was a problem hiding this comment.
Suggested change
| -- Dispatch to the per-era forgePerasVote. | |
| -- Dispatch to the per-era validatePerasVote. |
| let summary = State.reconstructSummaryLedger ledgerConfig unwrappedLedgerState | ||
| -- Query the hard fork history to determine what is the start slot of this | ||
| -- PerasRound. Thanks to 'runQueryNS', the result is wrapped in an 'NS' which | ||
| -- \*also* gives us the era the round falls in by its position. |
Contributor
There was a problem hiding this comment.
Suggested change
| -- \*also* gives us the era the round falls in by its position. | |
| -- __also__ gives us the era the round falls in by its position. |
This is the haddock markup for bold
| -- Ledger state is forecast into ledger view for the target slot. | ||
| nsLedgerView <- forcastToViewAtSlot ledgerConfig slot ledgerState | ||
| -- Ensure the query era and the forecasted view era agree. | ||
| nsQueryResAndLedgerView <- ensureSameEraPair (nsQueryRes, getOneEraLedgerView nsLedgerView) |
Contributor
There was a problem hiding this comment.
Isn't this trivially true always?
Comment on lines
+587
to
+596
| downcastHardForkPoint :: | ||
| forall blk xs. | ||
| SingleEraBlock blk => | ||
| Point (HardForkBlock xs) -> | ||
| Point blk | ||
| downcastHardForkPoint = \case | ||
| GenesisPoint -> | ||
| GenesisPoint | ||
| BlockPoint s (OneEraHash h) -> | ||
| BlockPoint s (fromShortRawHash (Proxy @blk) h) |
Contributor
There was a problem hiding this comment.
This feels weird. I think you should be able to do castPoint directly no?
Comment on lines
+598
to
+610
| -- | Upcast a 'Point' from a single era into a 'Point' of the hard fork block | ||
| -- by encoding the raw hash via 'toShortRawHash'. Used by accessor instances | ||
| -- to return 'Point (HardForkBlock xs)' from single-era point values. | ||
| upcastToHardForkPoint :: | ||
| forall blk xs. | ||
| SingleEraBlock blk => | ||
| Point blk -> | ||
| Point (HardForkBlock xs) | ||
| upcastToHardForkPoint = \case | ||
| GenesisPoint -> | ||
| GenesisPoint | ||
| BlockPoint s h -> | ||
| BlockPoint s (OneEraHash (toShortRawHash (Proxy @blk) h)) |
This file contains hidden or 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
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.
Description
Please include a meaningful description of the PR and link the relevant issues
this PR might resolve.
Also note that: