Skip to content

Conversation

@williamdemeo
Copy link
Member

@williamdemeo williamdemeo commented Dec 22, 2025

Description

Stacked PR. The branch for this PR should be rebased on master once PR #1012 is merged.

This PR closes issue #1005 by adopting the following interpretation and approach in the Dijkstra spec, resolving the apparent ambiguity in the CIP and matches the "preceding Tx outputs" intent:

  1. Spending inputs (i.e., the ones that are actually consumed) must be present in the initial UTxO snapshot for the batch (the "mempool safety" constraint).

  2. Reference inputs are allowed to refer to:

    • entries in the initial UTxO, or
    • outputs produced by earlier subTxs in the batch order (the "preceding transactions" carve-out).
  3. Reference lookup uses an evolving (tentative) UTxO view, computed by applying prior subtransaction effects for lookup only (still no commitment to change state until the batch succeeds).

This makes the two CIP statements mentioned in Issue #1005 simultaneously true by reading "inputs" as "spending inputs," while still enabling the specific "ref scripts from preceding outputs" behavior the CIP explicitly mentions.

Moreover, we change type signatures where necessary to allow for the two UTxO views:

  • utxoSpend₀, the initial (static) UTxO;
  • utxoRefView, the evolving UTxO.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • Any semantic changes to the specifications are documented in CHANGELOG.md
  • Code is formatted according to CONTRIBUTING.md
  • Self-reviewed the diff

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR resolves the ambiguity in the Dijkstra specification (issue #1005) regarding the visibility of reference inputs in batch transactions. It establishes a clear distinction between spending inputs (which must exist in the initial UTxO snapshot) and reference inputs (which may additionally point to outputs from preceding sub-transactions in the batch).

Key changes:

  • Introduce two UTxO views: utxoSpend₀ (initial snapshot) and utxoRefView (evolving view for reference lookups)
  • Update transaction body structure to replace txRequiredGuards with txGuards and add reqSignerHashes field
  • Extend TxInfo with txInfoSubTxs field and introduce purpose-specific txInfoForPurpose function
  • Add minimal UTXO and UTXOW skeleton transition systems for Dijkstra phase-1 checks

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/Ledger/Dijkstra/Specification/Utxow.lagda.md New skeleton wrapper around UTXO transition for witnessing layer
src/Ledger/Dijkstra/Specification/Utxo.lagda.md New skeleton UTXO transition with phase-1 guard satisfaction check
src/Ledger/Dijkstra/Specification/Transaction.lagda.md Major updates: dual UTxO views, renamed guard fields, updated function signatures, comprehensive validity documentation
src/Ledger/Dijkstra/Specification/Script/Validation.lagda.md Updated ScriptPurpose, TxInfo structure with guards/subTxs, dual UTxO parameters for script lookups
src/Ledger/Dijkstra/Specification/Abstract.lagda.md Updated indexOfGuard signature to use Credential and List Credential
src/Ledger/Dijkstra/Specification.lagda.md Added module imports for new Utxo and Utxow specifications
src/Ledger/Conway/Specification/Utxow.lagda.md Fixed source_path metadata from .lagda to .lagda.md
src/Ledger/Conway/Specification/Utxo.lagda.md Added missing metadata header
CHANGELOG.md Documented all semantic changes to transaction structure and validation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@williamdemeo williamdemeo moved this to In Progress in Dijkstra formal spec Dec 22, 2025
@carlostome carlostome mentioned this pull request Jan 5, 2026
4 tasks
@williamdemeo williamdemeo changed the base branch from master to 1004-dijkstra-implement-txinfo-rules-for-guards January 6, 2026 03:57
@williamdemeo williamdemeo force-pushed the 1004-dijkstra-implement-txinfo-rules-for-guards branch from db4a1bc to 7ccd947 Compare January 7, 2026 00:33
@williamdemeo williamdemeo force-pushed the 1005-dijkstra-cip-0118-ambiguity-visibility-of-reference-inputs branch from d2e681c to 0e6ef2c Compare January 7, 2026 00:41
@williamdemeo williamdemeo force-pushed the 1004-dijkstra-implement-txinfo-rules-for-guards branch from 7ccd947 to 8063211 Compare January 7, 2026 02:19
@williamdemeo williamdemeo force-pushed the 1005-dijkstra-cip-0118-ambiguity-visibility-of-reference-inputs branch from 0e6ef2c to 20498dc Compare January 7, 2026 02:36
@williamdemeo williamdemeo force-pushed the 1004-dijkstra-implement-txinfo-rules-for-guards branch from 8063211 to 72b806c Compare January 7, 2026 13:44
@williamdemeo williamdemeo force-pushed the 1005-dijkstra-cip-0118-ambiguity-visibility-of-reference-inputs branch from 20498dc to 0eb3c68 Compare January 7, 2026 13:46
@williamdemeo williamdemeo force-pushed the 1004-dijkstra-implement-txinfo-rules-for-guards branch from 72b806c to c0dc0cf Compare January 7, 2026 14:04
@williamdemeo williamdemeo force-pushed the 1005-dijkstra-cip-0118-ambiguity-visibility-of-reference-inputs branch from 0eb3c68 to 58fc737 Compare January 7, 2026 14:04
@williamdemeo williamdemeo force-pushed the 1004-dijkstra-implement-txinfo-rules-for-guards branch from c0dc0cf to 46039b7 Compare January 7, 2026 14:18
@williamdemeo williamdemeo force-pushed the 1005-dijkstra-cip-0118-ambiguity-visibility-of-reference-inputs branch from 58fc737 to d9fd7b5 Compare January 7, 2026 14:18
@williamdemeo williamdemeo marked this pull request as ready for review January 8, 2026 06:25
@williamdemeo williamdemeo force-pushed the 1004-dijkstra-implement-txinfo-rules-for-guards branch from 36b6346 to 56f60be Compare January 9, 2026 02:30
@williamdemeo williamdemeo force-pushed the 1005-dijkstra-cip-0118-ambiguity-visibility-of-reference-inputs branch from d9fd7b5 to f2f9003 Compare January 9, 2026 02:52
@williamdemeo williamdemeo force-pushed the 1005-dijkstra-cip-0118-ambiguity-visibility-of-reference-inputs branch 2 times, most recently from 26c20b0 to c070f60 Compare January 9, 2026 14:57
@williamdemeo williamdemeo force-pushed the 1005-dijkstra-cip-0118-ambiguity-visibility-of-reference-inputs branch from c070f60 to ce58826 Compare January 9, 2026 15:00
@williamdemeo williamdemeo force-pushed the 1004-dijkstra-implement-txinfo-rules-for-guards branch from 38786dc to 3990eed Compare January 9, 2026 15:04
@williamdemeo williamdemeo force-pushed the 1005-dijkstra-cip-0118-ambiguity-visibility-of-reference-inputs branch from ce58826 to 8418eed Compare January 9, 2026 15:05
Copy link
Collaborator

@carlostome carlostome left a comment

Choose a reason for hiding this comment

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

LGTM!

Base automatically changed from 1004-dijkstra-implement-txinfo-rules-for-guards to master January 12, 2026 16:09
williamdemeo and others added 8 commits January 12, 2026 09:23
+  Remove contradiction between "ref inputs may refer to earlier tx outputs in the batch" vs "all inputs must exist before applying any tx in the batch." The new text punts the exact constraint to the UTxO rules (where it belongs).
+  Fix Plutus bullet (old "nor earlier versions" reads like "no Plutus at all").
+  Align fees with current Agda (`txFee : InTopLevel …`), but leave room for later CIP-driven updates.
Also highlight that `getDatum` gets the datum of the spent output (look
up `txin` in the UTxO; if the output stores a datum hash, look it up in
`DataOf tx`). It's a spending-input datum lookup (not a reference-input
datum lookup).
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@williamdemeo williamdemeo force-pushed the 1005-dijkstra-cip-0118-ambiguity-visibility-of-reference-inputs branch from a636905 to 9b4798b Compare January 12, 2026 16:25
@williamdemeo williamdemeo merged commit 42eeaeb into master Jan 12, 2026
12 checks passed
@williamdemeo williamdemeo deleted the 1005-dijkstra-cip-0118-ambiguity-visibility-of-reference-inputs branch January 12, 2026 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Dijkstra] CIP-0118 ambiguity: visibility of reference inputs/scripts inside a batch of subTxs

3 participants