Repository navigation
Update tx-generator to not use deprecated cardano-api API - #6602
carbolymer wants to merge 7 commits into
Conversation
2064644 to
0e48d61
Compare
adb450f to
fd7f5d5
Compare
|
Experimental API migration guide: https://gist.github.com/carbolymer/1967d68a8d4ed4b80cbbf50ee8698bf8 |
b95df49 to
892b6c9
Compare
24672d4 to
44e94ac
Compare
44e94ac to
8d46065
Compare
There was a problem hiding this comment.
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.Experimentalprimitives (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.
2615b9d to
b6acf4c
Compare
|
This PR is stale because it has been open 45 days with no activity. |
fdb38d5 to
b1256c2
Compare
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
It looks like we should parameterize runPlutus with era (and therefore the executable that eventually calls this). I would get feedback from @mgmeier here.
There was a problem hiding this comment.
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 |
c6ce8b9 to
c1443af
Compare
…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.
c1443af to
e23fea0
Compare
- 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]>
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]>
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]>
- 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]>
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]>
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]>
- 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]>
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]>
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]>
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]>
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 throughwithEra/shelleyBasedEraConstraints.The experimental API is still used, but only for witness vocabulary types (
AnyWitness,PlutusScriptWitness,AnyPlutusScript,SignedTx), not for a separate transaction-building path.AnyWitness (LedgerEra era),makePlutusContextconstructs the witness via the newCardano.TxGenerator.Setup.Plutushelpers (toAnyPlutusScript,mkPlutusSpendingWitness), andgenTxconsumes each fund's stored witness.scriptLanguageSupportedInEra). Scripts are decoded with cardano-api'sdecodeAnyPlutusScript, which also checks that the era supports the script's language.TxGenErrorinstead of callingerror:mkUTxOScriptreturns it for Plutus before Alonzo or for an unsupported language, andinterpretPayModesurfaces it.SizedMetadata) and genesis funding are on the samecreateCompatibleTxtrack, generic overIsShelleyBasedEra.SignedTx.calibrate-scripttakes its era from the protocol version in its parameters file and builds its dummy transaction withcreateCompatibleTx. 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-scriptreports every failure with the caller's call stack (via cardano-api'sliftEitherError), and theErrorinstance ofTxGenErrornow prints thePlutusErrorandTxGenErrormessages instead of an empty string.supervisorctlcall, so runs work on hosts that have their own/etc/supervisord.conf.formatting,generic-monoidandghc-prim) and the-Wno-deprecationspragmas across the library,calibrate-scriptandtx-generator-apitest, now that nothing deprecated remains.Validated end to end with
make ci-test-hydra-autonix: noMissingScriptWitnessesUTXOWrejections, 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-chairmanandchairman-testscompile; the testnet and chairman suites were not run.Checklist
CHANGELOG.mdfor affected package.cabalfiles are updatedhlintstylish-haskellghc-9.6andghc-9.12