Skip to content

Add LeiosCert to DijkstraBlockBody#5872

Open
ch1bo wants to merge 15 commits into
masterfrom
ch1bo/cardano-crypto-leios
Open

Add LeiosCert to DijkstraBlockBody#5872
ch1bo wants to merge 15 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 on lines 634 to 638
decodeRecordNamedT name getRecordSize decoder =
decodeListLikeT name decoder $ \result n ->
-- REVIEW: Is n really the requested/expected? It's the one we decode and
-- thus n is rather the actual/found.
lift $ matchSize ("Record " <> name) n (getRecordSize result)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well, it was exactly my intention to reach a reviewer in this PR :)

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 from 6662626 to 24c8a40 Compare June 18, 2026 09:44
@ch1bo ch1bo force-pushed the ch1bo/cardano-crypto-leios branch 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 from d58a6be to 6d5c292 Compare June 18, 2026 21:10
@ch1bo ch1bo force-pushed the ch1bo/cardano-crypto-leios branch 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

-- cabal-allow-newer end
-- Points to cardano-base/ch1bo/cardano-crypto-leios
source-repository-package

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.

Naturally, we can't merge this PR, until caradno-crypto-leios is on CHaP

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, we need the upstream PR merged first and then I'll release it.

then pure TNull
else genArrayTerm $ TInteger . toInteger <$> invalidIxIxs
txsTerm <- withAntiGen (withAnnotation "transactions") $ genArrayTerm txs
-- NOTE: This would not be a valid block because txs are not allowed when a

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.

I'd like to understand all possible modes here for block body contents, so could you please provide a response to this message, so we make sure we get validation logic right.
This is my understanding today of valid block contents in Dijkstra:

  • Praos block:
    • Transactions, No Leios Certificate, maybe Peras Certificate
    • No Transactions, No Leios Certificate, maybe Peras Certificate
  • Ranking Block can contain:
    • No Transactions, Leios Certificate, maybe Peras Certificate
  • Endorsed Block:
    • Transactions (many of them). No Leios Certificate, No Peras Certificate.

Is my understanding on block contents correct?

Also, I believe EB, must always follow RB, otherwise chain is invalid, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

From a Leios perspective we call all Praos blocks "Ranking blocks" (RB) and distinguish two cases for the block body:

  • TxsRB = txs, no leios cert (and optional peras or other things)
  • CertRB = no txs, leios cert (and optional peras or other things)

An "Endorser block" (EB) also has an invalid txs index, but otherwise just contains transaction hashes. One could inline those transactions and call the inlined structure the EB.

Yes, EBs would extend an RB (that announced the EB) and be followed by a CertRB (that certifies the EB).

It's currently not settled how we'd be validating EBs (by the ledger). A first sketch just folds calls to ApplyTx (mempool API) to update the ledger state when we see a CertRB. See this, very recent prototype code:


leios_signature = bytes .size 48

peras_certificate = bytes

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.

Is there any upper or lower limit on the size of certificate, aside from block body size limit?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For leios (you commented on peras here), certs will be 48 bytes for the signature + committee size / 8 bytes + cbor overhead. The maximum committee size would be all registered pools ~ 3000 - typically it would rather be < 1000. So the maximum you can expect is 429B and typical 178B.

This follows the pattern of other cardano-base types.
ch1bo added 2 commits June 21, 2026 20:34
Not sure if this is better, but the upstream module has a smaller API
surface now.
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.

3 participants