Skip to content

Commit 7066cad

Browse files
committed
Thread rewards0 from Ledger
1 parent 042a9cf commit 7066cad

2 files changed

Lines changed: 31 additions & 18 deletions

File tree

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,20 @@ record EntitiesEnv : Type where
3333
coldCredentials : ℙ Credential
3434
legacyMode : Bool
3535
rewards₀ : Rewards
36+
37+
record SubEntitiesEnv : Type where
38+
field
39+
epoch : Epoch
40+
pp : PParams
41+
coldCredentials : ℙ Credential
42+
rewards₀ : Rewards
3643
```
3744

3845
<!--
3946
```agda
40-
unquoteDecl HasCast-EntitiesEnv = derive-HasCast
41-
[ (quote EntitiesEnv , HasCast-EntitiesEnv) ]
47+
unquoteDecl HasCast-EntitiesEnv HasCast-SubEntitiesEnv = derive-HasCast
48+
( (quote SubEntitiesEnv , HasCast-SubEntitiesEnv) ∷
49+
[ (quote EntitiesEnv , HasCast-EntitiesEnv) ])
4250
4351
instance
4452
EntitiesEnv-HasEpoch : HasEpoch EntitiesEnv
@@ -117,16 +125,12 @@ private variable
117125
stakeDelegs stakeDelegs' : StakeDelegs
118126
ccHotKeys : CCHotKeys
119127
voteDelegs voteDelegs' : VoteDelegs
120-
withdrawals : Withdrawals
121-
directDeposits : DirectDeposits
122-
accountBalanceIntervals : AccountBalanceIntervals
123128
rewards₀ : Rewards
124129
depositsᵍ depositsᵈ depositsᵈ' : Credential ⇀ Coin
125130
legacyMode : Bool
126131
127132
dCerts : List DCert
128133
e : Epoch
129-
votes : List GovVote
130134
pp : PParams
131135
cc : ℙ Credential
132136
@@ -136,16 +140,17 @@ private variable
136140
-->
137141

138142
```agda
139-
data _⊢_⇀⦇_,SUBENTITIES⦈_ : EntitiesEnv → CertState → SubLevelTx → CertState → Type where
143+
data _⊢_⇀⦇_,SUBENTITIES⦈_ : SubEntitiesEnv → CertState → SubLevelTx → CertState → Type where
140144
141145
SUBENTITIES :
142-
let refresh = mapPartial (isGovVoterDRep ∘ voter) (fromList votes)
146+
let refresh = mapPartial (isGovVoterDRep ∘ voter) (fromList (ListOfGovVotesOf txSub))
143147
refreshedDReps = mapValueRestricted (const (e + pp .drepActivity)) dReps refresh
144148
activeVDelegs = mapˢ vDelegCredential (dom (DRepsOf gState'))
145149
∪ fromList (vDelegNoConfidence ∷ vDelegAbstain ∷ [])
146150
147151
withdrawals = WithdrawalsOf txSub
148152
withdrawalsCredentials = mapˢ stake (dom withdrawals)
153+
accountBalanceIntervals = BalanceIntervalsOf txSub
149154
directDeposits = DirectDepositsOf txSub
150155
directDepositsCredentials = mapˢ stake (dom directDeposits)
151156
in
@@ -162,21 +167,22 @@ data _⊢_⇀⦇_,SUBENTITIES⦈_ : EntitiesEnv → CertState → SubLevelTx →
162167
∙ ∀[ a ∈ dom directDeposits ] NetworkIdOf a ≡ NetworkId
163168
∙ directDepositsCredentials ⊆ dom rewards'
164169
────────────────────────────────
165-
⟦ e , pp , cc , legacyMode , rewards₀ ⟧ ⊢ ⟦ ⟦ voteDelegs , stakeDelegs , rewards , depositsᵈ ⟧ , pState , ⟦ dReps , ccHotKeys , depositsᵍ ⟧ ⟧ ⇀⦇ txSub ,SUBENTITIES⦈ ⟦ ⟦ voteDelegs' ∣^ activeVDelegs , stakeDelegs' , applyDirectDeposits directDeposits rewards' , depositsᵈ' ⟧ , pState' , gState' ⟧
170+
⟦ e , pp , cc , rewards₀ ⟧ ⊢ ⟦ ⟦ voteDelegs , stakeDelegs , rewards , depositsᵈ ⟧ , pState , ⟦ dReps , ccHotKeys , depositsᵍ ⟧ ⟧ ⇀⦇ txSub ,SUBENTITIES⦈ ⟦ ⟦ voteDelegs' ∣^ activeVDelegs , stakeDelegs' , applyDirectDeposits directDeposits rewards' , depositsᵈ' ⟧ , pState' , gState' ⟧
166171
```
167172

168173
```agda
169174
data _⊢_⇀⦇_,ENTITIES⦈_ : EntitiesEnv → CertState → TopLevelTx → CertState → Type where
170175
171176
ENTITIES :
172-
let refresh = mapPartial (isGovVoterDRep ∘ voter) (fromList votes)
177+
let refresh = mapPartial (isGovVoterDRep ∘ voter) (fromList (ListOfGovVotesOf txTop))
173178
refreshedDReps = mapValueRestricted (const (e + pp .drepActivity)) dReps refresh
174179
activeVDelegs = mapˢ vDelegCredential (dom (DRepsOf gState'))
175180
∪ fromList (vDelegNoConfidence ∷ vDelegAbstain ∷ [])
176181
177182
withdrawalsSubTxs = foldl (λ acc txSub → acc ∪⁺ WithdrawalsOf txSub) ∅ (SubTransactionsOf txTop)
178183
withdrawals = WithdrawalsOf txTop
179184
withdrawalsCredentials = mapˢ stake (dom withdrawals)
185+
accountBalanceIntervals = BalanceIntervalsOf txSub
180186
directDeposits = DirectDepositsOf txTop
181187
directDepositsCredentials = mapˢ stake (dom directDeposits)
182188
in

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ open import Ledger.Dijkstra.Specification.Gov govStructure
2828
open import Ledger.Dijkstra.Specification.Utxo txs abs
2929
open import Ledger.Dijkstra.Specification.Utxow txs abs
3030
open import Ledger.Dijkstra.Specification.Certs govStructure
31-
open import Ledger.Dijkstra.Specification.Entities govStructure
31+
open import Ledger.Dijkstra.Specification.Entities txs
3232
3333
open EnactState using (cc)
3434
```
@@ -45,7 +45,7 @@ record SubLedgerEnv : Type where
4545
enactState : EnactState
4646
treasury : Treasury
4747
utxo₀ : UTxO
48-
certState : CertState
48+
rewards₀ : Rewards
4949
allScripts : ℙ Script
5050
isTopLevelValid : Bool
5151
@@ -211,6 +211,7 @@ private variable
211211
treasury : Treasury
212212
isTopLevelValid : Bool
213213
allScripts : ℙ Script
214+
rewards₀ : Rewards
214215
```
215216
-->
216217

@@ -278,16 +279,16 @@ data _⊢_⇀⦇_,SUBLEDGER⦈_ : SubLedgerEnv → LedgerState → SubLevelTx
278279
SUBLEDGER-V :
279280
∙ isTopLevelValid ≡ true
280281
∙ ⟦ slot , pp , treasury , utxo₀ , certState , allScripts , isTopLevelValid ⟧ ⊢ utxoState₀ ⇀⦇ stx ,SUBUTXOW⦈ utxoState₁
281-
∙ ⟦ epoch slot , pp , ListOfGovVotesOf stx , allColdCreds govState₀ enactState , WithdrawalsOf stx , DirectDepositsOf stx ⟧ ⊢ certState₀ ⇀⦇ DCertsOf stx ,ENTITIES⦈ certState₁
282+
∙ ⟦ epoch slot , pp , allColdCreds govState₀ enactState , rewards₀ ⟧ ⊢ certState₀ ⇀⦇ stx ,SUBENTITIES⦈ certState₁
282283
∙ ⟦ TxIdOf stx , epoch slot , pp , ppolicy , enactState , certState₁ , dom (RewardsOf certState₁) ⟧ ⊢ govState₀ ⇀⦇ GovProposals+Votes stx ,GOVS⦈ govState₁
283284
────────────────────────────────
284-
⟦ slot , ppolicy , pp , enactState , treasury , utxo₀ , certState , allScripts , isTopLevelValid ⟧ ⊢ ⟦ utxoState₀ , govState₀ , certState₀ ⟧ ⇀⦇ stx ,SUBLEDGER⦈ ⟦ utxoState₁ , govState₁ , certState₁ ⟧
285+
⟦ slot , ppolicy , pp , enactState , treasury , utxo₀ , rewards₀ , allScripts , isTopLevelValid ⟧ ⊢ ⟦ utxoState₀ , govState₀ , certState₀ ⟧ ⇀⦇ stx ,SUBLEDGER⦈ ⟦ utxoState₁ , govState₁ , certState₁ ⟧
285286
286287
SUBLEDGER-I :
287288
∙ isTopLevelValid ≡ false
288289
∙ ⟦ slot , pp , treasury , utxo₀ , certState , allScripts , isTopLevelValid ⟧ ⊢ utxoState₀ ⇀⦇ stx ,SUBUTXOW⦈ utxoState₀
289290
────────────────────────────────
290-
⟦ slot , ppolicy , pp , enactState , treasury , utxo₀ , certState , allScripts , isTopLevelValid ⟧ ⊢ ⟦ utxoState₀ , govState₀ , certState₀ ⟧ ⇀⦇ stx ,SUBLEDGER⦈ ⟦ utxoState₀ , govState₀ , certState₀ ⟧
291+
⟦ slot , ppolicy , pp , enactState , treasury , utxo₀ , rewards₀ , allScripts , isTopLevelValid ⟧ ⊢ ⟦ utxoState₀ , govState₀ , certState₀ ⟧ ⇀⦇ stx ,SUBLEDGER⦈ ⟦ utxoState₀ , govState₀ , certState₀ ⟧
291292
292293
_⊢_⇀⦇_,SUBLEDGERS⦈_ : SubLedgerEnv → LedgerState → List SubLevelTx → LedgerState → Type
293294
_⊢_⇀⦇_,SUBLEDGERS⦈_ = ReflexiveTransitiveClosure {sts = _⊢_⇀⦇_,SUBLEDGER⦈_}
@@ -299,12 +300,15 @@ data _⊢_⇀⦇_,LEDGER⦈_ : LedgerEnv → LedgerState → TopLevelTx → Ledg
299300
let utxo₀ : UTxO
300301
utxo₀ = UTxOOf utxoState₀
301302
303+
rewards₀ : Rewards
304+
rewards₀ = RewardsOf certState₀
305+
302306
allScripts : ℙ Script
303307
allScripts = getAllScripts tx utxo₀
304308
in
305309
∙ IsValidFlagOf tx ≡ true
306-
∙ ⟦ slot , ppolicy , pp , enactState , treasury , utxo₀ , certState₀ , allScripts , IsValidFlagOf tx ⟧ ⊢ ⟦ utxoState₀ , govState₀ , certState₀ ⟧ ⇀⦇ SubTransactionsOf tx ,SUBLEDGERS⦈ ⟦ utxoState₁ , govState₁ , certState₁ ⟧
307-
∙ ⟦ epoch slot , pp , ListOfGovVotesOf tx , allColdCreds govState₁ enactState , WithdrawalsOf tx , DirectDepositsOf tx ⟧ ⊢ certState₁ ⇀⦇ DCertsOf tx ,ENTITIES⦈ certState₂
310+
∙ ⟦ slot , ppolicy , pp , enactState , treasury , utxo₀ , rewards₀ , allScripts , IsValidFlagOf tx ⟧ ⊢ ⟦ utxoState₀ , govState₀ , certState₀ ⟧ ⇀⦇ SubTransactionsOf tx ,SUBLEDGERS⦈ ⟦ utxoState₁ , govState₁ , certState₁ ⟧
311+
∙ ⟦ epoch slot , pp , allColdCreds govState₁ enactState , true , rewards₀ ⟧ ⊢ certState₁ ⇀⦇ tx ,ENTITIES⦈ certState₂
308312
∙ ⟦ TxIdOf tx , epoch slot , pp , ppolicy , enactState , certState₂ , dom (RewardsOf certState₂) ⟧ ⊢ govState₁ ⇀⦇ GovProposals+Votes tx ,GOVS⦈ govState₂
309313
∙ ⟦ slot , pp , treasury , utxo₀ , certState₀ , allScripts ⟧ ⊢ utxoState₁ ⇀⦇ tx ,UTXOW⦈ utxoState₂
310314
────────────────────────────────
@@ -314,11 +318,14 @@ data _⊢_⇀⦇_,LEDGER⦈_ : LedgerEnv → LedgerState → TopLevelTx → Ledg
314318
let utxo₀ : UTxO
315319
utxo₀ = UTxOOf utxoState₀
316320
321+
rewards₀ : Rewards
322+
rewards₀ = RewardsOf certState₀
323+
317324
allScripts : ℙ Script
318325
allScripts = getAllScripts tx utxo₀
319326
in
320327
∙ IsValidFlagOf tx ≡ false
321-
∙ ⟦ slot , ppolicy , pp , enactState , treasury , utxo₀ , certState₀ , allScripts , IsValidFlagOf tx ⟧ ⊢ ⟦ utxoState₀ , govState₀ , certState₀ ⟧ ⇀⦇ SubTransactionsOf tx ,SUBLEDGERS⦈ ⟦ utxoState₀ , govState₀ , certState₀ ⟧
328+
∙ ⟦ slot , ppolicy , pp , enactState , treasury , utxo₀ , rewards₀ , allScripts , IsValidFlagOf tx ⟧ ⊢ ⟦ utxoState₀ , govState₀ , certState₀ ⟧ ⇀⦇ SubTransactionsOf tx ,SUBLEDGERS⦈ ⟦ utxoState₀ , govState₀ , certState₀ ⟧
322329
∙ ⟦ slot , pp , treasury , utxo₀ , certState₀ , allScripts ⟧ ⊢ utxoState₀ ⇀⦇ tx ,UTXOW⦈ utxoState₁
323330
────────────────────────────────
324331
⟦ slot , ppolicy , pp , enactState , treasury ⟧ ⊢ ⟦ utxoState₀ , govState₀ , certState₀ ⟧ ⇀⦇ tx ,LEDGER⦈ ⟦ utxoState₁ , govState₀ , certState₀ ⟧

0 commit comments

Comments
 (0)