Skip to content

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

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

Update tx-generator to not use deprecated cardano-api API#6602
carbolymer wants to merge 5 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

Summary

Migrate tx-generator to use the experimental cardano-api for transaction building and era dispatch.

  • Use IsEra constraint and Cardano.Api.Experimental transaction building across the tx construction and submission pipeline
  • Narrow era support to Conway and Dijkstra only - pre-Conway eras are no longer exercised by the benchmarking workbench
  • Remove pre-Conway CBOR metadata property tests that were already broken at runtime
  • Dijkstra metadata tests commented out pending makeUnsignedTx support in cardano-api

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated
  • Any changes are noted in the CHANGELOG.md for affected package
  • The version bounds in .cabal files are updated
  • CI passes

@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

Experimental API migration guide: https://gist.github.com/carbolymer/1967d68a8d4ed4b80cbbf50ee8698bf8

@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
Comment thread bench/tx-generator/src/Cardano/Benchmarking/Script/Selftest.hs
@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
Comment thread bench/tx-generator/app/calibrate-script.hs Outdated
Comment thread bench/tx-generator/app/calibrate-script.hs Outdated
Comment thread bench/tx-generator/app/calibrate-script.hs Outdated
@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.

Comment thread bench/tx-generator/src/Cardano/TxGenerator/Tx.hs Outdated
Comment thread bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SizedMetadata.hs Outdated
@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
Comment thread bench/tx-generator/app/calibrate-script.hs Outdated

@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.

Comment thread bench/tx-generator/src/Cardano/TxGenerator/Fund.hs Outdated
Comment thread bench/tx-generator/src/Cardano/TxGenerator/Genesis.hs Outdated
@carbolymer
carbolymer force-pushed the mgalazyn/chore/update-tx-generator-to-use-experimental-api branch from b6acf4c to 4dc6a4b Compare July 2, 2026 19:13
@carbolymer
carbolymer requested a review from Jimbo4350 July 2, 2026 19:13

@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.

There are still a few sites that use the old api's types. If you want to merge what you have and deal with them in a follow up PR that's fine but let me know.

Comment thread bench/tx-generator/app/calibrate-script.hs Outdated
Comment thread bench/tx-generator/app/calibrate-script.hs Outdated
Comment thread bench/tx-generator/app/calibrate-script.hs Outdated
Comment thread bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SizedMetadata.hs Outdated
Comment thread bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs Outdated
unsignedTx <- first (\err -> TxGenError $ "genTx: " ++ show err) $ makeUnsignedTx era txBodyContent
let witVKeys = [makeKeyWitness era unsignedTx (WitnessPaymentKey key) | key <- allKeys]
let tx = case signTx era [] witVKeys unsignedTx of
SignedTx signedLedgerTx -> ShelleyTx shelleyBasedEra signedLedgerTx

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.

Old api's Tx type used here.

@carbolymer carbolymer Jul 15, 2026

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.

fixed - genTx returns SignedTx and the pipeline carries it end to end; the single remaining ShelleyTx wrap is in mkTxInModeCardano, since TxInMode has no constructor for the experimental type

mkTxOut v = case forEraMaybeEon (cardanoEra @era) of
Nothing -> error "mkUtxOScript: scriptDataSupportedInEra==Nothing"
Just tag -> TxOut
plutusScriptAddr

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.

Old api's TxOut type used here.

@carbolymer carbolymer Jul 15, 2026

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.

fixed - ledger TxOut via mkCoinTxOut + datumTxOutL; there's no experimental datum helper yet, this is the same recipe cardano-api's own FromJSON (TxOut era) uses internally

Comment thread bench/tx-generator/src/Cardano/TxGenerator/Genesis.hs Outdated
}
mkUTxOVariant networkId key value = obtainCommonConstraints (useEra @era) $
let
mkTxOut v = TxOut (keyAddress @era networkId key) (lovelaceToTxOutValue (shelleyBasedEra @era) v) TxOutDatumNone ReferenceScriptNone

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.

Old TxOut type used here.

@carbolymer carbolymer Jul 15, 2026

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.

fixed - mkCoinTxOut + experimental TxOut

@carbolymer

Copy link
Copy Markdown
Contributor Author

Pushed the rest of the migration: all Tx/TxOut sites now use the experimental API. The old API remains in exactly two places: the TxInMode/submitTxToNodeLocal submission edge (no experimental submission path exists yet) and ScriptInAnyLang script loading, which waits for IntersectMBO/cardano-api#1245 - follow-up PR once that's released.

@carbolymer
carbolymer requested a review from Jimbo4350 July 15, 2026 12:13
@carbolymer
carbolymer force-pushed the mgalazyn/chore/update-tx-generator-to-use-experimental-api branch 2 times, most recently from 02094f3 to 87c11e2 Compare July 15, 2026 12:17
obtainCommonConstraints era $ do
let allKeys = mapMaybe getFundKey $ inFunds ++ collFunds
expInputs = map (\f -> (getFundTxIn f, AnyKeyWitnessPlaceholder)) inFunds
expMetadata = case metadata 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.

The witness needs to taken from the fund as well (getFundWitness f) - the placeholder won't work if we submit Plutus script txns.
The placeholder always leads to a MissingScriptWitnessesUTXOW error from ledger for all Plutus workloads.

executionUnits
in return (ScriptWitness ScriptWitnessForSpending scriptWitness, script, getScriptData scriptData, scriptFee)
ScriptInAnyLang _ PlutusScript{} ->
return (AnyKeyWitnessPlaceholder, script, getScriptData scriptData, scriptFee)

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.

A correct script witness needs to be constructed here by means of the new API, carrying all the values same as before.
This will then be used in a Fund, so it goes hand-in-hand with my other comment. The placeholder is a bug breaking Plutus workloads.

Comment thread bench/tx-generator/src/Cardano/Benchmarking/Script/Selftest.hs
@mgmeier

mgmeier commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

There's still this in the status quo: Cardano.TxGenerator.Fund.FundInEra's _fundWitness field (and getFundWitness's return type, and Cardano.TxGenerator.UTxO.mkUTxOScript's witness parameter) are typed AnyWitness era, where era is cardano-api's API-level tag. A genuine Plutus script witness (AnyPlutusScript/AnyPlutusScriptWitness) requires era to be an actual cardano-ledger-core Era instance. The API-level ConwayEra tag doesn't have one.

So addressing this will have major ripples throughout the code base.

@mgmeier

mgmeier commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

pre-Conway eras are no longer exercised by the benchmarking workbench

That is only partially true. The workbench still supports benchmarking profiles pre-Conway. We do not exercise them, because they're not relevant to Cardano Mainnet currently. Secondly, tx-generator has use cases outside workbench, and constraining one does not imply constraining the other.

tx-generator aims to be a general-purpose submission service, runnable for any testnet, for any eras. Tying the tool to the new API will effectively remove that capability and attach it closely to the state of Mainnet.

I'm aware the reduction of era coverage is a direct constraint imposed by the new, experimental API. This leads to some general questions:

  • The existing API is named "deprecated" in the PR. What's its remaining lifecycle?
  • Is there a replacement in the new API, or besides it, for anything pre-Conway, or will that just disappear from cardano-api?
  • The new API is named "experimental" - does the tx-generator really need to buy in now?
  • Is there motive and means for the tx-generator to remain a more general rather than a quite era-specific tool?

@mgmeier
mgmeier requested a review from a team as a code owner July 23, 2026 11:33
@mgmeier

mgmeier commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

In lack of a suitable test case, I've pushed a (TEMP) commit to validate a fix:

  • make ci-test-hydra-autonix - let it finish (should be <10mins)
  • Inspect run/current/node-*/stdout - you'll see the error under the trace namespace Mempool.RejectedTx.
  • If they've disappeared - run/current/analysis/chain.txt should show (mostly) blocks of 2-3kiB in size. This means, the script txns have been adopted.

@carbolymer
carbolymer force-pushed the mgalazyn/chore/update-tx-generator-to-use-experimental-api branch from a8044a8 to f6981ee Compare August 5, 2026 09:53
@carbolymer
carbolymer force-pushed the mgalazyn/chore/update-tx-generator-to-use-experimental-api branch from f6981ee to 178c813 Compare August 5, 2026 13:23
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