Repository navigation
Conversation
lisicky
force-pushed
the
feat/tx-emulator
branch
from
October 12, 2026 18:26
420e387 to
65a6f93
Compare
lisicky
force-pushed
the
feat/tx-emulator
branch
from
October 22, 2026 15:46
65a6f93 to
0c66ffb
Compare
lisicky
force-pushed
the
feat/tx-emulator
branch
from
October 29, 2026 01:06
0c66ffb to
062509c
Compare
lisicky
changed the base branch from
main
to
feat/governance-fetcher-interfaces
October 29, 2026 01:06
Merged
… as the ledger keeps them - The scalus validator's ledger is rebuilt only when a transaction needs it: stake address registrations and delegations are applied in step, and a stake address withdrawn from is rebuilt before a transaction that reads it. - At an epoch boundary, committee members proposed but not sitting lose their hot credentials and resignations, as the ledger keeps those only for the sitting committee. - A governance action read from a provider that reports none of its epochs is taken as open to votes and reported as not checked.
EmulatorOptions.poolRegistrations is a union of { params } and { poolId } in Scalus 1.5.0, and the explicit PoolRegistration return type hid which of the two is given. This belongs in the tx-emulator commit of #858; it is kept apart here until that commit is updated.
…Scalus 1.5.0 Scalus 1.5.0 takes a withdrawal before a deregistration in the same transaction, and takes a pool re-registration as an update with no other deposit, as the ledger does. The two tests no longer differ by validator and the README drops both limits. This belongs in the tx-emulator commit of #858; it is kept apart here until that commit is updated.
… validators Scalus 1.5.0 takes the registration of a registered pool as an update with no other deposit, so the fromChain test no longer expects the scalus validator to refuse it. This belongs in the tx-emulator commit of #858; it is kept apart here until that commit is updated.
The emulator builds only with the EmulatorOptions of Scalus 1.5.0, and the other packages already require ^1.5.0, so its own range of ^1.3.0 let an install resolve a version it does not work with. This belongs in the tx-emulator commit of #858; it is kept apart here until that commit is updated.
…elegated to Scalus 1.5.0 refuses a delegation to a pool or a DRep that is not registered, as the ledger does. The test of it now runs under both validators, and the README no longer lists it as a limit of the scalus validator. This belongs in the tx-emulator commit of #858; it is kept apart here until that commit is updated.
…udge Scalus 1.5.0 checks the governance rules, and the DRep delegation of a key-hash stake address withdrawn to, against a governance state of its own. That state cannot be given the governance actions, the last enacted ones, the committee members only proposed or the vote delegations the emulator holds, so with the scalus validator Scalus refused transactions that depend on state set without a transaction or read from a chain. The emulator now lists every rule a refused transaction breaks (ledgerFailures) and does not take a refusal by those rules alone: it checks the scripts itself, which Scalus does not run once a rule is broken, holding each to the units its redeemer declares, and applies the transaction's inputs and outputs to Scalus's ledger. A transaction that breaks another rule too is refused by that rule, also when Scalus reports only one not taken. What Scalus checks of governance without that state, such as a proposal's deposit and return account, stays checked. This belongs in the tx-emulator commit of #858; it is kept apart here until that commit is updated.
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.
Merge #864 first: this PR builds on its
IGovernanceFetcherandIStakePoolFetcherinterfaces.What
Adds
@meshsdk/tx-emulator, a local Cardano ledger for trying transactions out, alone or in chains.simulate(tx)reports what a transaction would do without changing anything.submit(tx)applies it, and every later transaction is checked against the result.@meshsdk/scalus-emulator. Transactions are validated by the validator the caller picks:"scalus"(built in) or"cquisitor"(@cardananium/cquisitor-lib, an optional peer dependency).IFetcher,IGovernanceFetcher,IStakePoolFetcher,ISubmitterandIEvaluator, so transactions are built and submitted against it with the usual Mesh tools.TxEmulator.fromChain(tx, …)builds a ledger holding the chain state a transaction reads, from providers, to check the transaction against the chain as it is now.Contents
packages/mesh-tx-emulator(new):TxEmulator.create(options)sets the starting state:validator(required) and the network (mainnet by default);simulate(tx, options?)/submit(tx, options?)take CBOR hex or aTransactionPrototypeand return:txHash,fee,isValid,redeemers(execution units each script used),consumedandproducedUTxOs (the collateral and its return for a transaction marked phase-2 invalid), script logs and warnings;errors, each with its ledgerruleandmessage; with cquisitor every problem, with ahint,locationsand thephase.{ requireSignatures: false }checks a transaction before anyone signs it: missing key witnesses are not reported, native scripts pass when they would once signed, and the fee and the size limit are checked as they will be once it is signed.submitTxsubmits like any Mesh submitter and throws aTxRejectedErrorcarrying the result.fetchAccountInfo,fetchPoolState,fetchDRepState,fetchGovernanceProposal,fetchCommitteeState, …) andutxos(filter).addUtxos/removeUtxos,setAccount/removeAccount,setPool/removePool,setDRep/removeDRep,setGovernanceAction/removeGovernanceAction,setLastEnacted,setCommitteeMember/removeCommitteeMember,setTreasury,setConstitution,setProtocolParameters. Asetmerges into an existing item (nullclears a field) and pays or refunds no deposit.fork(): an independent copy of the whole ledger, so one setup can branch into several scenarios.advanceTo({ slot } | { time } | { epoch }), forward only. Entering an epoch retires the pools due to retire (their deposits go back to their reward accounts), adds the previous epoch's donations to the treasury, and removes the governance actions past their lifetime, returning their deposits. No rewards are paid, and no governance actions are ratified or enacted.TxEmulator.fromChain(tx, { validator, fetcher, governance?, pools?, network? })reads the outputs the transaction spends and references, the protocol parameters and cost models, and the stake addresses, pools, DReps, governance actions and committee it touches, plus the treasury and the constitution. State no provider reports, or reports in a form that cannot be read, is taken to be as each transaction needs it and listed as aNotCheckedwarning, never as an error.fromChain, time and limits.packages/mesh-scalus-emulator: exports the existingtoMeshUtxo/fromMeshUtxoconverters, so the new package seeds the ledger with them instead of duplicating them. No behaviour change.Repo wiring:
build.ymlruns the new package's tests next to the scalus-emulator ones.publish.ymlgets a publish job for it.bump-version.shnow covers the package, and the@meshsdk/scalus-emulatordependency pin, which it did not rewrite before.@cardananium/cquisitor-lib; npm hoistsscalusto the root instead of keeping two nested copies.Validation
@meshsdk/tx-emulator: 122 tests.fromChainsuite run on both validators: chains of transactions, dry runs, forks, time and epoch boundaries, direct state changes, the provider interfaces, and checks against a chain read through plain and governance-capable fetchers.