Skip to content

Add LeiosCert to DijkstraBlockBody#5872

Merged
ch1bo merged 17 commits into
masterfrom
ch1bo/cardano-crypto-leios
Jun 30, 2026
Merged

Add LeiosCert to DijkstraBlockBody#5872
ch1bo merged 17 commits into
masterfrom
ch1bo/cardano-crypto-leios

Conversation

@ch1bo

@ch1bo ch1bo commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Description

This adds the LeiosCert as an SMaybe to the DijkstraBlockBody. The type and its encoding is defined in cardano-crypto-leios, a new package on the cardano-base repository. See IntersectMBO/cardano-base#670

This also includes a fix of the DijkstrBlockBodyRaw instance for EncCBORGroup instance: it was missing the invalid transactions field.

New block_body CDDL after this change (also regenerated in the diff):

block_body =
  [ invalid_transactions : invalid_transactions/ nil
  , transactions      : [* transaction]
  , leios_certificate : leios_certificate/ nil
  , peras_certificate : peras_certificate/ nil
  ]

with

leios_certificate =
  [ signers              : bytes           ;bitfield
  , aggregated_signature : leios_signature
  ]

leios_signature = bytes .size 48

Checklist

  • Commits in meaningful sequence and with useful messages.
  • Tests added or updated when needed.
  • CHANGELOG.md files updated for packages with externally visible changes.
    NOTE: New section is never added with the code changes. (See RELEASING.md).
  • Versions updated in .cabal and CHANGELOG.md files when necessary, according to the
    versioning process.
  • Version bounds in .cabal files updated when necessary.
    NOTE: If bounds change in a cabal file, that package itself must have a version increase. (See RELEASING.md).
  • Code formatted (use scripts/fourmolize.sh).
  • Cabal files formatted (use scripts/cabal-format.sh).
  • CDDL files are up to date (use scripts/gen-cddl.sh)
  • hie.yaml updated (use scripts/gen-hie.sh).
  • Self-reviewed the diff.

@ch1bo ch1bo requested a review from a team as a code owner June 17, 2026 07:26
Copilot AI review requested due to automatic review settings June 17, 2026 07:26
@ch1bo ch1bo added the Leios Tickets related in some form to work on Leios label Jun 17, 2026
@ch1bo ch1bo changed the title Leios: Add LeiosCert to DijkstraBlockBody Add LeiosCert to DijkstraBlockBody Jun 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the Dijkstra era block body format to optionally include a Leios certificate (LeiosCert) and updates the corresponding CBOR and CDDL representations, along with test generators/specs to exercise both the “TxsRB” and “CertRB” shapes.

Changes:

  • Add StrictMaybe LeiosCert to DijkstraBlockBodyRaw / DijkstraBlockBody and update CBOR encoding/decoding accordingly.
  • Regenerate/update Dijkstra CDDL + Huddle rules to include leios_certificate (and make cert fields / nil in block_body).
  • Update testlib instances/generators and CDDL specs to cover both block body shapes; add new cardano-crypto-leios dependency wiring.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
libs/cardano-ledger-binary/src/Cardano/Ledger/Binary/Decoding/Decoder.hs Adds an in-code review note inside decodeRecordNamedT (should be removed).
eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/TreeDiff.hs Adds ToExpr LeiosCert for better diffs without orphan signature instances.
eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Binary/Annotator.hs Updates block body decoding to expect 4 fields and decode optional Leios cert.
eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Arbitrary.hs Adds Arbitrary LeiosCert and new small block body generators for “TxsRB” vs “CertRB”.
eras/dijkstra/impl/test/Test/Cardano/Ledger/Dijkstra/Binary/CddlSpec.hs Splits block_body CDDL round-trip specs into “TxsRB” and “CertRB”.
eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/BlockBody/Internal.hs Adds Leios cert field + updates CBOR encode/decode; updates EncCBORGroup (currently mismatched for StrictMaybe encoding).
eras/dijkstra/impl/cddl/lib/Cardano/Ledger/Dijkstra/HuddleSpec.hs Adds Leios certificate/signature rules; updates block_body rule layout and generator to 4 fields.
eras/dijkstra/impl/cddl/data/dijkstra.cddl Updates block_body CDDL and defines leios_certificate / leios_signature.
eras/dijkstra/impl/cardano-ledger-dijkstra.cabal Adds cardano-crypto-leios (+ hedgehog-quickcheck for generators) to relevant components.
cabal.project Adds a source-repository-package pin to pull in cardano-crypto-leios from cardano-base.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/BlockBody/Internal.hs Outdated
Comment thread eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Arbitrary.hs Outdated
@ch1bo ch1bo force-pushed the ch1bo/cardano-crypto-leios branch 3 times, most recently from bfce2c9 to 6662626 Compare June 17, 2026 17:27
@ch1bo ch1bo force-pushed the ch1bo/cardano-crypto-leios branch 2 times, most recently from 24c8a40 to 5094471 Compare June 18, 2026 19:29
@ch1bo ch1bo requested a review from lehins June 18, 2026 19:34
@ch1bo ch1bo force-pushed the ch1bo/cardano-crypto-leios branch 2 times, most recently from 6d5c292 to 5a2478f Compare June 18, 2026 21:28

@lehins lehins left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking great. Thank you.

Comment thread eras/dijkstra/impl/cardano-ledger-dijkstra.cabal Outdated
Comment thread eras/dijkstra/impl/cardano-ledger-dijkstra.cabal Outdated
Comment thread eras/dijkstra/impl/cddl/lib/Cardano/Ledger/Dijkstra/HuddleSpec.hs Outdated
Comment thread eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/BlockBody/Internal.hs Outdated
Comment thread eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/BlockBody/Internal.hs Outdated
Comment thread eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/BlockBody/Internal.hs Outdated
Comment thread eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/BlockBody/Internal.hs Outdated
Comment thread cabal.project Outdated
Comment thread eras/dijkstra/impl/cddl/lib/Cardano/Ledger/Dijkstra/HuddleSpec.hs
Comment thread eras/dijkstra/impl/cddl/data/dijkstra.cddl
@ch1bo ch1bo force-pushed the ch1bo/cardano-crypto-leios branch 2 times, most recently from 55b8e91 to 6d22a5d Compare June 29, 2026 10:08
ch1bo added 2 commits June 29, 2026 12:08
Not sure if this is better, but the upstream module has a smaller API
surface now.
@ch1bo ch1bo force-pushed the ch1bo/cardano-crypto-leios branch 2 times, most recently from 612c1ce to b1ca9bf Compare June 29, 2026 14:32
@ch1bo ch1bo force-pushed the ch1bo/cardano-crypto-leios branch from b1ca9bf to 4543e08 Compare June 29, 2026 14:38

@lehins lehins left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thank you!

Comment thread eras/dijkstra/impl/cddl/data/dijkstra.cddl
Comment thread eras/dijkstra/impl/cddl/lib/Cardano/Ledger/Dijkstra/HuddleSpec.hs
Comment thread eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/TreeDiff.hs Outdated
Also fix hlint issues in the module
@ch1bo ch1bo enabled auto-merge June 29, 2026 20:09
@ch1bo ch1bo disabled auto-merge June 30, 2026 04:06
@ch1bo

ch1bo commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

These mutation tests are really cool! https://github.com/IntersectMBO/cardano-ledger/actions/runs/28398403686/job/84150174066#step:9:1

But it means that I need change or at least deprecate the current cert encoder already 😅😅

@ch1bo ch1bo force-pushed the ch1bo/cardano-crypto-leios branch from 8618cd2 to 7b69ca5 Compare June 30, 2026 05:56
@ch1bo ch1bo enabled auto-merge June 30, 2026 06:01
@ch1bo ch1bo merged commit 245e63d into master Jun 30, 2026
51 of 53 checks passed
@ch1bo ch1bo deleted the ch1bo/cardano-crypto-leios branch June 30, 2026 08:05
ch1bo added a commit to IntersectMBO/ouroboros-consensus that referenced this pull request Jul 3, 2026
Replaces mocked certificates with what was specified in CIP-164.

Depends on a new `cardano-crypto-leios` package that only holds the
`LeiosCert` IntersectMBO/cardano-base#670 and
the cardano-ledger which integrates that into the `DijkstraBlockBody`
IntersectMBO/cardano-ledger#5872

Explores code paths of certificate validation in the `applyBlock` /
block validation part of consensus.

Aggregates votes whenever added to the `LeiosVoteState` and creates a
certificate when exceeding the (hard-coded) threshold.

The forge loop gets the certificate from the `LeiosVoteState` and uses
it to decide whether we can build a `CertRB`.

TODO:
- [ ] Must not use committee of different epoch when creating block.
Either forecast (and re-aggregate the cert) or just index certificates
in the vote state by epoch and query using the current one.
- Left a FIXME in `VoteState.addVote` which will by extension affect
`queryCert`
- [x] Should clean up the many type class methods
- maybe anticipating an upcoming `applyBlock :: ... -> m (Either
(LedgerErr l) (LedgerResult l (l DiffMK))`
- [ ] Replace hacky integration with merges from `master` branches once
the `11.1` work was integrated (= Blocked by `11.1` release now.. or we
do that cleanup later)
  - [x] Use integrated `master` for `ouroboros-network`
  - [x] Use integrated `master` for `cardano-ledger`
  - [ ] Use integrated `master` for `ouroboros-consensus`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Leios Tickets related in some form to work on Leios

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prototype Voting

4 participants