Implement server-side transaction validation via LocalStateQuery#1228
Draft
palas wants to merge 6 commits into
Draft
Implement server-side transaction validation via LocalStateQuery#1228palas wants to merge 6 commits into
palas wants to merge 6 commits into
Conversation
…tion Adds a new local state query that runs applyTx against the current ledger state and returns the raw result. The provisional implementation queries the full EpochState and runs applyTx client-side; this will be replaced by a dedicated node-side consensus query. Exposed from Cardano.Api.Query alongside other queries.
…idation Runs both applyTx (phase 1) and evaluateTransactionExecutionUnits (phase 2) independently in a single LocalStateQueryExpr session, returning both results via TxValidationResult.
Add re-exports for ApplyTxError(..), ConwayLedgerPredFailure(..), ConwayUtxowPredFailure(..), ConwayUtxoPredFailure(..), Mismatch(..), and hashToTextAsHex so downstream consumers (cardano-cli) can pattern-match on ledger predicate failures for human-readable error rendering.
Replace the provisional client-side applyTx implementation with a proper server-side query through the LocalStateQuery protocol. This avoids transferring the full ledger state to the client.
This was referenced May 27, 2026
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.
Context
Implements the
cardano-apiportion of server-side transaction validation via theLocalStateQueryprotocol.Part of IntersectMBO/cardano-cli#1380.
Big picture:
transaction validatecurrently appliesapplyTxclient-side with an empty UTxO set, making it unable to properly validate transactions. This cross-repo change adds a newValidateTxquery to theLocalStateQueryprotocol so the node validates transactions against its real ledger state and UTxO set.transaction validatePR list:NodeToClientV_24forValidateTxquery ouroboros-network#5377ValidateTxquery forLocalStateQueryprotocol ouroboros-consensus#2052transaction validatecommand cardano-cli#1386NodeToClientV_24andtransaction validateintegration tests cardano-node#6582What this PR does
QueryValidateTxtoQueryInShelleyBasedEra, wrapping aTx eraand wiring it to the consensusValidateTxquery viatoConsensusQueryShelleyBasedqueryValidateTx(inCardano.Api.Experimental.Tx.Internal.Validate) to issue the query throughLocalStateQueryExprvalidateTxfunction (inCardano.Api.Experimental.Tx) that combines phase-1 validation (via the node query) with phase-2 script execution unit evaluation, filtering script failures from phase-1 results to avoid double-reportingSignedTxfromCardano.Api.Experimental.Txto its ownInternal.TypemoduleInAnyEraexistential wrapper inCardano.Api.Experimental.EraCardano.Api.Ledger.Internal.Reexport(e.g.ApplyTxError,ConwayLedgerPredFailure,Mismatch,IsValid,CollectError, etc.) for downstream error renderingquerySbefromCardano.Api.Query.Internal.ExprqueryValidateTx,QueryValidateTxError,TxValidationResult, andvalidateTxthrough the publicCardano.Api.QueryandCardano.Api.ExperimentalmodulesHow to trust this PR
Integration tests in
cardano-testnet(in the cardano-node PR) exercise the full round-trip: valid simple txs, valid Plutus txs, fee-too-low, value-not-conserved, missing witnesses, missing script witnesses, no collateral, max-tx-size exceeded, phase-2 failures, and multi-error scenarios.Checklist
.changes/