Skip to content

Commit 58e1771

Browse files
Merge pull request #953 from IntersectMBO/fd/fpoolparams
Implement fPoolParams as in the Shelley specification
2 parents a3942cb + d524478 commit 58e1771

File tree

7 files changed

+48
-24
lines changed

7 files changed

+48
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Conway spec
44

55
### WIP
6-
6+
- Implement the fPoolParams field of PState as in the Shelley specification
77
- Add the BBODY transition relation from Shelley
88
- Add the RUPD and TICK transition relations
99
- Change two constructor names of `GovActionType` data type

src/Ledger/Conway/Conformance/Certs.agda

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private variable
7676
sDelegs stakeDelegs : Credential ⇀ KeyHash
7777
ccKeys ccHotKeys : Credential ⇀ Maybe Credential
7878
vDelegs voteDelegs : VoteDelegs
79-
pools : Pools
79+
pools fPools : Pools
8080
retiring : KeyHash ⇀ Epoch
8181
wdrls : Withdrawals
8282

@@ -110,12 +110,12 @@ data _⊢_⇀⦇_,POOL⦈_ where
110110
POOL-regpool :
111111
∙ kh ∉ dom pools
112112
────────────────────────────────
113-
pp ⊢ ⟦ pools , retiring ⟧ ⇀⦇ regpool kh poolParams ,POOL⦈
114-
⟦ ❴ kh , poolParams ❵ ∪ˡ pools , retiring ⟧
113+
pp ⊢ ⟦ pools , fPools , retiring ⟧ ⇀⦇ regpool kh poolParams ,POOL⦈
114+
⟦ ❴ kh , poolParams ❵ ∪ˡ pools , fPools , retiring ⟧
115115

116116
POOL-retirepool :
117117
────────────────────────────────
118-
pp ⊢ ⟦ pools , retiring ⟧ ⇀⦇ retirepool kh e ,POOL⦈ ⟦ pools , ❴ kh , e ❵ ∪ˡ retiring ⟧
118+
pp ⊢ ⟦ pools , fPools , retiring ⟧ ⇀⦇ retirepool kh e ,POOL⦈ ⟦ pools , fPools , ❴ kh , e ❵ ∪ˡ retiring ⟧
119119

120120
data _⊢_⇀⦇_,DELEG⦈_ where
121121
DELEG-delegate : let open PParams pp in

src/Ledger/Conway/Conformance/Epoch.agda

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,10 @@ data _⊢_⇀⦇_,EPOCH⦈_ : ⊤ → EpochState → Epoch → EpochState → Ty
133133
dState' = record dState { rewards = dState .rewards ∪⁺ refunds }
134134

135135
pState' : PState
136-
pState' = ⟦ (pState .pools) ∣ retired ᶜ , (pState .retiring) ∣ retired ᶜ ⟧
136+
pState' = ⟦ (pState .pools) ∣ retired ᶜ
137+
, (pState .fPools) ∣ retired ᶜ
138+
, (pState .retiring) ∣ retired ᶜ
139+
137140

138141
gState' : GState
139142
gState' = ⟦ (if null govSt' then mapValues (1 +_) (gState .dreps) else (gState .dreps))

src/Ledger/Conway/Specification/Certs.lagda.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ record DState : Type where
199199
record PState : Type where
200200
field
201201
pools : Pools
202+
fPools : Pools
202203
retiring : KeyHash ⇀ Epoch
203204
204205
record GState : Type where
@@ -337,7 +338,7 @@ private variable
337338
sDelegs stakeDelegs : StakeDelegs
338339
ccKeys ccHotKeys : CCHotKeys
339340
vDelegs voteDelegs : VoteDelegs
340-
pools : Pools
341+
pools fPools : Pools
341342
retiring : Retiring
342343
wdrls : Withdrawals
343344
@@ -474,11 +475,11 @@ data _⊢_⇀⦇_,POOL⦈_ : PoolEnv → PState → DCert → PState → Type wh
474475
POOL-regpool :
475476
∙ kh ∉ dom pools
476477
────────────────────────────────
477-
pp ⊢ ⟦ pools , retiring ⟧ ⇀⦇ regpool kh poolParams ,POOL⦈ ⟦ ❴ kh , poolParams ❵ ∪ˡ pools , retiring ⟧
478+
pp ⊢ ⟦ pools , fPools , retiring ⟧ ⇀⦇ regpool kh poolParams ,POOL⦈ ⟦ ❴ kh , poolParams ❵ ∪ˡ pools , fPools , retiring ⟧
478479
479480
POOL-retirepool :
480481
────────────────────────────────
481-
pp ⊢ ⟦ pools , retiring ⟧ ⇀⦇ retirepool kh e ,POOL⦈ ⟦ pools , ❴ kh , e ❵ ∪ˡ retiring ⟧
482+
pp ⊢ ⟦ pools , fPools , retiring ⟧ ⇀⦇ retirepool kh e ,POOL⦈ ⟦ pools , fPools , ❴ kh , e ❵ ∪ˡ retiring ⟧
482483
```
483484

484485

src/Ledger/Conway/Specification/Epoch.lagda.md

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ record NewEpochState : Type where
130130
In addition, the formal specification omits the VRF key hashes in the
131131
codomain of `PoolDelegatedStake`{.AgdaDatatype} as they are not implemented at
132132
the moment.
133-
133+
134134
<!--
135135
```agda
136136
record HasNewEpochState {a} (A : Type a) : Type a where
@@ -579,15 +579,17 @@ record EPOCH-Updates0 : Type where
579579
es : EnactState
580580
govSt' : GovState
581581
payout : Withdrawals
582+
pState' : PState
582583
gState' : GState
583584
utxoSt' : UTxOState
584585
totWithdrawals : Coin
585586
586587
EPOCH-updates0 : RatifyState → LState → EPOCH-Updates0
587588
EPOCH-updates0 fut ls =
588-
EPOCHUpdates0 es govSt' payout gState' utxoSt' totWithdrawals
589+
EPOCHUpdates0 es govSt' payout pState' gState' utxoSt' totWithdrawals
589590
where
590591
open LState ls public
592+
open PState
591593
open CertState certState using (gState) public
592594
open RatifyState fut renaming (es to esW)
593595
@@ -626,6 +628,12 @@ EPOCH-updates0 fut ls =
626628
, CCHotKeysOf gState ∣ ccCreds (EnactState.cc es)
627629
628630
631+
pState = PStateOf ls
632+
pState' = record pState
633+
{ pools = pState .fPools ∪ˡ pState .pools
634+
; fPools = ∅ᵐ
635+
}
636+
629637
utxoSt' : UTxOState
630638
utxoSt' = record utxoSt
631639
{ deposits = DepositsOf utxoSt ∣ mapˢ (proj₁ ∘ proj₂) removedGovActions ᶜ
@@ -641,14 +649,22 @@ record EPOCH-Updates : Type where
641649
es : EnactState
642650
govSt' : GovState
643651
dState'' : DState
652+
pState'' : PState
644653
gState' : GState
645654
utxoSt' : UTxOState
646655
acnt'' : Acnt
647656
648657
EPOCH-updates
649658
: RatifyState → LState → DState → Acnt → EPOCH-Updates
650659
EPOCH-updates fut ls dState' acnt' =
651-
EPOCHUpdates (u0 .es) (u0 .govSt') dState'' (u0 .gState') (u0 .utxoSt') acnt''
660+
EPOCHUpdates
661+
(u0 .es)
662+
(u0 .govSt')
663+
dState''
664+
(u0 .pState')
665+
(u0 .gState')
666+
(u0 .utxoSt')
667+
acnt''
652668
where
653669
open LState
654670
open EPOCH-Updates0
@@ -673,7 +689,7 @@ EPOCH-updates fut ls dState' acnt' =
673689

674690
### Transition Rule
675691

676-
This section defines the `EPOCH`{.AgdaDatatype} transition rule.
692+
This section defines the `EPOCH`{.AgdaDatatype} transition rule.
677693

678694
In Conway, the `EPOCH`{.AgdaDatatype} rule invokes `RATIFIES`{.AgdaDatatype},
679695
and carries out the following tasks:
@@ -700,12 +716,12 @@ data _⊢_⇀⦇_,EPOCH⦈_ : ⊤ → EpochState → Epoch → EpochState → Ty
700716
```
701717
<!--
702718
```agda
703-
∀ {acnt : Acnt} {utxoSt'' : UTxOState} {acnt' dState' pState'} →
719+
∀ {acnt : Acnt} {utxoSt'' : UTxOState} {acnt' dState' pState''} →
704720
```
705721
-->
706722
```agda
707723
let
708-
EPOCHUpdates es govSt' dState'' gState' utxoSt' acnt'' =
724+
EPOCHUpdates es govSt' dState'' pState' gState' utxoSt' acnt'' =
709725
EPOCH-updates fut ls dState' acnt'
710726
711727
stakeDistrs : StakeDistrs
@@ -718,9 +734,9 @@ data _⊢_⇀⦇_,EPOCH⦈_ : ⊤ → EpochState → Epoch → EpochState → Ty
718734
in
719735
ls ⊢ ss ⇀⦇ tt ,SNAP⦈ ss'
720736
∙ Γ ⊢ ⟦ es , ∅ , false ⟧ ⇀⦇ govSt' ,RATIFIES⦈ fut'
721-
∙ _ ⊢ ⟦ utxoSt' , acnt , DStateOf ls , PStateOf ls ⟧ ⇀⦇ e ,POOLREAP⦈ ⟦ utxoSt'' , acnt' , dState' , pState' ⟧
737+
∙ _ ⊢ ⟦ utxoSt' , acnt , DStateOf ls , pState' ⟧ ⇀⦇ e ,POOLREAP⦈ ⟦ utxoSt'' , acnt' , dState' , pState'' ⟧
722738
──────────────────────────────────────────────
723-
_ ⊢ ⟦ acnt , ss , ls , es₀ , fut ⟧ ⇀⦇ e ,EPOCH⦈ ⟦ acnt'' , ss' , ⟦ utxoSt'' , govSt' , ⟦ dState'' , pState' , gState' ⟧ᶜˢ ⟧ , es , fut' ⟧
739+
_ ⊢ ⟦ acnt , ss , ls , es₀ , fut ⟧ ⇀⦇ e ,EPOCH⦈ ⟦ acnt'' , ss' , ⟦ utxoSt'' , govSt' , ⟦ dState'' , pState'' , gState' ⟧ᶜˢ ⟧ , es , fut' ⟧
724740
```
725741

726742
## <span class="AgdaDatatype">NEWEPOCH</span> Transition System {#newepoch-transition-system}

src/Ledger/Conway/Specification/Epoch/Properties/Computational.agda

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ module _ {eps : EpochState} {e : Epoch} where
5555

5656
open EpochState eps hiding (es)
5757

58-
prs = ⟦ u0 .utxoSt' , acnt , cs .dState , cs .pState ⟧
58+
prs = ⟦ u0 .utxoSt' , acnt , cs .dState , u0 .pState'
5959
where
6060
open LState
6161
open CertState
@@ -72,11 +72,11 @@ module _ {eps : EpochState} {e : Epoch} where
7272

7373
private
7474
EPOCH-state : Snapshots RatifyState PoolReapState EpochState
75-
EPOCH-state ss fut' (⟦ utxoSt'' , acnt' , dState' , pState' ⟧ᵖ) =
75+
EPOCH-state ss fut' (⟦ utxoSt'' , acnt' , dState' , pState'' ⟧ᵖ) =
7676
let
77-
EPOCHUpdates es govSt' dState'' gState' _ acnt'' =
77+
EPOCHUpdates es govSt' dState'' _ gState' _ acnt'' =
7878
EPOCH-updates fut ls dState' acnt'
79-
certState' = ⟦ dState'' , pState' , gState' ⟧ᶜˢ
79+
certState' = ⟦ dState'' , pState'' , gState' ⟧ᶜˢ
8080
in
8181
record
8282
{ acnt = acnt''
@@ -97,14 +97,14 @@ module _ {eps : EpochState} {e : Epoch} where
9797
{utxoSt'' = utxoSt''₁}
9898
{acnt' = acnt'₁}
9999
{dState' = dState'₁}
100-
{pState' = pState'₁}
100+
{pState'' = pState'₁}
101101
(p₁ , p₂ , p₃)
102102
)
103103
(EPOCH
104104
{utxoSt'' = utxoSt''₂}
105105
{acnt' = acnt'₂}
106106
{dState' = dState'₂}
107-
{pState' = pState'₂}
107+
{pState'' = pState'₂}
108108
(p₁' , p₂' , p₃')
109109
) =
110110
cong₂ _$_ (cong₂ EPOCH-state ss'≡ss'' fut'≡fut'') prs'≡prs''

src/Ledger/Conway/Specification/PoolReap.lagda.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ data
8787
, dState .rewards ∪⁺ refunds
8888
8989
90-
pState' = ⟦ pState .pools ∣ retired ᶜ , pState .retiring ∣ retired ᶜ ⟧
90+
pState' =
91+
⟦ pState .pools ∣ retired ᶜ
92+
, pState .fPools ∣ retired ᶜ
93+
, pState .retiring ∣ retired ᶜ
94+
9195
9296
in
9397
────────────────────────────────

0 commit comments

Comments
 (0)