Repository navigation
feat(core-cst): evaluate with a reusable Scalus TxEvaluator - #860
Merged
Merged
Conversation
Switch OfflineEvaluatorScalus from a per-call evalPlutusScripts to one Scalus TxEvaluator with its own ScriptCache. The evaluator is built on first use and rebuilt only when slotConfig or costModels change; the script cache survives rebuilds. UTxOs are passed as the [input, output] pairs TransactionUnspentOutput already encodes, so the hand-built CBOR map goes. A runtime that cannot import() Scalus (Jest without --experimental-vm-modules) gets an error that says so. MeshTxBuilder evaluates on every coin-selection round, so reuse pays off: on recorded Midgard requests, TxEvaluator with a ScriptCache takes 0.98x the time of Aiken WASM, and the cache alone saves about 17-25%.
nau
force-pushed
the
pr-a/scalus-1.4-tx-evaluator
branch
from
October 30, 2026 10:45
f5f2aff to
6ebe5c2
Compare
Contributor
Author
|
Rebased on current |
lisicky
added a commit
that referenced
this pull request
Nov 1, 2026
Resolves the conflicts with #860 (reusable Scalus TxEvaluator, which this branch carried as a copy) and with the Scalus 1.4.1 test fixes on main: - offline-evaluator-scalus.ts and its test keep this branch's version, which already holds #860's content plus the default-evaluator work (#862, #866). - offline-evaluator-scalus-cases.test.ts keeps its Scalus expectations. Main's edits were to the CSL evaluator test it was copied from, so that test (mesh-core-csl/test/offline-providers/evaluator.test.ts) is restored from main rather than staying deleted. - script-tx-fail / script-tx-fetcher tests import MeshTxBuilder from @meshsdk/transaction, as on main.
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
OfflineEvaluatorScalusnow uses one ScalusTxEvaluatorwith its ownScriptCache(64 entries, kept across rebuilds) instead of callingevalPlutusScriptson everyevaluateTx.slotConfigorcostModelschange (compared by value, so in-place edits count too). The script cache survives rebuilds.[input, output]CBOR pairs thatTransactionUnspentOutput.toCbor()already gives, so the hand-built CBOR map is gone.import(), so the CJS build keeps working. Where a runtime cannotimport()an ES module (Jest without--experimental-vm-modules), the error now says so, and a later call tries again.TypeError. Before,Buffer.from(..., "hex")silently dropped the last digit. Hex with invalid characters still fails earlier, in cardano-sdk, as before.Why
MeshTxBuildercalls the evaluator on every coin-selection round. With a reusable evaluator each script is hashed and decoded once. On 55,001 requests recorded from Midgard's test suites,TxEvaluatorwith aScriptCachetakes 0.98x the time of Aiken WASM (Lucid's evaluator), with identical execution units, and the cache alone saves about 17–25%.Tests
offline-evaluator-scalus.test.ts: the pinned budget is unchanged (this also checks the UTxO pair encoding, including a reference-script UTxO). New tests check that two calls build oneTxEvaluatorand leave one script in the cache, that doubled V2 cost models double the budget and restoring them restores it, and that a movedslotConfig.zeroTimetakes effect – all while oneScriptCacheis kept.main(Scalus 1.4.1):mesh-core-cst180 + 3 Scalus tests,test:package(ESM and CJS) 2/2,mesh-scalus-emulator24,mesh-transaction249/249 (35 suites) pass.