Skip to content

[Peras 27] Split degenerate BlockSupportsPeras instance - #2027

Closed
agustinmista wants to merge 22 commits into
peras/concrete-certs-and-votesfrom
peras/degenerate-peras-instances
Closed

agustinmista wants to merge 22 commits into
peras/concrete-certs-and-votesfrom
peras/degenerate-peras-instances

Conversation

@agustinmista

@agustinmista agustinmista commented May 5, 2026 •

Copy link
Copy Markdown
Contributor

This PR has the main goal of removing the existing degenerate forall blk. BlockSupportsPeras blk instance and replace it with separate, independent ones for the several block types in the codebase that need it.

To aid with this process, we have made a couple of preliminary changes:

  • Moving base Peras types into a separate O.C.Peras.Types module to keep O.C.Block.SupportsPeras as focused on the blk-dependent API as possible.
  • Consolidating all the HasPeras(Vote|Cert)X classes into two, IsPerasVote and IsPerasCert, grouping all the necessary non-crypto-related projections needed to operate on Peras votes and certificates.
  • Removing the PerasCfg blk associated type, in favor of keeping things simple and using the monomorphic PerasParams for now. These will likely need a major overhaul in the future when on-chain governance of these parameters becomes necessary.
  • Introducing dedicated modules for MockPeras(Vote|Cert)s, containing the non-crypto mocked Peras votes and certificates that were previously hardcoded everywhere. These will still be used for certain (mostly test) block types.
  • Provide an "empty" default BlockSupportsPeras instance defined in terms of Void, so Peras votes, certs, and errors are uninstantiable and can be discharged via absurd.

With this in place, the remaining changes mostly encompass the plumbing needed after removing the existing BlockSupportsPeras instance and replacing it with dedicated ones. Concretely:

  • ByronBlock uses the "emtpy" instance
  • ShelleyBlock proto era uses a mocked instance (to be replaced with a concrete one using real type for era ~ Dijkstra and empty ones for every other era. (@tbagrel1 is working on this on a separate PR)
  • HardForkBlock xs uses a mocked instance, but will be replaced with a compositional one defined around the two previous ones (also WIP)

On the testing side:

  • BlockA and BlockB both use the "empty" instance
  • DualByronBlock uses the "empty" instance
  • O.C.Mock.Ledger.Block.SimpleBlock c ext uses the "empty" instance
  • O.C.Storage.TestBlock.TestBlock uses a mocked instance (now with a properly instantiated getPerasCertInBlock)
  • Test.Util.TestBlock.TestBlockWith ptype uses a mocked instance (without any support for certificates in blocks, as it's not needed for any of the existing tests)

Finally, some general notes (notice that some of these are already covered by new issues linked in the comments below):

  • There is a substantial number of instances involving type families that had to be derived using standalone deriving statements now to keep GHC happy.
  • BlockSupportsPeras is still missing a forgePerasVote method. This will become evident soon when trying to write a blk-generic voting thread (BlockSupportsPeras currently misses a forgeVote method tweag/cardano-peras#248)
  • Some of the new BlockSupportsPeras instances are defined via orphans in dedicated modules. This is because:
    • SerialiseNodeToNodeConstraints blk now requires SerialiseNodeToNode (PerasVote blk) and SerialiseNodeToNode (PerasCert blk) which are only in scope after PerasVote blk and PerasCert blk are established when defining BlockSupportsPeras blk
    • Some SerialiseNodeToNodeConstraints instances are already defined as orphans in their own dedicated modules, forcing us to create a new module or to define BlockSupportsPeras blk in the same one as SerialiseNodeToNodeConstraints blk (confusing!). We might be able to rearrange constraints to avoid this, but that would probably mean adding SerialiseNodeToNode (Peras(Vote|Cert) blk) as superclasses to a type-class higher-up in the chain.
    • We favored tight constraints over "umbrella" ones as much as possible to avoid having to implement unnecessary/unrelated interfaces for test blocks as much as possible.
  • Mocked votes and certs are trivially validatable without errors (technically, with uninstantiable errors if being pedantic). For this to work, MockPerasVote carries its own stake. Please note this is not the case for real votes, as their stake is retrieved from the stake distribution after validation.
  • Some Peras... types will become redundant and get removed in a later PR when we start integrating components.

@agustinmista agustinmista self-assigned this May 5, 2026
@agustinmista agustinmista moved this to In Progress in cardano-peras May 5, 2026
@agustinmista
agustinmista force-pushed the peras/degenerate-peras-instances branch from 821b00a to 37fe870 Compare May 5, 2026 13:10
@agustinmista
agustinmista force-pushed the peras/concrete-certs-and-votes branch from f47be9f to b084253 Compare May 5, 2026 13:11
@agustinmista
agustinmista force-pushed the peras/degenerate-peras-instances branch from 37fe870 to 7fbebad Compare May 5, 2026 14:11
@agustinmista
agustinmista force-pushed the peras/concrete-certs-and-votes branch from b084253 to 67855ea Compare May 5, 2026 14:12
@agustinmista
agustinmista force-pushed the peras/degenerate-peras-instances branch from 7fbebad to 35a01bc Compare May 5, 2026 15:56
@agustinmista
agustinmista force-pushed the peras/concrete-certs-and-votes branch 3 times, most recently from 8a2bab8 to 10f8c2e Compare May 7, 2026 12:39
@agustinmista
agustinmista force-pushed the peras/degenerate-peras-instances branch 3 times, most recently from f827bf2 to c4b4797 Compare May 8, 2026 15:09
@agustinmista
agustinmista force-pushed the peras/concrete-certs-and-votes branch from 10f8c2e to e8a284d Compare May 11, 2026 08:37
@agustinmista
agustinmista force-pushed the peras/degenerate-peras-instances branch 9 times, most recently from d5d1fd0 to f7ecea3 Compare May 13, 2026 12:01
@agustinmista
agustinmista force-pushed the peras/concrete-certs-and-votes branch from e8a284d to 00df1fa Compare May 13, 2026 12:01
@agustinmista agustinmista moved this from In Progress to Peer review in cardano-peras May 13, 2026
@agustinmista agustinmista changed the title [Peras 29] Split degenerate BlockSupportsPeras instance [Peras 27] Split degenerate BlockSupportsPeras instance May 13, 2026
agustinmista and others added 12 commits May 19, 2026 15:44
This commit implements conversion routines between the brand-new
(concrete) Peras votes and certificates and their corresponding
(abstract) voting committee counterparts.

This is done by introducing a `VotingCommitteeSupportsPeras` type class
to allow us to easily change the underlying voting committee
implementation via a proxy type.

Co-authored-by: Agustin Mista <agustin.mista@moduscreate.com>
Co-authored-by: Thomas BAGREL <thomas.bagrel@tweag.io>
Co-authored-by: Nicolas BACQUEY <nicolas.bacquey@tweag.io>
This commit adds test helpers to aid with the definition of the upcoming
roundtrip properties for concrete Peras votes and certificates.

Co-authored-by: Agustin Mista <agustin.mista@moduscreate.com>
Co-authored-by: Thomas BAGREL <thomas.bagrel@tweag.io>
Co-authored-by: Nicolas BACQUEY <nicolas.bacquey@tweag.io>
This commit adds property tests for the newly added bitmap library
asserting that both conversion from and/to indices as well as
serialization roundtrip correctly.

Co-authored-by: Agustin Mista <agustin.mista@moduscreate.com>
Co-authored-by: Thomas BAGREL <thomas.bagrel@tweag.io>
Co-authored-by: Nicolas BACQUEY <nicolas.bacquey@tweag.io>
This commit adds serialization roundtrip tests for the concrete Peras
votes and certificate types.

Co-authored-by: Agustin Mista <agustin.mista@moduscreate.com>
Co-authored-by: Thomas BAGREL <thomas.bagrel@tweag.io>
Co-authored-by: Nicolas BACQUEY <nicolas.bacquey@tweag.io>
…ommittee types

This commit adds conversion rountrip tests between concrete Peras votes
and certificates and their corresponding (abstract) counterparts in the
WFALS and EveryoneVotes voting committee implementations.

Notably, the roundtrip properties allow testing both total (WFALS) and partial
(EveryoneVotes) conversions, generating both good and bad cases and
contrasting them against their expected rountrip outcome.

Co-authored-by: Agustin Mista <agustin.mista@moduscreate.com>
Co-authored-by: Thomas BAGREL <thomas.bagrel@tweag.io>
Co-authored-by: Nicolas BACQUEY <nicolas.bacquey@tweag.io>
Co-authored-by: Agustin Mista <agustin.mista@moduscreate.com>
Co-authored-by: Thomas BAGREL <thomas.bagrel@tweag.io>
Co-authored-by: Nicolas BACQUEY <nicolas.bacquey@tweag.io>
Co-authored-by: Agustin Mista <agustin.mista@moduscreate.com>
Co-authored-by: Thomas BAGREL <thomas.bagrel@tweag.io>
Co-authored-by: Nicolas BACQUEY <nicolas.bacquey@tweag.io>
Co-authored-by: Agustin Mista <agustin.mista@moduscreate.com>
Co-authored-by: Thomas BAGREL <thomas.bagrel@tweag.io>
Co-authored-by: Nicolas BACQUEY <nicolas.bacquey@tweag.io>
Co-authored-by: Agustin Mista <agustin.mista@moduscreate.com>
Co-authored-by: Thomas BAGREL <thomas.bagrel@tweag.io>
Co-authored-by: Nicolas BACQUEY <nicolas.bacquey@tweag.io>
Co-authored-by: Agustin Mista <agustin.mista@moduscreate.com>
Co-authored-by: Thomas BAGREL <thomas.bagrel@tweag.io>
Co-authored-by: Nicolas BACQUEY <nicolas.bacquey@tweag.io>
Co-authored-by: Agustin Mista <agustin.mista@moduscreate.com>
Co-authored-by: Thomas BAGREL <thomas.bagrel@tweag.io>
Co-authored-by: Nicolas BACQUEY <nicolas.bacquey@tweag.io>
Co-authored-by: Agustin Mista <agustin.mista@moduscreate.com>
Co-authored-by: Thomas BAGREL <thomas.bagrel@tweag.io>
Co-authored-by: Nicolas BACQUEY <nicolas.bacquey@tweag.io>
@agustinmista
agustinmista force-pushed the peras/degenerate-peras-instances branch from 662ef8e to 1c7aa1a Compare May 19, 2026 13:45
@agustinmista
agustinmista force-pushed the peras/concrete-certs-and-votes branch from 45f5251 to a7118cf Compare May 19, 2026 13:46
@agustinmista agustinmista moved this from Peer review to In Progress in cardano-peras May 22, 2026
@tbagrel1 tbagrel1 linked an issue Jun 18, 2026 that may be closed by this pull request
@tbagrel1 tbagrel1 moved this from In Progress to Ready to undraft (modulo rebasing/fixing doc) in cardano-peras Jun 18, 2026
@agustinmista
agustinmista force-pushed the peras/concrete-certs-and-votes branch 3 times, most recently from 54f6cf4 to 0802d91 Compare June 19, 2026 11:24
@agustinmista

Copy link
Copy Markdown
Contributor Author

Closing in favor of #2067

@github-project-automation github-project-automation Bot moved this from Ready to undraft (modulo rebasing/fixing doc) to Accepted (Q) in cardano-peras Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Split degenerate BlockSupportsPeras instance Consider consolidating vote-signing and VRF keys Interface design & HFC plumbing for Peras

3 participants