Skip to content

Conversation

@aniketd
Copy link
Contributor

@aniketd aniketd commented Nov 24, 2025

Description

New libraries named cddl for Mary through Babbage to implement typeclass-based cuddle definitions to generate .cddl files from.

Follow-up PRs should implement for Conway.

This is the second phase in our efforts to address #5194

NOTE

codegen on CI is expected to FAIL, and its diff is important to know exactly what has changed in the new implementation.

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.

* Export `Era` from `Cardano.Ledger.Huddle` so that later eras do not
need to depend on core directly; they can just import the previous era.
* Add smart-constructors for scripts-related rules and reorganise them.
Repeat the same additions as core and shelley for mary.

Update changelogs for shelley and allegra to mention `generate-cddl`.
Repeat the same additions as core, shelley, allegra and mary.
@aniketd aniketd force-pushed the aniketd/cddl-typeclass-mary branch from ae10611 to 3920e01 Compare November 25, 2025 10:16
Repeat the same additions as core, shelley, allegra, mary and alonzo.
@aniketd aniketd force-pushed the aniketd/cddl-typeclass-mary branch from 3920e01 to 3e363b1 Compare November 25, 2025 12:38
@aniketd aniketd marked this pull request as ready for review November 25, 2025 13:52
@aniketd aniketd requested a review from a team as a code owner November 25, 2025 13:52
Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

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

Very, very nice!
I really like how this new approach to using Huddle is coming along.

Comment on lines +50 to +51
instance HuddleRule "major_protocol_version" MaryEra where
huddleRule _ = "major_protocol_version" =:= (0 :: Integer) ... (5 :: Integer)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be safe to create an instance for all eras like this in cardano-ledger-core, but please confirm that it is indeed the case. If it is not, then we'll need to figure out later how to make it be the case, since that should always be true for all eras, otherwise it would be impossible to transition out of the era.

Suggested change
instance HuddleRule "major_protocol_version" MaryEra where
huddleRule _ = "major_protocol_version" =:= (0 :: Integer) ... (5 :: Integer)
instance Era era => HuddleRule "major_protocol_version" era where
huddleRule _ = "major_protocol_version" =:= (0 :: Integer) ... lastSupportedEraVersion
where
lastSupportedEraVersion =
getVersion $ errorFail (succVersion (eraProtVerHigh @era)) :: Integer)

, transaction_witness_sets : [* transaction_witness_set]
, auxiliary_data_set : {* transaction_index => auxiliary_data}
, invalid_transactions : [* transaction_index]
, invalid_transactions : [* transaction_index] ; new
Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn't new in Babbage era

Comment on lines +295 to +296
, "block_body_size" ==> VUInt //- "merkle triple root"
, "block_body_hash" ==> huddleRule @"hash32" p
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe that comment was intended for the block body hash, instead of size

Suggested change
, "block_body_size" ==> VUInt //- "merkle triple root"
, "block_body_hash" ==> huddleRule @"hash32" p
, "block_body_size" ==> VUInt
, "block_body_hash" ==> huddleRule @"hash32" p //- "merkle triple root"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants