Skip to content

Conversation

@williamdemeo
Copy link
Member

@williamdemeo williamdemeo commented Dec 21, 2025

Description

Stacked PR. (This PR should be rebased on and target master once PR #1010 is merged.)

This PR closes #1003 by changing the type/signature of ScriptPurpose.Guard and IndexOfGuard, and

  • defining an ordered view guardsList : List Credential via setToList,
  • making indexOfGuard operate on that list,
  • letting rdptr compute the Ix using indexOfGuard.

For the "required top-level guards requested by subTxs" (txRequiredTopLevelGuards requests), we don't need a new ScriptPurpose constructor yet, because


Copilot-generated Description

This pull request updates the representation and handling of "Guard" script purposes in the Dijkstra ledger specification. The main change is a shift from using a tuple of TxId × ScriptHash to using a Credential for identifying guards, which simplifies and clarifies the indexing and referencing of guards throughout the codebase.

Guard ScriptPurpose and Indexing Refactor:

  • Changed the type of the Guard constructor in ScriptPurpose from (TxId × ScriptHash) to Credential, and updated the documentation to clarify that Guard c always indexes into the current transaction's txGuards list-view.
  • Updated the indexOfGuard function in the indexOf record to take a Credential and a List Credential instead of a tuple and a set, aligning it with the new Guard representation.
  • Modified the rdptr function to use the updated indexOfGuard signature and to index into the txGuards list for Guard purposes, ensuring consistency with the new approach.

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 implements changes to make ScriptPurpose.Guard and IndexOfGuard carry a Credential instead of (TxId × ScriptHash), as part of the Dijkstra era specification work on CIP-0112 and CIP-0118.

Key Changes

  • Changed ScriptPurpose.Guard to carry a Credential (which can be either a key hash or script hash) instead of (TxId × ScriptHash)
  • Updated TxBody fields to use txGuards : ℙ Credential instead of txRequiredGuards : ℙ KeyHash, and changed txRequiredTopLevelGuards from a map to a list of (Credential × Maybe Datum) pairs
  • Added helper functions for phase-1 validation including groupRequiredTopLevelGuards, requiredTopLevelGuardsSatisfied, and related types

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Ledger/Dijkstra/Specification/Transaction.lagda.md Core changes to transaction body fields (txGuards, reqSignerHashes, txRequiredTopLevelGuards) and addition of phase-1 validation functions and extensive documentation updates
src/Ledger/Dijkstra/Specification/Script/Validation.lagda.md Updated ScriptPurpose.Guard type, modified rdptr to use setToList on txGuards, and updated TxInfo to include separate vkKey and txGuards fields
src/Ledger/Dijkstra/Specification/Abstract.lagda.md Changed indexOfGuard signature from (TxId × ScriptHash) → ℙ (TxId × ScriptHash) to Credential → List Credential
src/Ledger/Dijkstra/Specification/Utxo.lagda.md New skeleton file defining UTXO and UTXOS transitions with phase-1 checks
src/Ledger/Dijkstra/Specification/Utxow.lagda.md New skeleton file defining UTXOW as wrapper around UTXO
src/Ledger/Dijkstra/Specification.lagda.md Added imports for new Utxo and Utxow modules
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 source metadata header
CHANGELOG.md Documented semantic changes to txRequiredTopLevelGuards, txGuards, and reqSignerHashes

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

@williamdemeo williamdemeo marked this pull request as ready for review December 21, 2025 08:52
@williamdemeo williamdemeo changed the base branch from master to 1002-dijkstra-phase-1-requiredtoplevelguards-stacked January 6, 2026 03:48
@williamdemeo williamdemeo force-pushed the 1002-dijkstra-phase-1-requiredtoplevelguards-stacked branch from 29516cc to 2ba8844 Compare January 6, 2026 05:49
@williamdemeo williamdemeo force-pushed the 1003-dijkstra-change-types-scriptpurposeguard-indexofguard branch 2 times, most recently from 286942e to e65a1ea Compare January 7, 2026 00:27
@williamdemeo williamdemeo force-pushed the 1002-dijkstra-phase-1-requiredtoplevelguards-stacked branch from deeb8ad to df6879c Compare January 7, 2026 01:53
@williamdemeo williamdemeo force-pushed the 1003-dijkstra-change-types-scriptpurposeguard-indexofguard branch from e65a1ea to e727cdf Compare January 7, 2026 02:15
@williamdemeo williamdemeo force-pushed the 1002-dijkstra-phase-1-requiredtoplevelguards-stacked branch from df6879c to 43ce03e Compare January 7, 2026 13:40
@williamdemeo williamdemeo force-pushed the 1003-dijkstra-change-types-scriptpurposeguard-indexofguard branch from e727cdf to 8e4a2c9 Compare January 7, 2026 13:42
@williamdemeo williamdemeo force-pushed the 1002-dijkstra-phase-1-requiredtoplevelguards-stacked branch from 43ce03e to ec362bc Compare January 7, 2026 14:02
@williamdemeo williamdemeo force-pushed the 1003-dijkstra-change-types-scriptpurposeguard-indexofguard branch from 8e4a2c9 to 446d9c8 Compare January 7, 2026 14:03
williamdemeo and others added 9 commits January 7, 2026 07:14
+  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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
agreeing with Carlos' observation/suggestion
Agreeing with Carlos' suggestion to avoid "request."
+ a minimal `UTXOS` rule as a stub/hook (so `UTXO` can call something),
+ a minimal `UTXO` rule with just the new phase-1 premise (plus an explicit "calls UTXOS"),
+ a minimal `UTXOW`; just a wrapper over `UTXO` for now.
@williamdemeo williamdemeo force-pushed the 1002-dijkstra-phase-1-requiredtoplevelguards-stacked branch from ec362bc to 5a88696 Compare January 7, 2026 14:16
Key idea:

+  Keep `txGuards` as a set **for now**.
+  Define an ordered view `guardsList : List Credential` via `setToList`.
+  Make `indexOfGuard` operate on that list.
+  Let `rdptr` compute the `Ix` using `indexOfGuard`.

For the "required top-level guards requested by subTxs" (i.e., `txRequiredTopLevelGuards` requests), we don't need a new ScriptPurpose constructor yet, because:

+  phase-1 ensures those requested credentials are contained in top-level `txGuards`
+  the later work (#1004 / #1006) will decide how to construct TxInfo / datum arguments for running those guard scripts batch-wide
@williamdemeo williamdemeo force-pushed the 1003-dijkstra-change-types-scriptpurposeguard-indexofguard branch from 446d9c8 to c43c71a Compare January 7, 2026 14:17
@williamdemeo williamdemeo force-pushed the 1002-dijkstra-phase-1-requiredtoplevelguards-stacked branch from 5a88696 to 2dbea3f Compare January 8, 2026 15:38
Base automatically changed from 1002-dijkstra-phase-1-requiredtoplevelguards-stacked to master January 8, 2026 15:39
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!

@williamdemeo williamdemeo merged commit c660581 into master Jan 9, 2026
14 checks passed
@williamdemeo williamdemeo deleted the 1003-dijkstra-change-types-scriptpurposeguard-indexofguard branch January 9, 2026 02:01
@github-project-automation github-project-automation bot moved this from In Progress to Done in Dijkstra formal spec Jan 9, 2026
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] change types of ScriptPurpose.Guard and indexOfGuard to use lists of Credentials

3 participants