Skip to content

Commit c660581

Browse files
[Dijkstra] Make ScriptPurpose.Guard and IndexOfGuard carry a Credential (#1011)
* Add helpers for grouping top-level guard requests * Fix prose explaining CIP 118. + 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. * update CHANGELOG * Update src/Ledger/Dijkstra/Specification/Transaction.lagda.md Co-authored-by: Copilot <[email protected]> * change txRequiredTopLevelGuards type from list to set agreeing with Carlos' observation/suggestion * changed nomenclature Agreeing with Carlos' suggestion to avoid "request." * convert code comments to (literate) documentation * Add `requiredTopLevelGuardsSatisfied` predicate. * Add initial versions of Utxo and Utxow modules + 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. * Make `ScriptPurpose.Guard` carry a `Credential` 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 --------- Co-authored-by: Copilot <[email protected]>
1 parent cd76009 commit c660581

File tree

2 files changed

+28
-22
lines changed

2 files changed

+28
-22
lines changed

src/Ledger/Dijkstra/Specification/Abstract.lagda.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ open import Ledger.Dijkstra.Specification.Certs govStructure
1212
1313
record indexOf : Type where
1414
field
15-
indexOfDCert : DCert → List DCert → Maybe Ix
16-
indexOfRewardAddress : RewardAddress → Withdrawals → Maybe Ix
17-
indexOfTxIn : TxIn → ℙ TxIn → Maybe Ix
18-
indexOfPolicyId : ScriptHash → ℙ ScriptHash → Maybe Ix
19-
indexOfVote : GovVoter → List GovVoter → Maybe Ix
20-
indexOfProposal : GovProposal → List GovProposal → Maybe Ix
21-
indexOfGuard : TxId × ScriptHash → ℙ (TxId × ScriptHash) → Maybe Ix
15+
indexOfDCert : DCert → List DCert → Maybe Ix
16+
indexOfRewardAddress : RewardAddress → Withdrawals → Maybe Ix
17+
indexOfTxIn : TxIn → ℙ TxIn → Maybe Ix
18+
indexOfPolicyId : ScriptHash → ℙ ScriptHash → Maybe Ix
19+
indexOfVote : GovVoter → List GovVoter → Maybe Ix
20+
indexOfProposal : GovProposal → List GovProposal → Maybe Ix
21+
indexOfGuard : Credential → List Credential → Maybe Ix
2222
2323
record AbstractFunctions : Type where
2424
field txScriptFee : Prices → ExUnits → Fees

src/Ledger/Dijkstra/Specification/Script/Validation.lagda.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,36 @@ open import Ledger.Dijkstra.Specification.Certs govStructure
2222

2323
```agda
2424
data ScriptPurpose : Type where
25-
Cert : DCert → ScriptPurpose
26-
Rwrd : RewardAddress → ScriptPurpose
27-
Mint : ScriptHash → ScriptPurpose
28-
Spend : TxIn → ScriptPurpose
29-
Vote : GovVoter → ScriptPurpose
30-
Propose : GovProposal → ScriptPurpose
31-
Guard : (TxId × ScriptHash) → ScriptPurpose
25+
Cert : DCert → ScriptPurpose
26+
Rwrd : RewardAddress → ScriptPurpose
27+
Mint : ScriptHash → ScriptPurpose
28+
Spend : TxIn → ScriptPurpose
29+
Vote : GovVoter → ScriptPurpose
30+
Propose : GovProposal → ScriptPurpose
31+
Guard : Credential → ScriptPurpose
3232
```
3333

34+
Note that `Guard c` always indexes into *the current `tx`'s* `txGuards`:
35+
36+
+ if `tx : TopLevelTx`, it indexes into the top-level guard set's list-view;
37+
+ if `tx : SubLevelTx`, it indexes into the subTx's guard set's list-view.
38+
3439
<!--
3540
```agda
3641
private variable
3742
ℓ : TxLevel
3843
3944
rdptr : (Tx ℓ) → ScriptPurpose → Maybe (RedeemerPtr ℓ)
4045
rdptr tx = λ where
41-
(Cert h) → map (Cert ,_) $ indexOfDCert h txCerts
42-
(Rwrd h) → map (Reward ,_) $ indexOfRewardAddress h txWithdrawals
43-
(Mint h) → map (Mint ,_) $ indexOfPolicyId h (policies mint)
44-
(Spend h) → map (Spend ,_) $ indexOfTxIn h txIns
45-
(Vote h) → map (Vote ,_) $ indexOfVote h (map GovVote.voter txGovVotes)
46-
(Propose h) → map (Propose ,_) $ indexOfProposal h txGovProposals
47-
(Guard h) → map (Guard ,_) $ indexOfGuard h (getTxScripts tx)
48-
where open TxBody (TxBodyOf tx)
46+
(Cert h) → map (Cert ,_) $ indexOfDCert h txCerts
47+
(Rwrd h) → map (Reward ,_) $ indexOfRewardAddress h txWithdrawals
48+
(Mint h) → map (Mint ,_) $ indexOfPolicyId h (policies mint)
49+
(Spend h) → map (Spend ,_) $ indexOfTxIn h txIns
50+
(Vote h) → map (Vote ,_) $ indexOfVote h (map GovVote.voter txGovVotes)
51+
(Propose h) → map (Propose ,_) $ indexOfProposal h txGovProposals
52+
(Guard c) → map (Guard ,_) $ indexOfGuard c (setToList txGuards)
53+
where open TxBody (TxBodyOf tx)
54+
4955
-- getSubTxScripts : TopLevelTx → ℙ (TxId × ScriptHash)
5056
5157
indexedRdmrs : (Tx ℓ) → ScriptPurpose → Maybe (Redeemer × ExUnits)

0 commit comments

Comments
 (0)