Update tx-generator to not use deprecated cardano-api API#6602
Update tx-generator to not use deprecated cardano-api API#6602carbolymer wants to merge 1 commit into
Conversation
2064644 to
0e48d61
Compare
adb450f to
fd7f5d5
Compare
|
Experimental API migration guide: https://gist.github.com/carbolymer/1967d68a8d4ed4b80cbbf50ee8698bf8 |
b95df49 to
892b6c9
Compare
| , teRawCBOR = "X \vl1~\182\201v(\152\250A\202\157h0\ETX\248h\153\171\SI/m\186\242D\228\NAK\182(&\162" | ||
| } | ||
| era = AnyCardanoEra AllegraEra | ||
| era = AnyCardanoEra ConwayEra |
There was a problem hiding this comment.
selftest is a smoke test for tx-generator so I presume we don't have to use Allegra here, and conway is fine?
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
b6acf4c to
4dc6a4b
Compare
Jimbo4350
left a comment
There was a problem hiding this comment.
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.
| let era = useEra @ConwayEra | ||
| anyPlutusScript <- obtainCommonConstraints era $ | ||
| case script of | ||
| ScriptInAnyLang _lang (PlutusScript version (PlutusScriptSerialised sbs)) -> do |
There was a problem hiding this comment.
This is still an old api type and we should be using AnyScript era. However there is no helper function to make this easy so I added it here: IntersectMBO/cardano-api#1245
There was a problem hiding this comment.
^ This can stay as is for now since 1245 needs to be merged and released.
|
|
||
| -- just placeholders | ||
| dummyTxIn ix = mkTxIn $ "900fc5da77a0747da53f7675cbb7d149d46779346dea2f879ab811ccc72a2162#" <> textShow @Int ix | ||
| dummyTxOut = TxOut (keyAddress (Testnet (NetworkMagic 42)) keyBenchmarkInputs) (lovelaceToTxOutValue shelleyBasedEra 1_000_000) TxOutDatumNone ReferenceScriptNone |
There was a problem hiding this comment.
Still using the old api's TxOut here.
|
|
||
| let | ||
| witVKey = makeKeyWitness era unsignedTx (WitnessPaymentKey keyBenchmarkInputs) | ||
| dummyTx :: Tx ConwayEra |
There was a problem hiding this comment.
This is the old api's Tx type.
| txBodyContent = Exp.defaultTxBodyContent | ||
| & Exp.setTxIns [(mkTxIn "dbaff4e270cfb55612d9e2ac4658a27c79da4a5271c6f90853042d1403733810#0", AnyKeyWitnessPlaceholder)] | ||
| & Exp.setTxMetadata expMetadata | ||
| dummyTx :: Tx era |
| scriptRedeemer | ||
| executionUnits | ||
| in return (ScriptWitness ScriptWitnessForSpending scriptWitness, script, getScriptData scriptData, scriptFee) | ||
| ScriptInAnyLang _ PlutusScript{} -> |
There was a problem hiding this comment.
Old api's ScriptInAnyLang type here.
| 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 |
There was a problem hiding this comment.
Old api's Tx type used here.
| mkTxOut v = case forEraMaybeEon (cardanoEra @era) of | ||
| Nothing -> error "mkUtxOScript: scriptDataSupportedInEra==Nothing" | ||
| Just tag -> TxOut | ||
| plutusScriptAddr |
There was a problem hiding this comment.
Old api's TxOut type used here.
| where | ||
| eTx = mkGenesisTransaction (castKey inputKey) ttl fee [pseudoTxIn] [txout] | ||
| era = useEra @era | ||
| txout = TxOut addr value TxOutDatumNone ReferenceScriptNone |
There was a problem hiding this comment.
Old TxOut type used here.
| } | ||
| mkUTxOVariant networkId key value = obtainCommonConstraints (useEra @era) $ | ||
| let | ||
| mkTxOut v = TxOut (keyAddress @era networkId key) (lovelaceToTxOutValue (shelleyBasedEra @era) v) TxOutDatumNone ReferenceScriptNone |
There was a problem hiding this comment.
Old TxOut type used here.
Summary
Migrate tx-generator to use the experimental cardano-api for transaction building and era dispatch.
IsEraconstraint andCardano.Api.Experimentaltransaction building across the tx construction and submission pipelinemakeUnsignedTxsupport in cardano-apiChecklist
CHANGELOG.mdfor affected package.cabalfiles are updated