Skip to content

Commit 0b585e4

Browse files
committed
Add preconditions to UTXOW
1 parent dd8aae4 commit 0b585e4

File tree

2 files changed

+43
-10
lines changed

2 files changed

+43
-10
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ open import Ledger.Dijkstra.Specification.Script.Validation txs abs
3838
```agda
3939
record UTxOEnv : Type where
4040
field
41-
slot : Slot
42-
pparams : PParams
43-
treasury : Treasury
41+
slot : Slot
42+
pparams : PParams
43+
treasury : Treasury
44+
utxo₀ : UTxO
45+
refInputsScripts : ℙ Script
4446
4547
record UTxOState : Type where
4648
field

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

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,53 @@ module Ledger.Dijkstra.Specification.Utxow
2424
where
2525
2626
open import Ledger.Dijkstra.Specification.Utxo txs abs
27+
open import Ledger.Dijkstra.Specification.Script.Validation txs abs
2728
2829
private variable
30+
ℓ : TxLevel
2931
Γ : UTxOEnv
3032
s s' : UTxOState
31-
tx : TopLevelTx
33+
tx : Tx ℓ
3234
```
3335
-->
3436

3537
```agda
36-
data _⊢_⇀⦇_,UTXOW⦈_ : UTxOEnv → UTxOState → TopLevelTx → UTxOState → Type where
38+
data _⊢_⇀⦇_,UTXOW⦈_ : UTxOEnv → UTxOState → Tx ℓ → UTxOState → Type where
3739
38-
UTXOW-inductive :
39-
∙ Γ ⊢ s ⇀⦇ tx ,UTXO⦈ s'
40+
UTXOW :
41+
let
42+
open Tx tx
43+
open TxBody txBody
44+
open TxWitnesses txWitnesses
45+
46+
utxo₀ = Γ .UTxOEnv.utxo₀
47+
utxo = s .UTxOState.utxo
48+
witsKeyHashes = mapˢ hash (dom vKeySigs)
49+
neededScriptHashes = mapPartial (isScriptObj ∘ proj₂) (credsNeeded utxo₀ txBody)
50+
neededVKeyHashes = mapPartial (isKeyHashObj ∘ proj₂) (credsNeeded utxo₀ txBody)
51+
-- txdatsHashes = mapˢ hash txdats
52+
-- inputsDataHashes = mapPartial (λ txout → if txOutToP2Script utxo tx txout
53+
-- then txOutToDataHash txout
54+
-- else nothing) (range (utxo ∣ txIns))
55+
-- refInputsDataHashes = mapPartial txOutToDataHash (range (utxo ∣ refInputs))
56+
-- outputsDataHashes = mapPartial txOutToDataHash (range txOuts)
57+
p1Scripts = mapPartial toP1Script
58+
( scripts -- (1) scripts from witnesses
59+
∪ mapPartial txOutScript
60+
( range (utxo₀ ∣ txIns) -- (2) scripts from transaction inputs
61+
∪ range (utxo ∣ refInputs) -- (3) scripts from reference inputs
62+
)
63+
∪ Γ .UTxOEnv.refInputsScripts -- (4) scripts from all reference inputs
64+
)
65+
in
66+
∙ ∀[ (vk , σ) ∈ vKeySigs ] isSigned vk (txidBytes txId) σ
67+
∙ ∀[ s ∈ p1Scripts ] (hash s ∈ neededScriptHashes → validP1Script witsKeyHashes txVldt s)
68+
∙ neededVKeyHashes ⊆ witsKeyHashes
69+
-- ∙ inputsDataHashes ⊆ txdatsHashes
70+
-- ∙ txdatsHashes ⊆ inputsDataHashes ∪ outputsDataHashes ∪ refInputsDataHashes
71+
-- ∙ languages tx utxo ⊆ allowedLanguages tx utxo
72+
-- ∙ txADhash ≡ map hash txAD
73+
-- ∙ Γ ⊢ s ⇀⦇ tx ,UTXO⦈ s'
4074
────────────────────────────────
4175
Γ ⊢ s ⇀⦇ tx ,UTXOW⦈ s'
4276
```
43-
44-
This file intentionally contains **no** additional premises yet. As Dijkstra witnessing
45-
evolves, this is where signature / script / datum / language constraints can be added.

0 commit comments

Comments
 (0)