Skip to content

Commit ce58826

Browse files
committed
bugfix
1 parent 01290c3 commit ce58826

File tree

2 files changed

+37
-20
lines changed

2 files changed

+37
-20
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,14 @@ could be either of them.
291291
field TxIdOf : A → TxId
292292
open HasTxId ⦃...⦄ public
293293
294+
record HasSpendInputs {a} (A : Type a) : Type a where
295+
field SpendInputsOf : A → ℙ TxIn
296+
open HasSpendInputs ⦃...⦄ public
297+
298+
record HasReferenceInputs {a} (A : Type a) : Type a where
299+
field ReferenceInputsOf : A → ℙ TxIn
300+
open HasReferenceInputs ⦃...⦄ public
301+
294302
record HasFees? {a} (A : Type a) : Type a where
295303
field FeesOf? : A → Maybe Fees
296304
open HasFees? ⦃...⦄ public
@@ -339,6 +347,18 @@ could be either of them.
339347
HasWithdrawals-Tx : HasWithdrawals (Tx txLevel)
340348
HasWithdrawals-Tx .WithdrawalsOf = WithdrawalsOf ∘ TxBodyOf
341349
350+
HasSpendInputs-TxBody : HasSpendInputs (TxBody txLevel)
351+
HasSpendInputs-TxBody .SpendInputsOf = TxBody.txIns
352+
353+
HasSpendInputs-Tx : HasSpendInputs (Tx txLevel)
354+
HasSpendInputs-Tx .SpendInputsOf = SpendInputsOf ∘ TxBodyOf
355+
356+
HasReferenceInputs-TxBody : HasReferenceInputs (TxBody txLevel)
357+
HasReferenceInputs-TxBody .ReferenceInputsOf = TxBody.refInputs
358+
359+
HasReferenceInputs-Tx : HasReferenceInputs (Tx txLevel)
360+
HasReferenceInputs-Tx .ReferenceInputsOf = ReferenceInputsOf ∘ TxBodyOf
361+
342362
HasValue-TxBody : HasValue (TxBody txLevel)
343363
HasValue-TxBody .ValueOf = TxBody.mint
344364

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

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ record UTxOState : Type where
5454
<!--
5555
```agda
5656
instance
57+
HasUTxO-UTxOEnv : HasUTxO UTxOEnv
58+
HasUTxO-UTxOEnv .UTxOOf = UTxOEnv.utxo₀
59+
60+
HasUTxO-UTxOState : HasUTxO UTxOState
61+
HasUTxO-UTxOState .UTxOOf = UTxOState.utxo
62+
5763
unquoteDecl HasCast-UTxOEnv HasCast-UTxOState = derive-HasCast
5864
( (quote UTxOEnv , HasCast-UTxOEnv ) ∷
5965
[ (quote UTxOState , HasCast-UTxOState) ])
@@ -96,37 +102,28 @@ transaction (or partially applying any part of it). TODO: Add link to CIP once i
96102
data _⊢_⇀⦇_,SUBUTXO⦈_ : UTxOEnv → UTxOState → SubLevelTx → UTxOState → Type where
97103
98104
SUBUTXO :
99-
let txb = Tx.txBody tx
100-
subTxs = TxBody.txSubTransactions txb
101-
in
105+
102106
────────────────────────────────
103107
Γ ⊢ s ⇀⦇ stx ,SUBUTXO⦈ s'
104108
105109
data _⊢_⇀⦇_,UTXO⦈_ : UTxOEnv → UTxOState → TopLevelTx → UTxOState → Type where
106110
107111
UTXO :
108-
let txb = Tx.txBody tx
109-
subTxs = TxBody.txSubTransactions txb
110-
utxo₀ = Γ .utxo₀
111-
utxo = s .utxo
112-
in
113-
∙ txIns ≢ ∅
114-
∙ txIns ⊆ dom utxo₀ -- (1)
115-
∙ refInputs ⊆ dom utxo
116-
117-
∙ requiredTopLevelGuardsSatisfied tx subTxs
118112
113+
∙ SpendInputsOf tx ≢ ∅
114+
∙ SpendInputsOf tx ⊆ dom (UTxOOf Γ) -- (1)
115+
∙ ReferenceInputsOf tx ⊆ dom (UTxOOf s)
116+
∙ requiredTopLevelGuardsSatisfied tx (SubTransactionsOf tx) -- (2)
119117
∙ Γ ⊢ s ⇀⦇ tx ,UTXOS⦈ s'
120118
────────────────────────────────
121119
Γ ⊢ s ⇀⦇ tx ,UTXO⦈ s'
122120
```
123121

124-
**Note.** The premise `requiredTopLevelGuardsSatisfied tx subTxs`
125-
is explicitly a **phase-1** condition (CIP-0118): every guard credential requested by
126-
subTx bodies must appear in the top-level `txGuards` set.
122+
**Notes**.
127123

128-
A couple of details to notice:
124+
1. The set of spending inputs must exist in the UTxO *before* applying the
125+
transaction (or partially applying any part of it).
129126

130-
- `txb` is computed via `Tx.txBody tx` (no reliance on `TxBodyOf` instances).
131-
- `UTXOS-stub` returns the **same** state (so we can typecheck
132-
everything without inventing semantics prematurely).
127+
2. The premise `requiredTopLevelGuardsSatisfied tx subTxs` is explicitly a
128+
phase-1 condition (CIP-0118): every guard credential requested by subtransaction
129+
bodies must appear in the top-level `txGuards` set.

0 commit comments

Comments
 (0)