Skip to content

Expose Plutus and native guard witnesses in experimental transactions - #1381

Merged
Jimbo4350 merged 3 commits into
masterfrom
feature/dijkstra-guard-witnesses
Oct 21, 2026
Merged

Jimbo4350 merged 3 commits into
masterfrom
feature/dijkstra-guard-witnesses

Conversation

@Jimbo4350

@Jimbo4350 Jimbo4350 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Context

Allow native and Plutus V4 scripts to witness guards in experimental Dijkstra transactions and sub-transactions. Guard credentials and optional witnesses live together in an opaque, insertion-ordered TxGuards collection, supplied through setTxGuards.

mkTxGuards preserves the caller's order and rejects duplicate credentials, script witnesses for key credentials, and mismatching inline script hashes. GuardWitness accepts native scripts or Plutus V4 guarding witnesses, enforcing the Plutus language and purpose in its type. Entries without supplied witnesses remain explicit; reference-script hashes still require the referenced UTxO for validation.

Guard witnesses participate in script collection, script integrity hashes, execution-unit evaluation and substitution, and fee estimation. Redeemer indices preserve positions occupied by key, native, and witnessless guards. Legacy extra required signers are appended without duplicating explicit guards. RPC evaluation handles ScriptWitnessIndexGuarding using the existing unspecified redeemer-purpose value.

The PR contains two commits: first the guard type, smart constructor, and constructor tests; then transaction integration, indexing, fees, RPC handling, and integration tests. The implementation uses TxGuards directly, without an intermediate separate witness-map API. The public API changes are recorded as breaking changes in the Herald fragment.

How to trust this PR

  • cabal build all --offline -j4 passed with GHC 9.12.4, including cardano-rpc and the native builds of the WASM package components.
  • cabal test cardano-api-test --offline -j4 --test-options='--pattern=Experimental +RTS -N4 -RTS' passed all 71 tests.
  • Tests cover constructor validation, ledger redeemer lookup, order preservation through budget substitution, extra signer deduplication, sub-transaction witnesses, native signing-key estimates, and automatic balancing with inline and reference Plutus V4 guards.
  • Fourmolu, HLint, and git diff --check passed for the changed files.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated
  • Self-reviewed the diff
  • Changelog fragment added in .changes/

@Jimbo4350
Jimbo4350 force-pushed the feature/dijkstra-guard-witnesses branch 4 times, most recently from 349d099 to b4c9cf6 Compare October 19, 2026 20:20
@Jimbo4350
Jimbo4350 force-pushed the feature/dijkstra-guard-witnesses branch from b4c9cf6 to d485ea1 Compare October 19, 2026 20:26
@Jimbo4350
Jimbo4350 marked this pull request as ready for review October 19, 2026 20:29
Copilot AI balanced review requested due to automatic review settings October 19, 2026 20:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The breaking-change fragment needs explicit downstream migration guidance for the changed guard APIs and new constructors.

1 open issue
What changed in this PR

Adds native and Plutus V4 guard witnesses to experimental Dijkstra transactions and sub-transactions.

Changes:

  • Introduces validated, insertion-ordered TxGuards and public construction helpers.
  • Integrates guards with witness collection, redeemer indexing, execution budgets, and fees.
  • Adds integration tests, RPC handling, and changelog fragments.
File Description
cardano-rpc/​test/​cardano-rpc-test/​Test/​Cardano/​Rpc/​Eval.hs Tests guarding-purpose mapping.
cardano-rpc/​src/​Cardano/​Rpc/​Server/​Internal/​UtxoRpc/​Type/​TxEval.hs Handles guarding indices.
cardano-api/​test/​cardano-api-test/​Test/​Cardano/​Api/​Experimental/​Fee.hs Tests validation, ordering, budgets, and balancing.
cardano-api/​test/​cardano-api-test/​Test/​Cardano/​Api/​Experimental.hs Adapts sub-transaction tests.
cardano-api/​src/​Cardano/​Api/​Tx/​Internal/​Body.hs Adds guarding indices and conversions.
cardano-api/​src/​Cardano/​Api/​Experimental/​Tx/​Internal/​SubTransaction.hs Uses shared guard credential extraction.
cardano-api/​src/​Cardano/​Api/​Experimental/​Tx/​Internal/​Guards.hs Defines validated guard collections.
cardano-api/​src/​Cardano/​Api/​Experimental/​Tx/​Internal/​Fee.hs Integrates guard budgets and witness estimates.
cardano-api/​src/​Cardano/​Api/​Experimental/​Tx/​Internal/​BodyContent.hs Integrates guards into transaction bodies.
cardano-api/​src/​Cardano/​Api/​Experimental/​Tx/​Internal/​AnyWitness.hs Adds guarding witness equality.
cardano-api/​src/​Cardano/​Api/​Experimental/​Tx.hs Exports guard APIs.
cardano-api/​src/​Cardano/​Api/​Experimental/​Plutus/​Internal/​Shim/​LegacyScripts.hs Supports guarding witness conversion.
cardano-api/​src/​Cardano/​Api/​Experimental/​Plutus/​Internal/​ScriptWitness.hs Adds guarding equality instances.
cardano-api/​src/​Cardano/​Api/​Experimental/​Plutus/​Internal/​IndexedPlutusScriptWitness.hs Adds insertion-ordered guarding indices.
cardano-api/​src/​Cardano/​Api/​Experimental/​AnyScriptWitness.hs Extends witness helpers for guards.
cardano-api/​src/​Cardano/​Api/​Experimental.hs Re-exports guard APIs.
cardano-api/​cardano-api.cabal Registers the internal guards module.
.changes/​20261019_cardano-rpc_guarding_script_index.yml Records RPC guarding support.
.changes/​20261016_dijkstra_guard_witnesses.yml Records the breaking guard API change.

Review effort: Balanced

Comment thread .changes/20261016_dijkstra_guard_witnesses.yml Outdated
Comment thread .changes/20261016_dijkstra_guard_witnesses.yml Outdated
Comment thread cardano-api/test/cardano-api-test/Test/Cardano/Api/Experimental/Fee.hs Outdated
Comment thread cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Guard.hs
Comment thread cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Guards.hs Outdated
Comment thread cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Guards.hs Outdated
Comment thread cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Guard.hs
Comment thread cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Guards.hs Outdated
Comment thread cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Fee.hs Outdated
Comment thread cardano-api/test/cardano-api-test/Test/Cardano/Api/Experimental/Fee.hs Outdated
Comment thread cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Guard.hs

@palas palas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me. Here are some things that I thought would improve the readability and the tests

Comment thread cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Guards.hs Outdated
Comment thread cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Guards.hs Outdated
Comment thread cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Guards.hs Outdated
Comment thread cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Guards.hs Outdated
Comment thread cardano-api/test/cardano-api-test/Test/Cardano/Api/Experimental/Fee.hs Outdated
Comment thread cardano-api/test/cardano-api-test/Test/Cardano/Api/Experimental/Fee.hs Outdated
Comment thread cardano-api/test/cardano-api-test/Test/Cardano/Api/Experimental/Fee.hs Outdated
Comment thread cardano-api/test/cardano-api-test/Test/Cardano/Api/Experimental/Fee.hs Outdated
@palas

palas commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

The problem in the CI is patched in my PR: #1379

@Jimbo4350
Jimbo4350 added this pull request to the merge queue Oct 21, 2026
Merged via the queue into master with commit aacace1 Oct 21, 2026
34 checks passed
@Jimbo4350
Jimbo4350 deleted the feature/dijkstra-guard-witnesses branch October 21, 2026 20:09
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.

4 participants