Skip to content

Update tx-generator to not use deprecated cardano-api API - #6602

Open
carbolymer wants to merge 7 commits into
masterfrom
mgalazyn/chore/update-tx-generator-to-use-experimental-api
Open

carbolymer wants to merge 7 commits into
masterfrom
mgalazyn/chore/update-tx-generator-to-use-experimental-api

Conversation

@carbolymer

@carbolymer carbolymer commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

Removes all use of the deprecated cardano-api API from tx-generator.

The original plan was to migrate onto the experimental API and narrow era support to Conway/Dijkstra.
That plan changed: tx-generator now builds every transaction, for every era Shelley through Dijkstra, on a single track via Cardano.Api.Compatible.Tx.createCompatibleTx, with per-era dispatch retained through withEra/shelleyBasedEraConstraints.
The experimental API is still used, but only for witness vocabulary types (AnyWitness, PlutusScriptWitness, AnyPlutusScript, SignedTx), not for a separate transaction-building path.

  • Build real Plutus spending witnesses: fund witnesses are typed AnyWitness (LedgerEra era), makePlutusContext constructs the witness via the new Cardano.TxGenerator.Setup.Plutus helpers (toAnyPlutusScript, mkPlutusSpendingWitness), and genTx consumes each fund's stored witness.
  • Plutus V1/V2 workloads are supported through the compatible API from Alonzo/Babbage onwards respectively (gated by scriptLanguageSupportedInEra). Scripts are decoded with cardano-api's decodeAnyPlutusScript, which also checks that the era supports the script's language.
  • Unsupported script eras and languages are reported as a TxGenError instead of calling error: mkUTxOScript returns it for Plutus before Alonzo or for an unsupported language, and interpretPayMode surfaces it.
  • Metadata sizing (SizedMetadata) and genesis funding are on the same createCompatibleTx track, generic over IsShelleyBasedEra.
  • Fix the fee estimate double-counting key witnesses (the preview tx is already signed, so no dummy witnesses need to be added).
  • Adapt the Ogmios submission path to the experimental SignedTx.
  • Dijkstra goes through the same path, and the Dijkstra metadata tests are enabled again.
  • calibrate-script takes its era from the protocol version in its parameters file and builds its dummy transaction with createCompatibleTx. Conway (v10) output is unchanged. With Babbage or Alonzo parameter files, the size and fee estimates now come from a transaction in that era (previously a Conway transaction, 16 bytes larger). Calibrating PlutusV4 in Dijkstra is not supported yet (no V4 evaluator, no protocol version 12 parameters file) and is left for a follow-up.
  • calibrate-script reports every failure with the caller's call stack (via cardano-api's liftEitherError), and the Error instance of TxGenError now prints the PlutusError and TxGenError messages instead of an empty string.
  • The hard-coded signing keys of the selftest and the pure example keep their decode error if decoding fails.
  • workbench: pass the run's supervisord config explicitly to every supervisorctl call, so runs work on hosts that have their own /etc/supervisord.conf.
  • Drop now-unused build-deps (including formatting, generic-monoid and ghc-prim) and the -Wno-deprecations pragmas across the library, calibrate-script and tx-generator-apitest, now that nothing deprecated remains.

Validated end to end with make ci-test-hydra-autonix: no MissingScriptWitnessesUTXOW rejections, script-spending blocks adopted (2.4 kB blocks passing the analysis filters).

Verified locally with nix: the tx-generator library, exe and test suite pass (17 of 17 tests, including both Dijkstra tests).
cardano-testnet-test, cardano-node-chairman and chairman-tests compile; the testnet and chairman suites were not run.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. These may include:
    • golden tests
    • property tests
    • roundtrip tests
    • integration tests
  • Any changes are noted in the CHANGELOG.md for affected package
  • The version bounds in .cabal files are updated
  • CI passes
    • Code is linted with hlint
    • Code is formatted with stylish-haskell
    • Code builds on Linux, MacOS and Windows for ghc-9.6 and ghc-9.12
  • Self-reviewed the diff

@carbolymer carbolymer self-assigned this Jun 17, 2026
@carbolymer carbolymer linked an issue Jun 17, 2026 that may be closed by this pull request
16 tasks
@carbolymer
carbolymer force-pushed the mgalazyn/feature/update-cardano-rpc-11.0 branch from 2064644 to 0e48d61 Compare June 18, 2026 10:40
Base automatically changed from mgalazyn/feature/update-cardano-rpc-11.0 to master June 19, 2026 12:45
@carbolymer
carbolymer force-pushed the mgalazyn/chore/update-tx-generator-to-use-experimental-api branch 3 times, most recently from adb450f to fd7f5d5 Compare June 29, 2026 13:24
@carbolymer

carbolymer commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor Author

@carbolymer
carbolymer force-pushed the mgalazyn/chore/update-tx-generator-to-use-experimental-api branch 3 times, most recently from b95df49 to 892b6c9 Compare June 30, 2026 11:55
@carbolymer
carbolymer force-pushed the mgalazyn/chore/update-tx-generator-to-use-experimental-api branch 4 times, most recently from 24672d4 to 44e94ac Compare June 30, 2026 14:32
@carbolymer
carbolymer requested a review from Jimbo4350 July 1, 2026 13:01
@carbolymer
carbolymer force-pushed the mgalazyn/chore/update-tx-generator-to-use-experimental-api branch from 44e94ac to 8d46065 Compare July 1, 2026 13:01
@carbolymer
carbolymer requested a review from Copilot July 1, 2026 13:01

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 migrates the tx-generator benchmarking/workbench code from deprecated cardano-api APIs to the experimental transaction-building and era-dispatch APIs, while narrowing the exercised era surface to Conway and Dijkstra.

Changes:

  • Switch multiple tx construction/submission paths to Cardano.Api.Experimental primitives (IsEra, useEra, makeUnsignedTx, signTx, etc.).
  • Narrow era dispatch in benchmarking scripts/selftests to Conway/Dijkstra and update protocol-parameters file references to protocol-parameters-v10.json.
  • Remove/comment out pre-Conway (and currently-broken) metadata CBOR property tests, and refactor the remaining metadata sizing implementation to use experimental tx building.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
bench/tx-generator/tx-generator.cabal Updates dependencies/ghc-options to match the experimental API migration and reduced era surface.
bench/tx-generator/test/Main.hs Drops pre-Conway metadata property tests; keeps Conway tests and comments out Dijkstra pending support.
bench/tx-generator/src/Cardano/TxGenerator/UTxO.hs Moves UTxO output/fund construction to IsEra + obtainCommonConstraints.
bench/tx-generator/src/Cardano/TxGenerator/Utils.hs Adds txIdFromTx and updates TxInMode construction to experimental-era constraints.
bench/tx-generator/src/Cardano/TxGenerator/Tx.hs Reimplements genTx using experimental unsigned tx building + signing.
bench/tx-generator/src/Cardano/TxGenerator/PureExample.hs Updates the pure example to a post-Conway era and new protocol-parameters filename.
bench/tx-generator/src/Cardano/TxGenerator/Genesis.hs Ports genesis expenditure transaction building/signing to experimental API.
bench/tx-generator/src/Cardano/TxGenerator/Fund.hs Narrows witness-era matching to Conway/Dijkstra under IsEra.
bench/tx-generator/src/Cardano/Benchmarking/Script/Selftest.hs Updates protocol-parameters filename and switches selftest era to Conway.
bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs Narrows era dispatch and ports generator evaluation/fee estimation to experimental-era constraints.
bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SubmissionClient.hs Ports submission client to IsEra and uses txIdFromTx for TxId extraction.
bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SizedMetadata.hs Reworks metadata sizing measurement to build dummy txs via the experimental API.
bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx.hs Switches the benchmark entrypoint constraints to IsEra and uses obtainCommonConstraints.
bench/tx-generator/app/calibrate-script.hs Ports the calibration script’s tx sizing/fee approximation logic to experimental tx building and Plutus witness construction.

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

@carbolymer
carbolymer force-pushed the mgalazyn/chore/update-tx-generator-to-use-experimental-api branch 2 times, most recently from 2615b9d to b6acf4c Compare July 2, 2026 11:06
@carbolymer
carbolymer marked this pull request as ready for review July 2, 2026 12:31
@carbolymer
carbolymer requested review from a team as code owners July 2, 2026 12:31
@carbolymer carbolymer changed the title Update tx-generator to not use deprecated cardano-api api Update tx-generator to not use deprecated cardano-api API Jul 2, 2026

@Jimbo4350 Jimbo4350 left a comment •

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.

Some more leftover types.

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open 45 days with no activity.

@github-actions github-actions Bot added the Stale label Oct 19, 2026
@carbolymer carbolymer removed the Stale label Oct 19, 2026
@carbolymer
carbolymer force-pushed the mgalazyn/chore/update-tx-generator-to-use-experimental-api branch 3 times, most recently from fdb38d5 to b1256c2 Compare November 5, 2026 21:23

@Jimbo4350 Jimbo4350 left a comment •

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.

We should get some feedback from the benchmarking team regarding the hard coding to Conway. If benchmarking is accustomed to having flexibility across all eras, then we need to define the scope of what needs to be done to our "compatible" api in order to support their needs.

ScriptInAnyLang _lang (PlutusScript version (PlutusScriptSerialised sbs)) -> do
let slang = toPlutusSLanguage version
decode :: forall l. (L.PlutusLanguage l, Typeable l) => L.SLanguage l -> IO (AnyPlutusScript (ShelleyLedgerEra ConwayEra))
decode _ = case L.decodePlutusRunnable @l (eraProtVerHigh era) (L.Plutus (L.PlutusBinary sbs)) of

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.

It looks like we should parameterize runPlutus with era (and therefore the executable that eventually calls this). I would get feedback from @mgmeier here.

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.

I think we can extract the era from protocol params file. I've updated the PR.

, cardano-data
, cardano-diffusion ^>= 1.3
, cardano-git-rev ^>= 0.2.2
, cardano-ledger-alonzo

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.

👍

@carbolymer
carbolymer force-pushed the mgalazyn/chore/update-tx-generator-to-use-experimental-api branch 2 times, most recently from c6ce8b9 to c1443af Compare November 6, 2026 16:20
@carbolymer
carbolymer requested a review from Jimbo4350 November 6, 2026 16:23
…call

supervisord is launched with an explicit --config, but all other
supervisorctl invocations relied on the client's default config search
path, which only works when no /etc/supervisord.conf exists: both
client and server then fall back to the same localhost:9001 default.
On a host where /etc/supervisord.conf exists, supervisorctl either
fails outright ("could not read config file" when unreadable) or
silently targets the wrong server (e.g. unix:///run/supervisor.sock).

Pass -c "$dir"/supervisor/supervisord.conf at all 12 call sites.
No tx-generator component imports modules from these packages.
The library drops cardano-crypto-wrapper, cardano-ledger-alonzo, cardano-ledger-byron, cardano-strict-containers, constraints-extras, formatting, generic-monoid, ghc-prim and unordered-containers.
calibrate-script and tx-generator-apitest drop transformers and transformers-except, and tx-generator-apitest also drops cardano-cli.
Sort the hiding list in Cardano.Benchmarking.GeneratorTx and the imports of the tx-generator-test Main module.
The first-entry comment in SizedMetadata now gives the per-era costs that firstEntry already uses, including 42 bytes from Alonzo onwards.
… experimental API

toAnyPlutusScript decodes a ScriptInAnyLang into the ledger-side AnyPlutusScript of an era.
It returns a TxGenError for a non-Plutus script, for a Plutus language that the era does not support, and for a script that fails to decode.
mkPlutusSpendingWitness builds the AnyWitness that spends a UTxO locked by such a script.
Build, sign and submit transactions as SignedTx with the compatible and experimental cardano-api APIs, and remove every -Wno-deprecations suppression.
Funds locked by a Plutus script carry their Plutus spending witness as an AnyWitness, built with the new helpers.
mkUTxOScript and makePlutusContext report an era or a script language that cannot lock funds as a TxGenError instead of calling error.
The transaction preview estimates the fee of the signed preview transaction with estimateMinFeeTx.
calibrate-script takes its era from the protocol version in its parameters file and builds its dummy transaction with createCompatibleTx, as the generator does. calibrate-script reports every failure with the caller's call stack, and the Error instance of TxGenError now prints the PlutusError and TxGenError messages instead of an empty string.
The selftest and the pure example run in Conway with the v10 protocol parameters.
The hard-coded signing keys of the selftest and the pure example are decoded with either (error . show) id, so a decode failure keeps the decoding error instead of a fixed message.
@carbolymer
carbolymer force-pushed the mgalazyn/chore/update-tx-generator-to-use-experimental-api branch from c1443af to e23fea0 Compare November 10, 2026 18:40
Russoul added a commit that referenced this pull request Nov 16, 2026
- The workbench passes the supervisord config to every supervisorctl call.
- TxGenError's Error instance prints PlutusError and TxGenError messages,
  instead of an empty string.
- The selftest and the pure example keep the decoding error of their
  hard-coded signing keys.
- A stray blank line in .gitignore, and sorted imports.

Co-authored-by: Mateusz Galazyn <[email protected]>
Russoul added a commit that referenced this pull request Nov 16, 2026
Transactions are built with cardano-api's compatible API (createCompatibleTx)
instead of the experimental one, as in #6602, so tx-generator runs in every
Shelley-based era again rather than Conway and Dijkstra only.

- genTx builds with createCompatibleTx and Compatible.addWitnesses, and takes
  a TxMetadataInEra. Reference inputs come from the witnesses.
- genNestedTx keeps the experimental API, in Dijkstra: the compatible API has
  no sub-transactions yet. It shall go once it does. Without sub-transactions
  it builds the same bytes as genTx, which NestedTxTest checks for key inputs,
  metadata, a reference script output, and LoopV3 and LoopV4 spent by
  reference and in the witnesses.
- Transactions are Exp.SignedTx from the generators to submission, the Ogmios
  endpoint and the dumps.
- withEra dispatches on every Shelley-based era. Script outputs set the datum
  hash per era (Alonzo, Babbage onwards), reference script outputs need
  Babbage onwards, and NestedNtoM checks for Dijkstra.
- The Plutus spending witness is #6602's toAnyPlutusScript and
  mkPlutusSpendingWitness, which can now also spend by reference; the legacy
  witness conversion goes.
- Fee estimates use the ledger's estimateMinFeeTx in every era.
- The genesis transaction, SizedMetadata and calibrate-script are #6602's:
  calibrate-script builds in the era of the protocol version, with Plutus V4
  in Dijkstra, as preExecutePlutusScript runs V4.
- The selftest and the pure example use protocol-parameters-v10.json.
- A fund's value stays a Coin, and TxEnvironment's metadata a TxMetadataInEra.

Co-authored-by: Mateusz Galazyn <[email protected]>
Russoul added a commit that referenced this pull request Nov 16, 2026
As in #6602: the library no longer needs cardano-crypto-wrapper,
cardano-ledger-alonzo, cardano-ledger-byron, constraints-extras, formatting,
generic-monoid, ghc-prim and unordered-containers, calibrate-script and the
API test no longer need transformers and transformers-except, nor the API
test cardano-cli. Nothing uses deprecated API any more, so -Wno-deprecations
goes. cardano-strict-containers stays, for UTxO's StrictMaybe.

Co-authored-by: Mateusz Galazyn <[email protected]>
Russoul added a commit that referenced this pull request Nov 19, 2026
- The workbench passes the supervisord config to every supervisorctl call.
- TxGenError's Error instance prints PlutusError and TxGenError messages,
  instead of an empty string.
- The selftest and the pure example keep the decoding error of their
  hard-coded signing keys.
- A stray blank line in .gitignore, and sorted imports.

Co-authored-by: Mateusz Galazyn <[email protected]>
Russoul added a commit that referenced this pull request Nov 19, 2026
Transactions are built with cardano-api's compatible API (createCompatibleTx)
instead of the experimental one, as in #6602, so tx-generator runs in every
Shelley-based era again rather than Conway and Dijkstra only.

- genTx builds with createCompatibleTx and Compatible.addWitnesses, and takes
  a TxMetadataInEra. Reference inputs come from the witnesses.
- genNestedTx keeps the experimental API, in Dijkstra: the compatible API has
  no sub-transactions yet. It shall go once it does. Without sub-transactions
  it builds the same bytes as genTx, which NestedTxTest checks for key inputs,
  metadata, a reference script output, and LoopV3 and LoopV4 spent by
  reference and in the witnesses.
- Transactions are Exp.SignedTx from the generators to submission, the Ogmios
  endpoint and the dumps.
- withEra dispatches on every Shelley-based era. Script outputs set the datum
  hash per era (Alonzo, Babbage onwards), reference script outputs need
  Babbage onwards, and NestedNtoM checks for Dijkstra.
- The Plutus spending witness is #6602's toAnyPlutusScript and
  mkPlutusSpendingWitness, which can now also spend by reference; the legacy
  witness conversion goes.
- Fee estimates use the ledger's estimateMinFeeTx in every era.
- The genesis transaction, SizedMetadata and calibrate-script are #6602's:
  calibrate-script builds in the era of the protocol version, with Plutus V4
  in Dijkstra, as preExecutePlutusScript runs V4.
- The selftest and the pure example use protocol-parameters-v10.json.
- A fund's value stays a Coin, and TxEnvironment's metadata a TxMetadataInEra.

Co-authored-by: Mateusz Galazyn <[email protected]>
Russoul added a commit that referenced this pull request Nov 19, 2026
As in #6602: the library no longer needs cardano-crypto-wrapper,
cardano-ledger-alonzo, cardano-ledger-byron, constraints-extras, formatting,
generic-monoid, ghc-prim and unordered-containers, calibrate-script and the
API test no longer need transformers and transformers-except, nor the API
test cardano-cli. Nothing uses deprecated API any more, so -Wno-deprecations
goes. cardano-strict-containers stays, for UTxO's StrictMaybe.

Co-authored-by: Mateusz Galazyn <[email protected]>
Russoul added a commit that referenced this pull request Nov 19, 2026
- The workbench passes the supervisord config to every supervisorctl call.
- TxGenError's Error instance prints PlutusError and TxGenError messages,
  instead of an empty string.
- The selftest and the pure example keep the decoding error of their
  hard-coded signing keys.
- A stray blank line in .gitignore, and sorted imports.

Co-authored-by: Mateusz Galazyn <[email protected]>
Russoul added a commit that referenced this pull request Nov 19, 2026
Transactions are built with cardano-api's compatible API (createCompatibleTx)
instead of the experimental one, as in #6602, so tx-generator runs in every
Shelley-based era again rather than Conway and Dijkstra only.

- genTx builds with createCompatibleTx and Compatible.addWitnesses, and takes
  a TxMetadataInEra. Reference inputs come from the witnesses.
- genNestedTx keeps the experimental API, in Dijkstra: the compatible API has
  no sub-transactions yet. It shall go once it does. Without sub-transactions
  it builds the same bytes as genTx, which NestedTxTest checks for key inputs,
  metadata, a reference script output, and LoopV3 and LoopV4 spent by
  reference and in the witnesses.
- Transactions are Exp.SignedTx from the generators to submission, the Ogmios
  endpoint and the dumps.
- withEra dispatches on every Shelley-based era. Script outputs set the datum
  hash per era (Alonzo, Babbage onwards), reference script outputs need
  Babbage onwards, and NestedNtoM checks for Dijkstra.
- The Plutus spending witness is #6602's toAnyPlutusScript and
  mkPlutusSpendingWitness, which can now also spend by reference; the legacy
  witness conversion goes.
- Fee estimates use the ledger's estimateMinFeeTx in every era.
- The genesis transaction, SizedMetadata and calibrate-script are #6602's:
  calibrate-script builds in the era of the protocol version, with Plutus V4
  in Dijkstra, as preExecutePlutusScript runs V4.
- The selftest and the pure example use protocol-parameters-v10.json.
- A fund's value stays a Coin, and TxEnvironment's metadata a TxMetadataInEra.

Co-authored-by: Mateusz Galazyn <[email protected]>
Russoul added a commit that referenced this pull request Nov 19, 2026
As in #6602: the library no longer needs cardano-crypto-wrapper,
cardano-ledger-alonzo, cardano-ledger-byron, constraints-extras, formatting,
generic-monoid, ghc-prim and unordered-containers, calibrate-script and the
API test no longer need transformers and transformers-except, nor the API
test cardano-cli. Nothing uses deprecated API any more, so -Wno-deprecations
goes. cardano-strict-containers stays, for UTxO's StrictMaybe.

Co-authored-by: Mateusz Galazyn <[email protected]>
Russoul added a commit that referenced this pull request Nov 26, 2026
Transactions are built with cardano-api's compatible API (createCompatibleTx)
instead of the experimental one, as in #6602, so tx-generator runs in every
Shelley-based era again rather than Conway and Dijkstra only.

- genTx builds with createCompatibleTx and Compatible.addWitnesses, and takes
  a TxMetadataInEra. Reference inputs come from the witnesses.
- genNestedTx keeps the experimental API, in Dijkstra: the compatible API has
  no sub-transactions yet. It shall go once it does. Without sub-transactions
  it builds the same bytes as genTx, which NestedTxTest checks for key inputs,
  metadata, a reference script output, and LoopV3 and LoopV4 spent by
  reference and in the witnesses.
- Transactions are Exp.SignedTx from the generators to submission, the Ogmios
  endpoint and the dumps.
- withEra dispatches on every Shelley-based era. Script outputs set the datum
  hash per era (Alonzo, Babbage onwards), reference script outputs need
  Babbage onwards, and NestedNtoM checks for Dijkstra.
- The Plutus spending witness is #6602's toAnyPlutusScript and
  mkPlutusSpendingWitness, which can now also spend by reference; the legacy
  witness conversion goes.
- Fee estimates use the ledger's estimateMinFeeTx in every era.
- The genesis transaction, SizedMetadata and calibrate-script are #6602's:
  calibrate-script builds in the era of the protocol version, with Plutus V4
  in Dijkstra, as preExecutePlutusScript runs V4.
- The selftest and the pure example use protocol-parameters-v10.json.
- A fund's value stays a Coin, and TxEnvironment's metadata a TxMetadataInEra.
- The metadata cost tests cover every Shelley-based era again, as in #6602.

Co-authored-by: Mateusz Galazyn <[email protected]>

This branch has not been deployed

No deployments
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.

Migrate tx-generator to the experimental Cardano API (Conway and later)

4 participants