Skip to content

Bump to cardano-api 11.2.0.0 + migrate to Certificate API#1379

Open
Jimbo4350 wants to merge 6 commits into
masterfrom
jordan/bump-cardano-api-11.2.0.0
Open

Bump to cardano-api 11.2.0.0 + migrate to Certificate API#1379
Jimbo4350 wants to merge 6 commits into
masterfrom
jordan/bump-cardano-api-11.2.0.0

Conversation

@Jimbo4350
Copy link
Copy Markdown
Contributor

@Jimbo4350 Jimbo4350 commented May 18, 2026

Changelog

- description: |
    Bump to cardano-api 11.2.0.0. Folds in three migrations that previously
    lived in separate PRs / unreleased branches:

    - Companion to cardano-api #1200: drop deprecated TxBody / TxBodyContent
      uses (was #1375).
    - Companion to cardano-api #1209: migrate createCompatibleTx, toTxOutInEra,
      and toTxOutInShelleyBasedEra to the experimental TxOut plus supplemental
      datum map (was #1376).
    - Companion to cardano-api #1210: legacy Cardano.Api.Certificate module is
      gone; migrate all imports to Cardano.Api.Experimental.Certificate /
      Cardano.Api.Compatible.Certificate as appropriate, and drop vacuous
      hiding clauses that became -Wdodgy-imports errors under -Werror.
  type:
   - maintenance
  projects:
   - cardano-cli

Context

Test run: https://github.com/IntersectMBO/cardano-node-tests/actions/runs/26061932453

Supersedes #1375 and #1376. cardano-api 11.2.0.0 ships these breaking changes:

Plus two non-breaking notable changes (#1205 evaluateTransaction, #1200 TxBody/TxBodyContent deprecation, #1193 export of evaluateTransactionExecutionUnits).

cardano-api 11.2.0.0 is now published to CHaP (timestamp 2026-05-18T18:23:40Z). This branch consumes it via the standard CHaP repository — the previous source-repository-package pin has been removed and the cardano-haskell-packages index-state plus the CHaP flake input have been bumped past the publish.

How to trust this PR

  • cabal build cardano-cli -j4 is green against cardano-api 11.2.0.0 from CHaP.
  • cabal test all -j4: cardano-cli-test 69/69 pass; cardano-cli-golden 686/686 pass.
  • fourmolu clean on all touched modules.
  • Self-contained commits:
    1. Drop deprecated TxBody from TxBodyFile phantom
    2. Migrate IncompleteTxBody and transaction commands to Exp.UnsignedTx
    3. Remove non-Byron TxOut CtxTx/CtxUTxO usage from cardano-cli
    4. Migrate to experimental TxOut in createCompatibleTx
    5. Bump cardano-api to 11.2.0.0 (via source-repository-package pin)
    6. Migrate to cardano-api 11.2.0.0 Certificate API
    7. cabal.project: bump cardano-api pin to signed 11.2.0.0 commit
    8. cabal.project: drop cardano-api SRP, pull 11.2.0.0 from CHaP

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated
  • Self-reviewed the diff
  • Build green and test suites pass
  • source-repository-package pin dropped; consuming cardano-api 11.2.0.0 from CHaP

pure $ TxOut addr val datum refScript
let legacyTxOut = TxOut addr val datum refScript
pure $
shelleyBasedEraConstraints sbe $
@Jimbo4350 Jimbo4350 marked this pull request as ready for review May 18, 2026 20:33
Copilot AI review requested due to automatic review settings May 18, 2026 20:33
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates cardano-cli to build against cardano-api-11.2.0.0 and migrates CLI code to the new Experimental/Compatible Certificate and TxOut APIs introduced by upstream breaking changes. This keeps the CLI warning-clean under -Werror while preserving existing command behavior and on-disk formats.

Changes:

  • Bump dependency bounds and Nix/CHaP pins to consume cardano-api ^>= 11.2 from CHaP.
  • Migrate transaction-body handling and several transaction commands from legacy TxBody usage to Exp.UnsignedTx / ledger-body based helpers.
  • Migrate certificate-related imports/types to Cardano.Api.Experimental.Certificate / Cardano.Api.Compatible.Certificate and adapt TxOut construction to produce (Exp.TxOut, supplemental-datum map).

Reviewed changes

Copilot reviewed 37 out of 38 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
flake.lock Bumps CHaP flake input revision/hash to a version containing cardano-api-11.2.0.0.
cabal.project Advances cardano-haskell-packages index-state past the 11.2.0.0 publish timestamp.
cardano-cli/cardano-cli.cabal Updates cardano-api bound to ^>=11.2.
cardano-cli/src/Cardano/CLI/Type/Common.hs Replaces TxBodyFile phantom type with a dedicated tag type to avoid deprecated/removed TxBody usage.
cardano-cli/src/Cardano/CLI/Read.hs Refactors IncompleteTxBody to carry Exp.UnsignedTx and updates txbody reading accordingly.
cardano-cli/src/Cardano/CLI/EraIndependent/Debug/TransactionView/Run.hs Updates txbody viewing to consume the new IncompleteTxBody representation.
cardano-cli/src/Cardano/CLI/EraBased/Transaction/Run.hs Migrates signing/witnessing/txid/submit/min-fee/script-cost paths to ledger-body + experimental helpers and new TxOut return types.
cardano-cli/src/Cardano/CLI/Compatible/Transaction/TxOut.hs Changes TxOut building to produce experimental outputs plus a supplemental datum map.
cardano-cli/src/Cardano/CLI/Compatible/Transaction/Run.hs Threads supplemental datum map into createCompatibleTx call.
cardano-cli/src/Cardano/CLI/Compatible/Json/Friendly.hs Switches friendly JSON rendering to use experimental TxOut wrapper and ledger datum rendering.
cardano-cli/src/Cardano/CLI/Type/Error/TxCmdError.hs Removes now-unreachable datum decoding error constructor/rendering after upstream type removal.
cardano-cli/src/Cardano/CLI/Type/Error/TxValidationError.hs Removes validateTxReturnCollateral helper (now unused after migration).
cardano-cli/src/Cardano/CLI/Type/Key.hs Moves stake pool metadata/relay types to Experimental Certificate API imports.
cardano-cli/src/Cardano/CLI/Type/Error/StakePoolCmdError.hs Migrates stake pool metadata error types/hashes to Experimental Certificate API.
cardano-cli/src/Cardano/CLI/Type/Error/GovernanceCmdError.hs Migrates DRep metadata hash types to Experimental Certificate API.
cardano-cli/src/Cardano/CLI/EraIndependent/Node/Command.hs Imports KESPeriod from Experimental Certificate API.
cardano-cli/src/Cardano/CLI/EraIndependent/Node/Run.hs Migrates operational certificate issuance to Experimental Certificate API.
cardano-cli/src/Cardano/CLI/EraBased/Genesis/Run.hs Migrates operational certificate issuance/types to Experimental Certificate API.
cardano-cli/src/Cardano/CLI/EraBased/Genesis/CreateTestnetData/Run.hs Migrates KES period / op cert counter types to Experimental Certificate API.
cardano-cli/src/Cardano/CLI/EraBased/Common/Option.hs Migrates KES/stake pool metadata/relay option types to Experimental Certificate API.
cardano-cli/src/Cardano/CLI/EraBased/Query/Run.hs Updates UTxO text rendering to use experimental TxOut wrapper + ledger-based value/datum rendering.
cardano-cli/src/Cardano/CLI/EraBased/StakePool/Run.hs Migrates stake pool metadata validation/hashing/params conversion to Experimental Certificate API.
cardano-cli/src/Cardano/CLI/EraBased/StakePool/Option.hs Migrates stake pool metadata hash type imports to Experimental Certificate API.
cardano-cli/src/Cardano/CLI/EraBased/StakePool/Internal/Metadata.hs Migrates stake pool metadata reference + hashing to Experimental Certificate API.
cardano-cli/src/Cardano/CLI/EraBased/StakePool/Command.hs Migrates stake pool command types (metadata/relay) to Experimental Certificate API.
cardano-cli/src/Cardano/CLI/Compatible/StakePool/Run.hs Migrates compatible stake pool params conversion to Experimental Certificate API.
cardano-cli/src/Cardano/CLI/Compatible/StakePool/Command.hs Migrates stake pool metadata reference/relay types to Experimental Certificate API.
cardano-cli/src/Cardano/CLI/EraBased/StakeAddress/Run.hs Drops legacy hiding clause; aligns with updated certificate APIs.
cardano-cli/src/Cardano/CLI/Compatible/StakeAddress/Run.hs Drops legacy hiding clause; aligns with updated certificate APIs.
cardano-cli/src/Cardano/CLI/EraBased/Governance/Run.hs Drops legacy hiding clause; aligns with updated certificate APIs.
cardano-cli/src/Cardano/CLI/EraBased/Governance/GenesisKeyDelegationCertificate/Run.hs Drops legacy hiding clause; aligns with updated certificate APIs.
cardano-cli/src/Cardano/CLI/EraBased/Governance/Committee/Run.hs Drops legacy hiding clause; aligns with updated certificate APIs.
cardano-cli/src/Cardano/CLI/EraBased/Governance/DRep/Run.hs Migrates DRep metadata hashing/types to Experimental Certificate API.
cardano-cli/src/Cardano/CLI/EraBased/Governance/DRep/Option.hs Migrates DRep metadata hash type imports to Experimental Certificate API.
cardano-cli/src/Cardano/CLI/EraBased/Governance/DRep/Command.hs Migrates DRep metadata type import to Experimental Certificate API.
cardano-cli/src/Cardano/CLI/Compatible/Governance/Command.hs Imports MIRPot from Compatible Certificate API.
cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/GenesisDelegateKeys.hs Updates AsType import for op cert issue counter to Experimental Certificate API.
cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/Operational.hs Updates AsType import for operational certificate to Experimental Certificate API.

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

@@ -1,3 +1,5 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
Comment on lines +1754 to 1756
IncompleteTxBody era (Exp.UnsignedTx ledgerTx) <-
lift (readFileTxBody txbodyFile) & onLeft (left . TxCmdTextEnvError)
witnesses <-
Jimbo4350 added 6 commits May 19, 2026 10:58
cardano-api 11.2.0.0 is published to CHaP. Bump the
cardano-haskell-packages index-state past the publish
(2026-05-18T18:23:40Z), bump the cardano-cli cabal dep from ^>=11.1
to ^>=11.2, and bump the CHaP flake input accordingly.

11.2.0.0 introduces breaking changes that subsequent commits in this
PR migrate cardano-cli to: legacy TxOut removed (cardano-api #1209),
legacy Certificate type removed (#1210), and TxBody/TxBodyContent
deprecated (#1200).
`TxBodyFile` was a `File (TxBody ())` whose phantom payload was only
ever used as a file-tag for option/parser plumbing; the bytes on disk
do not depend on it. Replace `TxBody ()` with a fresh empty
`TxBodyTag` data type so the alias no longer references the deprecated
`TxBody` from cardano-api PR #1200.

No on-disk format change. No call-site change beyond the alias itself.
Drops the last remaining uses of the deprecated old-API transaction
body surface (`TxBody`, `getTxBody`, `getTxBodyAndWitnesses`,
`makeShelleyKeyWitness`, `makeSignedTransaction`,
`evaluateTransactionExecutionUnits` on a deprecated `TxBody`,
`getTxId . getTxBody`) from cardano-cli's source tree.

`IncompleteTxBody` is reworked from a `newtype` wrapping
`InAnyShelleyBasedEra TxBody` into a GADT existential carrying
`Exp.UnsignedTx (ShelleyLedgerEra era)` plus `IsShelleyBasedEra`
evidence. `readFileTxBody` pattern-matches `ShelleyTx _ ledgerTx`
directly and wraps as `Exp.UnsignedTx ledgerTx` — no `getTxBody`.

Consumers in `Transaction.Run` are migrated to:
- `makeShelleyKeyWitness'` (ledger-level body) and `addWitnesses` for
  signing — both non-deprecated and work for all Shelley-based eras,
  preserving pre-Conway support.
- `getTxIdShelley` for transaction IDs.
- `evaluateTransactionExecutionUnitsShelley` (operates on the ledger
  `Tx` directly) for `transaction calculate-plutus-script-cost`,
  preserving Alonzo+ era support.
- `Exp.evaluateTransactionFee` on `Exp.UnsignedTx` for
  `transaction calculate-min-fee` (already Conway+ via `sbeToEra`).

`TransactionView.Run` no longer needs the
`makeSignedTransaction []`-then-extract-ledger boundary that PR #1374
added — the new `readFileTxBody` returns `Exp.UnsignedTx` directly.

The TextEnvelope I/O boundary still uses `Tx era` and `ShelleyTx _`
(both non-deprecated), since `Exp.UnsignedTx`/`Exp.SignedTx` have no
`HasTextEnvelope` instance. The on-disk `.tx`/`.txbody` formats are
unchanged.

The compatible command path (`Cardano.CLI.Compatible.Transaction.Run`)
was already using non-deprecated symbols (`makeShelleyKeyWitness'`,
`addWitnesses`) and is unchanged by this commit.
Eliminate the legacy 'TxOut CtxTx era' and 'TxOut CtxUTxO era' type
signatures and pattern matches from cardano-cli's non-Byron code paths.
Byron-era code uses a separate pre-Shelley tx output model and is left
alone — 'Exp.TxOut' is not applicable there.

  * 'friendlyTxOut' in 'Compatible/Json/Friendly.hs' now takes
    'Exp.TxOut (LedgerEra era)' and reads address, value, and
    reference script directly via the ledger lenses ('addrTxOutL',
    'valueTxOutL', 'referenceScriptTxOutL'). The two call sites
    ('basePairs', 'friendlyReturnCollateral') wrap the body's ledger
    outputs with 'Exp.TxOut' instead of going through
    'fromShelleyTxOut → fromCtxUTxOTxOut'. The dead 'friendlyTxOutValue'
    helper is dropped.

  * 'filteredUTxOsToText' in 'EraBased/Query/Run.hs' now takes a
    'ShelleyBasedEra era' witness, converts the api 'UTxO era' to the
    ledger UTxO once via 'toLedgerUTxO', then renders each entry from
    '(TxIn, Exp.TxOut (ShelleyLedgerEra era))' using ledger lenses.
    The pre-Babbage datum slot has no uniform ledger representation,
    so the renderer emits an empty placeholder there and shows the
    babbage+ ledger datum elsewhere — debug-style output, no golden
    tests touched.

  * Removed 'validateTxReturnCollateral' from
    'Type/Error/TxValidationError.hs'. It was exported but never
    called outside its own module; the actual return-collateral
    construction in 'EraBased/Transaction/Run' builds
    'Exp.TxReturnCollateral' directly.

Remaining uses of legacy ctx-typed tx outputs in cardano-cli are
confined to Byron-only modules.
Adapt to cardano-api PR #1209, which removes the legacy 'TxOut CtxTx era'
from the Compatible and Experimental APIs:

  * 'createCompatibleTx' now takes '[Exp.TxOut (ShelleyLedgerEra era)]'
    plus a new 'Map L.DataHash (L.Data ...)' argument carrying any
    supplemental datum bodies. The legacy 'TxOut CtxTx era' bundled
    supplemental datums inside outputs; 'Exp.TxOut' only carries the
    datum hash, so callers thread the full datum bodies in explicitly.
  * The bridge helpers 'fromLegacyTxOut', 'legacyDatumToDatum',
    'supplementalDatumFromLegacy', 'toLedgerDatum', and the
    'DatumDecodingError' type are deleted from 'Cardano.Api.Experimental.Tx'.

Migration:

  * 'mkTxOut' and 'toTxOutInAnyEra' now return
    '(Exp.TxOut (ShelleyLedgerEra era), Map DataHash (L.Data ...))'
    directly, building the legacy 'TxOut CtxTx era' internally only as
    a stepping stone for 'toShelleyTxOutAny'.
  * 'createCompatibleTx' call site in 'Compatible/Transaction/Run.hs'
    folds the per-output supplemental datums via 'Map.unions' and
    passes them as the new argument.
  * 'toTxOutInEra' and 'toTxOutInShelleyBasedEra' in
    'EraBased/Transaction/Run.hs' delegate directly to 'mkTxOut' (the
    deleted 'fromLegacyTxOut' is gone).
  * 'TxCmdDatumDecodingError' is removed since the underlying
    'Exp.DatumDecodingError' is gone and the new conversion is total.
cardano-api #1210 removed the legacy 'Cardano.Api.Certificate' module
and stopped re-exporting Certificate-construction helpers from
'Cardano.Api'. Migrate cardano-cli to import the relevant types
('StakePoolRelay', 'StakePoolMetadataReference', 'StakePoolMetadata',
'DRepMetadata', 'KESPeriod', 'OperationalCertificate',
'OperationalCertificateIssueCounter', 'PoolId', 'StakePoolParameters',
helpers like 'issueOperationalCertificate', 'validateAndHashStakePoolMetadata',
'toShelleyPoolParams', 'hashDRepMetadata', 'getKesPeriod', 'getOpCertCount',
data instances 'Hash StakePoolMetadataHash' / 'Hash DRepMetadataHash',
'AsType AsOperationalCertificate' / 'AsType AsOperationalCertificateIssueCounter',
'MIRPot') from 'Cardano.Api.Experimental.Certificate' or
'Cardano.Api.Compatible.Certificate' as appropriate.

Drops vacuous 'hiding (make*Certificate)' / 'hiding (Certificate)'
clauses that referenced names no longer re-exported from 'Cardano.Api',
which had become '-Wdodgy-imports' errors under '-Werror'. Removes the
redundant 'Cardano.Ledger.Core' qualified import from
'Cardano.CLI.Read' that became unused after the cardano-api re-export
narrowing.
@Jimbo4350 Jimbo4350 force-pushed the jordan/bump-cardano-api-11.2.0.0 branch from d200dd2 to db5a030 Compare May 19, 2026 14:59
type TxBodyFile = File (TxBody ())
data TxBodyTag

type TxBodyFile = File TxBodyTag
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not so certain how TxBodyTag is useful here. Usually the phantom type here is used to represent what's in the file. So it's kind of detached from the actual content. Maybe L.TxBody could be used? but it has kind TxLevel -> Type -> Type, so we'd have to assume a Tx level or thread it in.

Copy link
Copy Markdown
Contributor

@palas palas left a comment

Choose a reason for hiding this comment

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

Check the missing datum in friendlyTxOut before merging.

Other than that, it looks good. Just a few lints/suggestions

, "amount" .= friendlyLedgerValue era ledgerValue
, "stake reference"
.= friendlyStakeReference (fromShelleyStakeReference stake)
, "reference script" .= refScript
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
, "reference script" .= refScript
, "datum" .= case ledgerTxOut ^. L.datumTxOutL of
L.NoDatum -> Aeson.Null
L.DatumHash h -> toJSON h
L.Datum bd -> friendlyDatum (L.binaryDataToData bd)
, "reference script" .= refScript

It seems the datum here got removed. It seems originally it was only shown when present but, since this is Babbage onwards, I am guessing it is more consistent to show it as null if absent

Comment on lines +1291 to +1292
let ledgerTxBody = shelleyBasedEraConstraints sbe $ ledgerTx ^. L.bodyTxL
unsignedTxAsTx = shelleyBasedEraConstraints sbe $ ShelleyTx sbe ledgerTx
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
let ledgerTxBody = shelleyBasedEraConstraints sbe $ ledgerTx ^. L.bodyTxL
unsignedTxAsTx = shelleyBasedEraConstraints sbe $ ShelleyTx sbe ledgerTx
let ledgerTxBody = ledgerTx ^. L.bodyTxL
unsignedTxAsTx = ShelleyTx sbe ledgerTx

shelleyBasedEraConstraints is not necessary here

mkShelleyBootstrapWitness sbe mNetworkId ledgerTxBody bootstrapWitData
AShelleyKeyWitness skShelley ->
pure $ makeShelleyKeyWitness sbe txbody skShelley
let ledgerTxBody = shelleyBasedEraConstraints sbe $ ledgerTx ^. L.bodyTxL
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
let ledgerTxBody = shelleyBasedEraConstraints sbe $ ledgerTx ^. L.bodyTxL
let ledgerTxBody = ledgerTx ^. L.bodyTxL

Same here

Comment on lines +307 to +308
:: IsShelleyBasedEra era
=> ShelleyBasedEra era
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
:: IsShelleyBasedEra era
=> ShelleyBasedEra era
:: ShelleyBasedEra era

IsShelleyBasedEra era can be deduced from ShelleyBasedEra era by using shelleyBasedEraConstraints. But maybe we want it for convenience

Comment on lines +64 to +66
outsAndDatums <- mapM (toTxOutInAnyEra sbe) outs
let allOuts = map fst outsAndDatums
extraDatums = Map.unions (map snd outsAndDatums)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
outsAndDatums <- mapM (toTxOutInAnyEra sbe) outs
let allOuts = map fst outsAndDatums
extraDatums = Map.unions (map snd outsAndDatums)
(allOuts, extraDatumsMapList) <- mapAndUnzipM (toTxOutInAnyEra sbe) outs
let extraDatums = Map.unions extraDatumsMapList

Just showing off, but it is a bit simpler and eagerer

TxSubmitSuccess -> do
liftIO $ Text.hPutStrLn IO.stderr "Transaction successfully submitted. Transaction hash is:"
liftIO $ LBS.putStrLn $ Aeson.encode $ TxSubmissionResult $ getTxId $ getTxBody tx
liftIO $
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is outside of the PR, but, since we are at it, we could liftIO only once outside of the do instead

Comment on lines +1375 to +1386
let unsignedTx :: Exp.UnsignedTx (Exp.LedgerEra era)
unsignedTx = obtainCommonConstraints era $ Exp.UnsignedTx ledgerTx
shelleyfee :: Lovelace
shelleyfee =
obtainCommonConstraints era $
Exp.evaluateTransactionFee lpparams unsignedTx nShelleyKeyWitW32 0 sReferenceScript
txFeePerByte :: L.CoinPerByte
txFeePerByte = obtainCommonConstraints era $ lpparams ^. L.ppTxFeePerByteL
byronfee :: Lovelace
byronfee = calculateByronWitnessFees txFeePerByte nByronKeyWitnesses
fee :: Lovelace
fee = shelleyfee + byronfee
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since these definitions have types declarations, I would add an empty line between them, otherwise it is a bit hard to parse them

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.

5 participants