Skip to content

Commit 1f2bbd6

Browse files
Move SNAP to section "Rewards" (#771)
* Move `Snapshot`, `stakeDistr` and `SNAP` to Section "Rewards" * Add overview and illustration of the Reward Cycle
1 parent 220284a commit 1f2bbd6

File tree

3 files changed

+392
-53
lines changed

3 files changed

+392
-53
lines changed

src/Ledger/Epoch.lagda

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,14 @@ open import Ledger.Enact govStructure
3232
open import Ledger.Gov txs
3333
open import Ledger.Ledger txs abs
3434
open import Ledger.Ratify txs
35-
open import Ledger.Rewards govStructure
35+
open import Ledger.Rewards txs abs
3636
open import Ledger.Utxo txs abs
3737

3838
\end{code}
3939
\begin{figure*}[ht]
4040
\begin{AgdaMultiCode}
41-
\begin{NoConway}
4241
\begin{code}
43-
record Snapshot : Set where
44-
field
45-
stake : Credential ⇀ Coin
46-
delegations : Credential ⇀ KeyHash
47-
poolParameters : KeyHash ⇀ PoolParams
48-
49-
record Snapshots : Set where
50-
field
51-
mark set go : Snapshot
52-
feeSS : Coin
5342

54-
\end{code}
55-
\end{NoConway}
56-
\begin{code}
5743
record EpochState : Type where
5844
\end{code}
5945
\begin{code}[hide]
@@ -66,6 +52,7 @@ record EpochState : Type where
6652
ls : LState
6753
es : EnactState
6854
fut : RatifyState
55+
6956
\end{code}
7057
\begin{code}[hide]
7158
record HasEpochState {a} (A : Type a) : Type a where
@@ -130,10 +117,8 @@ instance
130117
HasRewards-NewEpochState : HasRewards NewEpochState
131118
HasRewards-NewEpochState .RewardsOf = RewardsOf ∘ CertStateOf
132119

133-
unquoteDecl HasCast-RewardUpdate HasCast-Snapshot HasCast-Snapshots HasCast-EpochState HasCast-NewEpochState = derive-HasCast
120+
unquoteDecl HasCast-RewardUpdate HasCast-EpochState HasCast-NewEpochState = derive-HasCast
134121
( (quote RewardUpdate , HasCast-RewardUpdate)
135-
∷ (quote Snapshot , HasCast-Snapshot)
136-
∷ (quote Snapshots , HasCast-Snapshots)
137122
∷ (quote EpochState , HasCast-EpochState)
138123
∷ [ (quote NewEpochState , HasCast-NewEpochState)])
139124

@@ -274,15 +259,6 @@ getOrphans es govSt = proj₁ $ iterate step ([] , govSt) (length govSt)
274259
open RwdAddr using (stake)
275260
\end{code}
276261
\begin{code}
277-
stakeDistr : UTxO → DState → PState → Snapshot
278-
stakeDistr utxo stᵈ pState =
279-
⟦ aggregate₊ (stakeRelation ᶠˢ) , stakeDelegs , poolParams ⟧
280-
where
281-
poolParams = pState .PState.pools
282-
open DState stᵈ using (stakeDelegs; rewards)
283-
m = mapˢ (λ a → (a , cbalance (utxo ∣^' λ i → getStakeCred i ≡ just a))) (dom rewards)
284-
stakeRelation = m ∪ ∣ rewards ∣
285-
286262
gaDepositStake : GovState → Deposits → Credential ⇀ Coin
287263
gaDepositStake govSt ds = aggregateBy
288264
(mapˢ (λ (gaid , addr) → (gaid , addr) , stake addr) govSt')
@@ -323,12 +299,6 @@ private variable
323299
\begin{NoConway}
324300
\begin{figure*}[h]
325301
\begin{code}
326-
data _⊢_⇀⦇_,SNAP⦈_ : LState → Snapshots → ⊤ → Snapshots → Type where
327-
SNAP : let open LState lstate; open UTxOState utxoSt; open CertState certState
328-
stake = stakeDistr utxo dState pState
329-
in
330-
lstate ⊢ ⟦ mark , set , go , feeSS ⟧ ⇀⦇ tt ,SNAP⦈ ⟦ stake , mark , set , fees ⟧
331-
332302
data _⊢_⇀⦇_,EPOCH⦈_ : ⊤ → EpochState → Epoch → EpochState → Type where
333303
\end{code}
334304
\end{figure*}

src/Ledger/Epoch/Properties.agda

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ open import Ledger.Epoch txs abs
1616
open import Ledger.Ledger txs abs
1717
open import Ledger.Ratify txs
1818
open import Ledger.Ratify.Properties txs
19+
open import Ledger.Rewards txs abs
1920

2021
open import Data.List using (filter)
2122
import Relation.Binary.PropositionalEquality as PE

0 commit comments

Comments
 (0)