-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathNewPP.lagda
More file actions
66 lines (56 loc) · 1.87 KB
/
NewPP.lagda
File metadata and controls
66 lines (56 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
\section{Protocol Parameters Update}
\begin{code}[hide]
{-# OPTIONS --safe #-}
open import Relation.Nullary.Decidable
open import Ledger.Prelude
open import Ledger.Transaction
module Ledger.NewPP (txs : _) (open TransactionStructure txs) where
open import Ledger.PPUp txs
record NewPParamEnv : Type where
-- field
\end{code}
\begin{figure*}[h]
\begin{AgdaMultiCode}
\begin{code}
record NewPParamState : Type where
constructor ⟦_,_⟧ⁿᵖ
field
pparams : PParams
ppup : PPUpdateState
updatePPUp : PParams → PPUpdateState → PPUpdateState
updatePPUp pparams record { fpup = fpup }
with allᵇ ¿ isViableUpdate pparams ¿¹ (range fpup)
... | false = record { pup = ∅ᵐ ; fpup = ∅ᵐ }
... | true = record { pup = fpup ; fpup = ∅ᵐ }
votedValue : ProposedPPUpdates → PParams → ℕ → Maybe PParamsUpdate
votedValue pup pparams quorum =
case any? (λ u → lengthˢ (pup ∣^ fromList [ u ]) ≥? quorum) (range pup) of
\end{code}
\begin{code}[hide]
λ where
\end{code}
\begin{code}
(no _) → nothing
(yes (u , _)) → just u
\end{code}
\end{AgdaMultiCode}
\caption{Types and functions for the NEWPP transition system}
\end{figure*}
\begin{code}[hide]
private variable
Γ : NewPParamEnv
s s' : NewPParamState
upd : PParamsUpdate
data _⊢_⇀⦇_,NEWPP⦈_ : NewPParamEnv → NewPParamState → Maybe PParamsUpdate → NewPParamState → Type where
\end{code}
\begin{figure*}[h]
\begin{code}
NEWPP-Accept : ∀ {Γ} → let open NewPParamState s; newpp = applyUpdate pparams upd in
viablePParams newpp
────────────────────────────────
Γ ⊢ s ⇀⦇ just upd ,NEWPP⦈ ⟦ newpp , updatePPUp newpp ppup ⟧ⁿᵖ
NEWPP-Reject : ∀ {Γ} →
Γ ⊢ s ⇀⦇ nothing ,NEWPP⦈ s
\end{code}
\caption{NEWPP transition system}
\end{figure*}