Skip to content

Commit 2637fec

Browse files
committed
add TxInfo.txInfoSubTxs field
1. Introduce subTx info type (using an alias for `TxInfo` for now). 2. Extend `TxInfo` with field `txInfoSubTxs : Maybe (List SubTxInfo)`. 3. Define a purpose-built builder: + Top-level Guard scripts ⇒ `txInfoSubTxs = just (...)` + Everything else ⇒ `txInfoSubTxs = nothing` + SubTx scripts ⇒ always `nothing` (even for `Guard` at sub level)
1 parent 7673571 commit 2637fec

File tree

1 file changed

+38
-12
lines changed

1 file changed

+38
-12
lines changed

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

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,25 @@ getDatum tx utxo _ = nothing
7070
-->
7171

7272
```agda
73-
record TxInfo : Type where
74-
field realizedInputs : UTxO
75-
txOuts : Ix ⇀ TxOut
76-
txFee : Maybe Fees
77-
mint : Value
78-
txCerts : List DCert
79-
txWithdrawals : Withdrawals
80-
txVldt : Maybe Slot × Maybe Slot
81-
vkKey : ℙ KeyHash -- native/phase-1/timelock signers
82-
txGuards : ℙ Credential -- CIP-0112/0118 guards (required by tx body)
83-
txData : ℙ Datum
84-
txId : TxId
73+
mutual
74+
record TxInfo : Type where
75+
inductive
76+
field
77+
realizedInputs : UTxO
78+
txOuts : Ix ⇀ TxOut
79+
txFee : Maybe Fees
80+
mint : Value
81+
txCerts : List DCert
82+
txWithdrawals : Withdrawals
83+
txVldt : Maybe Slot × Maybe Slot
84+
vkKey : ℙ KeyHash -- native/phase-1/timelock signers
85+
txGuards : ℙ Credential -- CIP-0112/0118 guards (required by tx body)
86+
txData : ℙ Datum
87+
txId : TxId
88+
txInfoSubTxs : Maybe (List SubTxInfo)
89+
90+
SubTxInfo : Type
91+
SubTxInfo = TxInfo
8592
8693
8794
txInfo : (ℓ : TxLevel) → UTxO → Tx ℓ → TxInfo
@@ -98,6 +105,7 @@ txInfo TxLevelTop utxo tx =
98105
; txGuards = TxBody.txGuards txBody
99106
; txData = DataOf tx
100107
; txId = TxBody.txId txBody
108+
; txInfoSubTxs = nothing
101109
} where open Tx tx
102110
103111
txInfo TxLevelSub utxo tx =
@@ -112,7 +120,25 @@ txInfo TxLevelSub utxo tx =
112120
; txGuards = TxBody.txGuards txBody
113121
; txData = DataOf tx
114122
; txId = TxBody.txId txBody
123+
; txInfoSubTxs = nothing
115124
} where open Tx tx
125+
126+
txInfoForPurpose : (ℓ : TxLevel) → UTxO → Tx ℓ → ScriptPurpose → TxInfo
127+
-- SubTx scripts never get subTx infos (even if their ScriptPurpose is Guard).
128+
txInfoForPurpose TxLevelSub utxo tx sp = txInfo TxLevelSub utxo tx
129+
-- Top-level scripts:
130+
-- - guard scripts see txInfoSubTxs
131+
-- - others do not
132+
txInfoForPurpose TxLevelTop utxo tx sp with sp
133+
... | Guard _ =
134+
let base = txInfo TxLevelTop utxo tx
135+
txb = TxBodyOf tx
136+
subTxs = TxBody.txSubTransactions txb
137+
subInfos : List SubTxInfo
138+
subInfos = map (txInfo TxLevelSub utxo) subTxs
139+
in
140+
record base { txInfoSubTxs = just subInfos }
141+
... | _ = txInfo TxLevelTop utxo tx
116142
```
117143

118144
<!--

0 commit comments

Comments
 (0)