Skip to content

chore: drop @meshsdk/core-csl and implement TxParser on core-cst - #868

Merged
lisicky merged 5 commits into
mainfrom
chore/drop-core-csl
Nov 28, 2026
Merged

lisicky merged 5 commits into
mainfrom
chore/drop-core-csl

Conversation

@lisicky

@lisicky lisicky commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

@meshsdk/core-cst becomes the only serializer backend: @meshsdk/core-csl (CSLSerializer, the whisky OfflineEvaluator and the whisky-based TxParser) is removed from the monorepo. The one thing core-csl still did that cst could not, parsing a transaction back into a MeshTxBuilderBody for TxParser / TxTester, is implemented on the cardano-sdk Serialization layer as CardanoSDKTxParser, so CardanoSDKSerializer.parser works instead of throwing. Reviewing that work turned up two serializer bugs, which are fixed here as well.

Five commits, meant to be read in order:

  1. 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 and the deposit that certificates 7 and 8 state, 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 account Ord, votes by voter), whatever order the transaction encodes them in. The TxParser / TxTester tests run on cst.
  2. chore: drop @meshsdk/core-csl — the package, its lockfile entries (whisky), the publish job, bump-version.sh, docs; tests migrated to CardanoSDKSerializer / OfflineEvaluatorScalus, duplicated CSL-vs-CST cases dropped. The serializer option of MeshTxBuilder names CardanoSDKSerializer only. @meshsdk/core never depended on core-csl; only a doc comment changes there.
  3. fix: index voting redeemers by voter in ledger order
  4. fix(core-cst): keep native reference scripts on outputs
  5. test(core-cst): cover an invalid scriptRef on a resolved reference input

The two 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). serializeTxBody pushed one redeemer per ScriptVote, indexed by the vote's position in the body, so a script DRep voting on two governance actions produced redeemers 0 and 1 and 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). MeshTxBuilder, which builds on TxBuilder and already declares one redeemer per voter, kept the redeemer of a voter's first vote and dropped the others; it now refuses votes of one voter that give different redeemers (WITNESS_MISMATCH). The voter ordering helpers live in core-cst/src/utils/vote.ts and are used by the parser too.

toCardanoOutput dropped native reference scripts. serializeTxBody builds every output through it, and it only handled V1 / V2 / V3; serializeOutput already treated any other version marker as a native script. The core path now does the same.

Affect components

  • @meshsdk/common — a doc comment, the TxTester tests
  • @meshsdk/contract
  • @meshsdk/core — doc comment only
  • @meshsdk/core-cst — parser and serializer changes
  • @meshsdk/hydra
  • @meshsdk/provider
  • @meshsdk/react
  • @meshsdk/svelte
  • @meshsdk/transaction — MeshTxBuilder: the serializer option, the votes of one voter
  • @meshsdk/wallet
  • Mesh playground (i.e. https://meshjs.dev/)
  • Mesh CLI

Type of Change

  • New feature (non-breaking change which adds functionality) — CardanoSDKTxParser
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) — @meshsdk/core-csl is no longer part of the monorepo and is not published from it any more; validateTx goes without a replacement. Consumers import CardanoSDKSerializer, OfflineEvaluatorScalus and CardanoSDKTxParser from @meshsdk/core-cst.
  • Bug fix (non-breaking change which fixes an issue) — the two fixes above
  • Code refactoring (improving code quality without changing its behavior)
  • Documentation update (adding or updating documentation related to the project) — README package table and diagram, core and transaction READMEs, PR template, copilot instructions, tx-prototype design note

Behaviour changes to be aware of

  • serializeTxBody of a body with a script voter casting several votes declares one voting redeemer (it used to declare one per vote, which the ledger rejects). Two ScriptVotes of one voter with different redeemer data or budgets are rejected at serialization.
  • MeshTxBuilder refuses votes of one voter that give different redeemers (WITNESS_MISMATCH): different data, or different budgets when it keeps the declared ones (evaluator: null); it used to build with the first one's.
  • Native reference scripts on outputs reach the transaction when it is built through serializeTxBody (they were silently dropped).
  • OfflineEvaluatorScalus is the only offline evaluator.

Parser limitations

Documented on parseTxBuilderBody:

  • fee of 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).
  • A legacy stake registration or deregistration (certificate 0 or 1) comes back without coin; built again, it becomes certificate 7 or 8 with the protocol keyDeposit.
  • A cost model of a Plutus language Mesh has no version for (PlutusV4) is left out of a parsed protocol parameter update.
  • An output datum hash whose datum is not in the witness set comes back as { type: "Hash", data: { type: "CBOR", content: <hash> } }, since Output.datum has no hash-only form.
  • Output.referenceScript is typed PlutusScript; a native reference script comes back as { code, version: "Native" } behind a cast, which is what the serializer expects.
  • Not changed here: reward redeemer indexes in serializeTxBody still follow the order of the body's withdrawals.

Related Issues

None.

Checklist

  • My code is appropriately commented and includes relevant documentation, if necessary
  • I have added tests to cover my changes, if necessary — test/parser/tx-parser.test.ts (43 cases: every parsed part, ledger-order redeemer matching, round trips), vote-redeemers.test.ts in both core-cst and mesh-transaction, the native reference script case in ref-script-output.test.ts
  • I have updated the documentation, if necessary
  • All new and existing tests pass (i.e. npm run test)
  • The build is pass (i.e. npm run build:mesh)

Verification

Run locally after npm run build:mesh:

package tests
mesh-core-cst 258 passed, plus 21 under the Scalus (ESM) config
mesh-transaction 5232 passed
mesh-common 277 passed
mesh-tx-emulator, mesh-x402, mesh-wallet, mesh-scalus-emulator, mesh-contract, mesh-core 204, 98, 73, 24, 2, 1 passed

Root npm test (turbo): 9 of 9 tasks successful. npm run lint, build:docs, build:apps, build:scripts, the test:package checks of core-cst and scalus-emulator and test:scalus-packages pass too.

The tests added with the fixes fail on the code before them (4 in core-cst, 1 in mesh-transaction); each commit builds on its own.

Additional Information

  • Rebased on main. The deposit of stake certificates 7 and 8, which this PR used to add, came to main with fix!: use deposit-bearing certificates (7/8) for stake (de)registration #871; what is left of it is the parser keeping the deposit those certificates state (first commit).
  • _backup/apps/** still mentions CSLSerializer; it is not built and is left alone.
  • Historical comments in tx-prototype-to-cbor/* that cite whisky's Rust sources as the reference for the port are kept.

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 and the deposit stated by
  certificates 7 and 8, votes and proposals of every governance action kind
  incl. protocol parameter updates (a cost model of a language Mesh has no
  version for, PlutusV4, is left out)
- 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)
- MeshTxBuilder: its serializer option names CardanoSDKSerializer only
- tests: migrate to CardanoSDKSerializer / OfflineEvaluatorScalus, drop the
  duplicated CSL-vs-CST builds and the CSL-only cases; 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, transaction 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). serializeTxBody 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
- MeshTxBuilder: refuse votes of one voter that give different
  redeemers (WITNESS_MISMATCH) instead of keeping the first
- 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.
@lisicky
lisicky force-pushed the chore/drop-core-csl branch from d2c9e39 to f82a4c7 Compare November 28, 2026 13:52
@lisicky
lisicky merged commit 99d5c9a into main Nov 28, 2026
1 check passed
@lisicky
lisicky deleted the chore/drop-core-csl branch November 28, 2026 15:12
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.

2 participants