Repository navigation
Conversation
Replace the throwing `parser` stub of CardanoSDKSerializer with CardanoSDKTxParser, built on the cardano-sdk Serialization layer, so that TxParser and TxTester no longer need @meshsdk/core-csl. The parser rebuilds a MeshTxBuilderBody from a transaction and its resolved UTxOs: - inputs (pub key / Plutus / native script; provided or reference scripts; inline, witness-set and hash-only datums; spend redeemers by ledger order), collaterals and reference inputs with script sizes - outputs with hash / inline / embedded datums and Plutus or native reference scripts; change address = last output - mints (Plutus and native, grouped by policy), withdrawals (reward account order), certificates incl. pool registration, votes and proposals of every governance action kind incl. protocol parameter updates - metadata (nested maps, integer keys, byte strings, big integers), script metadata, validity range, required signers, total collateral, collateral return address and donation - getRequiredInputs lists inputs, collateral and reference inputs Switch the TxParser and TxTester tests to CardanoSDKSerializer.
Remove the core-csl package (CSLSerializer, the whisky OfflineEvaluator and the whisky-based TxParser) now that core-cst covers everything it provided: CardanoSDKSerializer is the only IMeshTxSerializer, OfflineEvaluatorScalus the only offline evaluator and CardanoSDKTxParser backs TxParser/TxTester. - delete packages/mesh-core-csl and its lockfile entries (@sidan-lab/whisky-js-browser, @sidan-lab/whisky-js-nodejs, whisky-evaluator); the lockfile also picks up the stale packages/mesh-x402 version (1.9.1 -> 0.0.1) - tests: migrate to CardanoSDKSerializer / OfflineEvaluatorScalus, drop the duplicated CSL-vs-CST builds and the CSL-only cases, assert the Scalus error message in script-tx-fail; the serializeData helper and the serializer-utils test use core-cst (fromBuilderToPlutusData, normalizePlutusScript) - CI: remove the publish-meshsdk-core-csl job and the bump-version entry - docs: README package table and diagram, core README, PR template, copilot instructions, tx-prototype design note, code comments validateTx (unused) is removed without a replacement.
The ledger runs a voter's script once for all of its votes and indexes the voting redeemer by the position of the voter in the ordering of the voting procedures (committee members, then DReps, then pools; script credentials before key hashes). The serializer declared one redeemer per vote, indexed by the vote's position, so a script DRep voting on two actions produced redeemers 0 and 1 and an invalid transaction. - serializer: collect one redeemer per voter, reject conflicting redeemers for the same voter, index by the sorted voters of the body - builder: evaluate and update budgets per voter (`votesByVoter`), fee estimation prices one redeemer per voter, `sortVotes` shares the comparator - parser: reuse the voter ordering helpers now in `utils/vote.ts`
`toCardanoOutput`, which `serializeTxBody` uses for every output, only handled Plutus reference scripts and silently dropped a native one; `serializeOutput` already treated any other version marker as a native script. Do the same in the core path.
`reg_cert` / `unreg_cert` (Conway certificates 7 and 8) state their deposit. Parsing them folded the deposit away and rebuilding produced the legacy certificates 0 and 1, so a transaction did not round trip. - `RegisterStake` / `DeregisterStake` take an optional `coin`; with it `toCardanoCert` emits the Conway forms, without it the legacy ones - `registerStakeCertificate` / `deregisterStakeCertificate` accept the deposit, and balancing uses it instead of the protocol `keyDeposit` - the parser keeps the deposit; the tx prototype conversion passes the coin on instead of building the certificates itself
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@meshsdk/core-cstbecomes the only serializer backend:@meshsdk/core-csl(CSLSerializer, the whiskyOfflineEvaluatorand the whisky-basedTxParser) is removed from the monorepo. The one thing core-csl still did that cst could not, parsing a transaction back into aMeshTxBuilderBodyforTxParser/TxTester, is implemented on the cardano-sdk Serialization layer asCardanoSDKTxParser, soCardanoSDKSerializer.parserworks instead of throwing. Reviewing that work turned up three serializer/builder bugs, which are fixed here as well.Six commits, meant to be read in order:
feat(core-cst): implement ITxParser for CardanoSDKSerializer—packages/mesh-core-cst/src/parser/. Inputs (key / Plutus / native, provided or reference scripts; inline, witness-set and hash-only datums), collaterals, reference inputs with script sizes, outputs with datums and reference scripts, mints grouped by policy, withdrawals, certificates incl. pool registration, votes and proposals of every governance action kind (incl. protocol parameter updates), metadata, validity range, required signers, total collateral, collateral return and donation. Redeemers are matched to their targets in ledger order (inputs by(txid, index), mints by policy id, withdrawals by reward accountOrd, votes by voter), whatever order the transaction encodes them in. TheTxParser/TxTestertests run on cst.chore: drop @meshsdk/core-csl— the package, its lockfile entries (whisky), the publish job,bump-version.sh, docs; tests migrated toCardanoSDKSerializer/OfflineEvaluatorScalus, duplicated CSL-vs-CST cases dropped.@meshsdk/corenever depended on core-csl; only a doc comment changes there.fix: index voting redeemers by voter in ledger orderfix(core-cst): keep native reference scripts on outputsfeat: keep the deposit of Conway stake registration certificatestest(core-cst): cover an invalid scriptRef on a resolved reference inputThe three fixes
Voting redeemers were indexed per vote. The ledger runs a voter's script once for all of its votes and indexes the redeemer by the voter's position among the voting procedures (committee members, then DReps, then pools; script credentials before key hashes). The serializer pushed one redeemer per
ScriptVote, indexed by the vote's position in the body, so a script DRep voting on two governance actions produced redeemers0and1and an invalid transaction. The serializer now keeps one redeemer per voter, indexes it by the sorted voters of the body and rejects different redeemers for one voter (The same voter must have the same redeemer). The builder evaluates and updates budgets per voter (votesByVoter),getRedeemerCostsprices one redeemer per voter andsortVotesshares the comparator. The voter ordering helpers live incore-cst/src/utils/vote.tsand are used by the parser too.toCardanoOutputdropped native reference scripts.serializeTxBodybuilds every output through it, and it only handledV1/V2/V3;serializeOutputalready treated any other version marker as a native script. The core path now does the same.Conway
reg_cert/unreg_certlost their deposit. They were parsed intoRegisterStake/DeregisterStake, which had no field for it, and rebuilt as the legacy certificates 0 and 1.RegisterStake/DeregisterStaketake an optionalcoin: with ittoCardanoCertemits the Conway forms, without it the legacy ones as before.registerStakeCertificate(rewardAddress, coin?)/deregisterStakeCertificate(rewardAddress, coin?)accept it, balancing usescoin ?? keyDeposit, the parser keeps it, and the tx-prototype conversion passes the coin on instead of building those certificates itself.Affect components
@meshsdk/common—coin?: numberonRegisterStake/DeregisterStake@meshsdk/contract@meshsdk/core— doc comment only@meshsdk/core-cst— parser, serializer and certificate changes@meshsdk/hydra@meshsdk/provider@meshsdk/react@meshsdk/svelte@meshsdk/transaction— votes per voter, stake certificate deposit@meshsdk/walletType of Change
CardanoSDKTxParser; the deposit on stake certificates@meshsdk/core-cslis no longer part of the monorepo and is not published from it any more;validateTxgoes without a replacement. Consumers importCardanoSDKSerializer,OfflineEvaluatorScalusandCardanoSDKTxParserfrom@meshsdk/core-cst.Behaviour changes to be aware of
VOTEresult at indexiis applied to every vote of thei-th voter. TwoScriptVotes of one voter with different redeemer data or budgets are rejected at serialization.serializeTxBody(they were silently dropped).registerStakeCertificate/deregisterStakeCertificatebehave as before when called with one argument; only a stated deposit changes the certificate form and the balance. Parsed Conway stake certificates now round-trip.OfflineEvaluatorScalusis the only offline evaluator; the tests that asserted whisky's error text assert Scalus's.Parser limitations
Documented on
CardanoSDKTxParser:feeof the parsed body is left at the body default"0".MeshTxBuilder.complete()takes any non-empty fee as fixed, so drop or override it before rebuilding (the round-trip tests do).{ type: "Hash", data: { type: "CBOR", content: <hash> } }, sinceOutput.datumhas no hash-only form.Output.referenceScriptis typedPlutusScript; a native reference script comes back as{ code, version: "Native" }behind a cast, which is what the serializer expects.MeshTxBuilder.sortWithdrawals.Related Issues
None.
Checklist
test/parser/tx-parser.test.ts(42 cases: every parsed part, ledger-order redeemer matching, round trips),vote-redeemers.test.tsandstake-certificates.test.tsin both core-cst and mesh-transaction, the native reference script case inref-script-output.test.tsnpm run test)npm run build:mesh)Verification
Run locally after
npm run build:mesh:Root
npm test(turbo): 8 of 8 tasks successful.The tests added with the fixes fail on the code before them (7 in core-cst, 4 in mesh-transaction); each intermediate commit type-checks on its own.
Additional Information
packages/mesh-x402version (1.9.1 → 0.0.1)._backup/apps/**still mentionsCSLSerializer; it is not built and is left alone.tx-prototype-to-cbor/*that cite whisky's Rust sources as the reference for the port are kept.