-
Notifications
You must be signed in to change notification settings - Fork 20
[Dijkstra] UTXOW rule #1018
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Dijkstra] UTXOW rule #1018
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,6 +1,6 @@ | ||||||
| --- | ||||||
| source_branch: master | ||||||
| source_path: src/Ledger/Dijkstra/Specification/Ledger.lagda | ||||||
| source_path: src/Ledger/Dijkstra/Specification/Ledger.lagda.md | ||||||
| --- | ||||||
|
|
||||||
| # Ledger {#sec:ledger} | ||||||
|
|
@@ -46,7 +46,10 @@ record SubLedgerEnv : Type where | |||||
| pparams : PParams | ||||||
| enactState : EnactState | ||||||
| treasury : Treasury | ||||||
| isValid : Bool | ||||||
| utxo₀ : UTxO | ||||||
| isTopLevelValid : Bool | ||||||
| globalScripts : ℙ Script | ||||||
| globalData : DataHash ⇀ Datum | ||||||
|
|
||||||
| record LedgerEnv : Type where | ||||||
| field | ||||||
|
|
@@ -172,6 +175,7 @@ private variable | |||||
| Γ : LedgerEnv | ||||||
| s s' s'' : LState | ||||||
| utxoState utxoState' : UTxOState | ||||||
| utxo₀ : UTxO | ||||||
| govState govState' : GovState | ||||||
| certState certState' : CertState | ||||||
| stx : SubLevelTx | ||||||
|
|
@@ -181,34 +185,36 @@ private variable | |||||
| enactState : EnactState | ||||||
| treasury : Treasury | ||||||
| isTopLevelValid : Bool | ||||||
| utxo₀ : UTxO | ||||||
| globalScripts : ℙ Script | ||||||
| globalData : DataHash ⇀ Datum | ||||||
| ``` | ||||||
| --> | ||||||
|
|
||||||
| ```agda | ||||||
| data _⊢_⇀⦇_,SUBLEDGER⦈_ : SubLedgerEnv → LState → SubLevelTx → LState → Type where | ||||||
| SUBLEDGER-V : | ||||||
| let txb = stx .txBody | ||||||
| let txb = stx .txBody | ||||||
|
|
||||||
| ``` | ||||||
| <!-- | ||||||
| ```agda | ||||||
| open TxBody txb | ||||||
| open TxBody txb | ||||||
| ``` | ||||||
| --> | ||||||
| ```agda | ||||||
| in | ||||||
| ∙ isTopLevelValid ≡ true | ||||||
| ∙ ⟦ slot , pp , treasury , utxo₀ ⟧ ⊢ utxoState ⇀⦇ stx ,SUBUTXOW⦈ utxoState' | ||||||
| ∙ ⟦ slot , pp , treasury , utxo₀ , isTopLevelValid , globalScripts , globalData ⟧ ⊢ utxoState ⇀⦇ stx ,SUBUTXOW⦈ utxoState' | ||||||
| ∙ ⟦ epoch slot , pp , txGovVotes , txWithdrawals , allColdCreds govState enactState ⟧ ⊢ certState ⇀⦇ txCerts ,CERTS⦈ certState' | ||||||
| ∙ ⟦ txId , epoch slot , pp , ppolicy , enactState , certState' , dom (RewardsOf certState) ⟧ ⊢ {- rmOrphanDRepVotes certState' -} govState ⇀⦇ txgov txb ,GOVS⦈ govState' | ||||||
| ──────────────────────────────── | ||||||
| ⟦ slot , ppolicy , pp , enactState , treasury , isTopLevelValid ⟧ ⊢ ⟦ utxoState , govState , certState ⟧ ⇀⦇ stx ,SUBLEDGER⦈ ⟦ utxoState' , govState' , certState' ⟧ | ||||||
| ⟦ slot , ppolicy , pp , enactState , treasury , utxo₀ , isTopLevelValid , globalScripts , globalData ⟧ ⊢ ⟦ utxoState , govState , certState ⟧ ⇀⦇ stx ,SUBLEDGER⦈ ⟦ utxoState' , govState' , certState' ⟧ | ||||||
|
|
||||||
| SUBLEDGER-I : | ||||||
| ∙ isTopLevelValid ≡ false | ||||||
| ∙ ⟦ slot , pp , treasury , utxo₀ ⟧ ⊢ utxoState ⇀⦇ stx ,SUBUTXOW⦈ utxoState | ||||||
| ∙ ⟦ slot , pp , treasury , utxo₀ , isTopLevelValid , globalScripts , globalData ⟧ ⊢ utxoState ⇀⦇ stx ,SUBUTXOW⦈ utxoState | ||||||
| ──────────────────────────────── | ||||||
| ⟦ slot , ppolicy , pp , enactState , treasury , isTopLevelValid ⟧ ⊢ ⟦ utxoState , govState , certState ⟧ ⇀⦇ stx ,SUBLEDGER⦈ ⟦ utxoState , govState , certState ⟧ | ||||||
| ⟦ slot , ppolicy , pp , enactState , treasury , utxo₀ , isTopLevelValid , globalScripts , globalData ⟧ ⊢ ⟦ utxoState , govState , certState ⟧ ⇀⦇ stx ,SUBLEDGER⦈ ⟦ utxoState , govState , certState ⟧ | ||||||
|
|
||||||
| _⊢_⇀⦇_,SUBLEDGERS⦈_ : SubLedgerEnv → LState → List SubLevelTx → LState → Type | ||||||
| _⊢_⇀⦇_,SUBLEDGERS⦈_ = ReflexiveTransitiveClosure {sts = _⊢_⇀⦇_,SUBLEDGER⦈_} | ||||||
|
|
@@ -228,6 +234,14 @@ private variable | |||||
| data _⊢_⇀⦇_,LEDGER⦈_ : LedgerEnv → LState → TopLevelTx → LState → Type where | ||||||
| LEDGER-V : | ||||||
| let txb = tx .txBody | ||||||
|
|
||||||
| utxo₀ = UTxOOf utxoState | ||||||
|
|
||||||
| globalScripts : ℙ Script | ||||||
| globalScripts = ∅ -- TODO | ||||||
|
|
||||||
| globalData : DataHash ⇀ Datum | ||||||
| globalData = ∅ -- TODO | ||||||
| ``` | ||||||
| <!-- | ||||||
| ```agda | ||||||
|
|
@@ -237,15 +251,23 @@ data _⊢_⇀⦇_,LEDGER⦈_ : LedgerEnv → LState → TopLevelTx → LState | |||||
| ```agda | ||||||
| in | ||||||
| ∙ isValid tx ≡ true | ||||||
| ∙ ⟦ slot , ppolicy , pp , enactState , treasury , isValid tx ⟧ ⊢ ⟦ utxoState , govState , certState ⟧ ⇀⦇ txSubTransactions ,SUBLEDGERS⦈ ⟦ utxoState' , govState' , certState' ⟧ | ||||||
| ∙ ⟦ slot , pp , treasury , utxo₀ ⟧ ⊢ utxoState' ⇀⦇ tx ,UTXOW⦈ utxoState'' | ||||||
| ∙ ⟦ slot , ppolicy , pp , enactState , treasury , utxo₀ , isValid tx , globalScripts , globalData ⟧ ⊢ ⟦ utxoState , govState , certState ⟧ ⇀⦇ txSubTransactions ,SUBLEDGERS⦈ ⟦ utxoState' , govState' , certState' ⟧ | ||||||
| ∙ ⟦ slot , pp , treasury , utxo₀ , isValid tx , globalScripts , globalData ⟧ ⊢ utxoState' ⇀⦇ tx ,UTXOW⦈ utxoState'' | ||||||
| ∙ ⟦ epoch slot , pp , txGovVotes , txWithdrawals , allColdCreds govState enactState ⟧ ⊢ certState' ⇀⦇ txCerts ,CERTS⦈ certState'' | ||||||
| ∙ ⟦ txId , epoch slot , pp , ppolicy , enactState , certState' , dom (RewardsOf certState) ⟧ ⊢ {- rmOrphanDRepVotes certState' -} govState ⇀⦇ txgov txb ,GOVS⦈ govState' | ||||||
| ──────────────────────────────── | ||||||
| ⟦ slot , ppolicy , pp , enactState , treasury ⟧ ⊢ ⟦ utxoState , govState , certState ⟧ ⇀⦇ tx ,LEDGER⦈ ⟦ utxoState'' , govState'' , certState'' ⟧ | ||||||
|
|
||||||
| LEDGER-I : | ||||||
| let txb = tx .txBody | ||||||
|
|
||||||
| utxo₀ = UTxOOf utxoState | ||||||
|
|
||||||
| globalScripts : ℙ Script | ||||||
| globalScripts = ∅ -- TODO | ||||||
|
|
||||||
| globalData : DataHash ⇀ Datum | ||||||
| globalData = ∅ -- TODO | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I think we should put something other than ∅ here for now, since otherwise the The suggestion above ( record HasDatumMap {a} (A : Type a) : Type a where
field DatumMapOf : A → DataHash ⇀ Datum
open HasDatumMap ⦃...⦄ public
instance
HasDatumMap-TxWitnesses : HasDatumMap (TxWitnesses txLevel)
HasDatumMap-TxWitnesses .DatumMapOf = TxWitnesses.txData
HasDatumMap-Tx : HasDatumMap (Tx txLevel)
HasDatumMap-Tx .DatumMapOf = DatumMapOf ∘ TxWitnessesOfSimilarly, we should probably put a non-empty placeholder in
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest we leave this to the corresponding issue. |
||||||
| ``` | ||||||
| <!-- | ||||||
| ```agda | ||||||
|
|
@@ -255,8 +277,8 @@ data _⊢_⇀⦇_,LEDGER⦈_ : LedgerEnv → LState → TopLevelTx → LState | |||||
| ```agda | ||||||
| in | ||||||
| ∙ isValid tx ≡ false | ||||||
| ∙ ⟦ slot , ppolicy , pp , enactState , treasury , isValid tx ⟧ ⊢ ⟦ utxoState , govState , certState ⟧ ⇀⦇ txSubTransactions ,SUBLEDGERS⦈ ⟦ utxoState , govState , certState ⟧ | ||||||
| ∙ ⟦ slot , pp , treasury , utxo₀ ⟧ ⊢ utxoState ⇀⦇ tx ,UTXOW⦈ utxoState' | ||||||
| ∙ ⟦ slot , ppolicy , pp , enactState , treasury , utxo₀ , isValid tx , globalScripts , globalData ⟧ ⊢ ⟦ utxoState , govState , certState ⟧ ⇀⦇ txSubTransactions ,SUBLEDGERS⦈ ⟦ utxoState , govState , certState ⟧ | ||||||
| ∙ ⟦ slot , pp , treasury , utxo₀ , isValid tx , globalScripts , globalData ⟧ ⊢ utxoState ⇀⦇ tx ,UTXOW⦈ utxoState' | ||||||
| ──────────────────────────────── | ||||||
| ⟦ slot , ppolicy , pp , enactState , treasury ⟧ ⊢ ⟦ utxoState , govState , certState ⟧ ⇀⦇ tx ,LEDGER⦈ ⟦ utxoState' , govState , certState ⟧ | ||||||
| ``` | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,12 +3,7 @@ source_branch: master | |
| source_path: src/Ledger/Dijkstra/Specification/Utxow.lagda.md | ||
| --- | ||
|
|
||
| # UTxOW (Dijkstra skeleton) | ||
|
|
||
| This is a **minimal skeleton** of the Dijkstra-era witnessing layer. | ||
|
|
||
| It currently acts as a wrapper around `UTXO`, mirroring Conway's shape, but without | ||
| committing to full witnessing checks yet. | ||
| # UTxOW | ||
|
|
||
| <!-- | ||
| ```agda | ||
|
|
@@ -24,30 +19,133 @@ module Ledger.Dijkstra.Specification.Utxow | |
| where | ||
|
|
||
| open import Ledger.Dijkstra.Specification.Utxo txs abs | ||
| open import Ledger.Dijkstra.Specification.Script.Validation txs abs | ||
|
|
||
| private variable | ||
| ℓ : TxLevel | ||
| Γ : UTxOEnv | ||
| s s' : UTxOState | ||
| tx : TopLevelTx | ||
| stx : SubLevelTx | ||
| ``` | ||
| --> | ||
|
|
||
| ```agda | ||
| languages : Tx ℓ → UTxO → ℙ Language | ||
| languages tx utxo = ∅ -- TODO | ||
|
|
||
| allowedLanguages : Tx ℓ → UTxO → ℙ Language | ||
| allowedLanguages tx utxo = ∅ -- TODO | ||
| ``` | ||
|
|
||
| ```agda | ||
| data _⊢_⇀⦇_,SUBUTXOW⦈_ : UTxOEnv → UTxOState → SubLevelTx → UTxOState → Type where | ||
|
|
||
| SUBUTXOW : | ||
| let | ||
| open Tx tx | ||
| open TxBody txBody | ||
| open TxWitnesses txWitnesses | ||
| open UTxOEnv | ||
|
|
||
| utxo₀ = Γ .utxo₀ | ||
| utxo = s .UTxOState.utxo | ||
|
|
||
| witsKeyHashes : ℙ KeyHash | ||
| witsKeyHashes = mapˢ hash (dom vKeySigs) | ||
|
|
||
| allScripts : ℙ Script | ||
| allScripts = | ||
| ( scripts -- (1) scripts from witnesses | ||
| ∪ mapPartial txOutToScript | ||
| ( range (utxo₀ ∣ txIns) -- (2) scripts from transaction inputs | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should document asap the important semantic choice of using range (utxo₀ ∣ txIns)which encodes the policy spending inputs are always resolved from the initial snapshot ( For now maybe just add one sentence above the relevant code blocks, something like, "In By the way, in my PR, I'll rename " |
||
| ∪ range (utxo ∣ refInputs) -- (3) scripts from reference inputs | ||
| ) | ||
| ∪ Γ .globalScripts -- (4) scripts from the nested transaction | ||
| ) | ||
|
|
||
| p1Scripts : ℙ P1Script | ||
| p1Scripts = mapPartial toP1Script allScripts | ||
|
|
||
| p2Scripts : ℙ P2Script | ||
| p2Scripts = mapPartial toP2Script allScripts | ||
|
|
||
| neededScriptHashes : ℙ ScriptHash | ||
| neededScriptHashes = mapPartial (isScriptObj ∘ proj₂) (credsNeeded utxo₀ txBody) | ||
|
|
||
| neededVKeyHashes : ℙ KeyHash | ||
| neededVKeyHashes = mapPartial (isKeyHashObj ∘ proj₂) (credsNeeded utxo₀ txBody) | ||
|
|
||
| neededDataHashes : ℙ DataHash | ||
| neededDataHashes = mapPartial (λ txOut@(a , _ , d , _) → do sh ← isScriptObj (payCred a) | ||
| _ ← lookupHash sh p2Scripts | ||
| d >>= isInj₂) | ||
| (range (utxo₀ ∣ txIns)) | ||
|
|
||
| in | ||
| ∙ ∀[ (vk , σ) ∈ vKeySigs ] isSigned vk (txidBytes txId) σ | ||
| ∙ ∀[ s ∈ p1Scripts ] (hash s ∈ neededScriptHashes → validP1Script witsKeyHashes txVldt s) | ||
| ∙ neededVKeyHashes ⊆ witsKeyHashes | ||
| ∙ neededScriptHashes ⊆ mapˢ hash allScripts | ||
| ∙ neededDataHashes ⊆ dom (Γ .globalData) | ||
| ∙ languages tx utxo ⊆ allowedLanguages tx utxo | ||
| ∙ txADhash ≡ map hash txAuxData | ||
| ∙ Γ ⊢ s ⇀⦇ stx ,SUBUTXO⦈ s' | ||
| ──────────────────────────────── | ||
| Γ ⊢ s ⇀⦇ stx ,SUBUTXOW⦈ s' | ||
|
|
||
| data _⊢_⇀⦇_,UTXOW⦈_ : UTxOEnv → UTxOState → TopLevelTx → UTxOState → Type where | ||
|
|
||
| UTXOW : | ||
| ∙ Γ ⊢ s ⇀⦇ tx ,UTXO⦈ s' | ||
| let | ||
| open Tx tx | ||
| open TxBody txBody | ||
| open TxWitnesses txWitnesses | ||
| open UTxOEnv | ||
|
|
||
| utxo₀ = Γ .utxo₀ | ||
| utxo = s .UTxOState.utxo | ||
|
|
||
| witsKeyHashes : ℙ KeyHash | ||
| witsKeyHashes = mapˢ hash (dom vKeySigs) | ||
|
|
||
| allScripts : ℙ Script | ||
| allScripts = | ||
| ( scripts -- (1) scripts from witnesses | ||
| ∪ mapPartial txOutToScript | ||
| ( range (utxo₀ ∣ txIns) -- (2) scripts from transaction inputs | ||
| ∪ range (utxo ∣ refInputs) -- (3) scripts from reference inputs | ||
| ) | ||
| ∪ Γ .globalScripts -- (4) scripts from the nested transaction | ||
| ) | ||
|
|
||
| p1Scripts : ℙ P1Script | ||
| p1Scripts = mapPartial toP1Script allScripts | ||
|
|
||
| p2Scripts : ℙ P2Script | ||
| p2Scripts = mapPartial toP2Script allScripts | ||
|
|
||
| neededScriptHashes : ℙ ScriptHash | ||
| neededScriptHashes = mapPartial (isScriptObj ∘ proj₂) (credsNeeded utxo₀ txBody) | ||
|
|
||
| neededVKeyHashes : ℙ KeyHash | ||
| neededVKeyHashes = mapPartial (isKeyHashObj ∘ proj₂) (credsNeeded utxo₀ txBody) | ||
|
|
||
| neededDataHashes : ℙ DataHash | ||
| neededDataHashes = mapPartial (λ txOut@(a , _ , d , _) → do sh ← isScriptObj (payCred a) | ||
| _ ← lookupHash sh p2Scripts | ||
| d >>= isInj₂) | ||
| (range (utxo₀ ∣ txIns)) | ||
|
|
||
| in | ||
| ∙ ∀[ (vk , σ) ∈ vKeySigs ] isSigned vk (txidBytes txId) σ | ||
| ∙ ∀[ s ∈ p1Scripts ] (hash s ∈ neededScriptHashes → validP1Script witsKeyHashes txVldt s) | ||
| ∙ neededVKeyHashes ⊆ witsKeyHashes | ||
| ∙ neededScriptHashes ⊆ mapˢ hash allScripts | ||
| ∙ neededDataHashes ⊆ dom (Γ .globalData) | ||
| ∙ languages tx utxo ⊆ allowedLanguages tx utxo | ||
| ∙ txADhash ≡ map hash txAuxData | ||
| ∙ Γ ⊢ s ⇀⦇ tx ,UTXO⦈ s' | ||
| ──────────────────────────────── | ||
| Γ ⊢ s ⇀⦇ tx ,UTXOW⦈ s' | ||
| ``` | ||
|
|
||
| This file intentionally contains **no** additional premises yet. As Dijkstra witnessing | ||
| evolves, this is where signature / script / datum / language constraints can be added. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably a good idea to document
globalScriptsandglobalDataabove where they're first introduced, since they're central to the new Dijkstra semantics. Could you add something like the following above this code block?globalScripts : ℙ Scriptdenotes the batch-wide script pool, available for resolving script hashes (witness scripts + reference scripts reachable via reference inputs, possibly including outputs created earlier in the batch).globalData : DataHash ⇀ Datumdenotes the batch-wide datum pool, available for resolving datum hashes (witness datums + datums reachable via reference inputs and/or other transactions in the batch).Of course you should revise the prose if you have a better or different understanding of the roles played by these objects.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll leave this to the corresponding issue.