@@ -36,10 +36,6 @@ open GovActionState
3636open Inverse
3737
3838private
39- lookupActionId : (pparams : PParams) (role : GovRole) (aid : GovActionID) (s : GovState) →
40- Dec (Any (λ (aid' , ast) → aid ≡ aid' × canVote pparams (action ast) role) s)
41- lookupActionId pparams role aid = any? λ _ → ¿ _ ¿
42-
4339 isUpdateCommittee : (a : GovAction) → Dec (∃[ new ] ∃[ rem ] ∃[ q ] a ≡ UpdateCommittee new rem q)
4440 isUpdateCommittee NoConfidence = no λ ()
4541 isUpdateCommittee (UpdateCommittee new rem q) = yes (new , rem , q , refl)
@@ -97,16 +93,16 @@ instance
9793 module GoVote sig where
9894 open GovVote sig
9995
100- computeProof = case lookupActionId pparams (proj₁ voter) gid s ,′ isRegistered? (proj₁ Γ) voter of λ where
96+ computeProof = case L. lookupActionId pparams (proj₁ voter) gid epoch s ,′ isRegistered? (proj₁ Γ) voter of λ where
10197 (yes p , yes p') → case Any↔ .from p of λ where
102- (_ , mem , refl , cV) → success (_ , GOV-Vote (∈-fromList .to mem , cV , p'))
98+ (_ , mem , refl , cV , ¬exp ) → success (_ , GOV-Vote (∈-fromList .to mem , cV , p' , ¬exp ))
10399 (yes _ , no ¬p) → failure (genErrors ¬p)
104100 (no ¬p , _) → failure (genErrors ¬p)
105101
106102 completeness : ∀ s' → Γ ⊢ s ⇀⦇ inj₁ sig ,GOV'⦈ s' → map proj₁ computeProof ≡ success s'
107- completeness s' (GOV-Vote (mem , cV , reg))
108- with lookupActionId pparams (proj₁ voter) gid s | isRegistered? (proj₁ Γ) voter
109- ... | no ¬p | _ = ⊥-elim (¬p (Any↔ .to (_ , ∈-fromList .from mem , refl , cV)))
103+ completeness s' (GOV-Vote (mem , cV , reg , ¬exp ))
104+ with L. lookupActionId pparams (proj₁ voter) gid epoch s | isRegistered? (proj₁ Γ) voter
105+ ... | no ¬p | _ = ⊥-elim (¬p (Any↔ .to (_ , ∈-fromList .from mem , refl , cV , ¬exp )))
110106 ... | yes _ | no ¬p = ⊥-elim $ ¬p reg
111107 ... | yes p | yes p' with Any↔ .from p
112108 ... | (_ , mem , refl , cV) = refl
@@ -118,40 +114,55 @@ instance
118114
119115 instance
120116 Dec-actionWellFormed = L.actionWellFormed?
117+ Dec-actionValid = L.actionValid?
121118 {-# INCOHERENT Dec-actionWellFormed #-}
119+ {-# INCOHERENT Dec-actionValid #-}
122120
123- H = ¿ L.actionWellFormed rewardCreds p ppolicy epoch a
121+ H = ¿ L.actionWellFormed a
122+ × L.actionValid rewardCreds p ppolicy epoch a
124123 × d ≡ govActionDeposit
125124 × L.validHFAction prop s enactState
126125 × L.hasParent' enactState s a prev
127- × addr .RwdAddr.net ≡ NetworkId ¿
126+ × addr .RwdAddr.net ≡ NetworkId
127+ × addr .RwdAddr.stake ∈ rewardCreds ¿
128128 ,′ isUpdateCommittee a
129129
130- genErrorsWellFormed : ∀ {a} → ¬ (L.actionWellFormed rewardCreds p ppolicy epoch a) → String
131- genErrorsWellFormed {NoConfidence} ¬p = genErrors ¬p
132- genErrorsWellFormed {UpdateCommittee _ _ _} ¬p = genErrors ¬p
133- genErrorsWellFormed {NewConstitution _ _} ¬p = genErrors ¬p
134- genErrorsWellFormed {TriggerHF _} ¬p = genErrors ¬p
135- genErrorsWellFormed {ChangePParams _} ¬p = genErrors ¬p
136- genErrorsWellFormed {TreasuryWdrl _} ¬p = genErrors ¬p
137- genErrorsWellFormed {Info} ¬p = genErrors ¬p
130+ genErrorsActionWellFormed : ∀ {a} → ¬ (L.actionWellFormed a) → String
131+ genErrorsActionWellFormed {NoConfidence} ¬p = genErrors ¬p
132+ genErrorsActionWellFormed {UpdateCommittee _ _ _} ¬p = genErrors ¬p
133+ genErrorsActionWellFormed {NewConstitution _ _} ¬p = genErrors ¬p
134+ genErrorsActionWellFormed {TriggerHF _} ¬p = genErrors ¬p
135+ genErrorsActionWellFormed {ChangePParams _} ¬p = genErrors ¬p
136+ genErrorsActionWellFormed {TreasuryWdrl _} ¬p = genErrors ¬p
137+ genErrorsActionWellFormed {Info} ¬p = genErrors ¬p
138+
139+ genErrorsActionValid : ∀ {a} → ¬ (L.actionValid rewardCreds p ppolicy epoch a) → String
140+ genErrorsActionValid {NoConfidence} ¬p = genErrors ¬p
141+ genErrorsActionValid {UpdateCommittee _ _ _} ¬p = genErrors ¬p
142+ genErrorsActionValid {NewConstitution _ _} ¬p = genErrors ¬p
143+ genErrorsActionValid {TriggerHF _} ¬p = genErrors ¬p
144+ genErrorsActionValid {ChangePParams _} ¬p = genErrors ¬p
145+ genErrorsActionValid {TreasuryWdrl _} ¬p = genErrors ¬p
146+ genErrorsActionValid {Info} ¬p = genErrors ¬p
138147
139148 computeProof = case H of λ where
140- (yes (wf , dep , vHFA , L.HasParent' en , goodAddr) , yes (new , rem , q , refl)) →
149+ (yes (wf , av , dep , vHFA , L.HasParent' en , goodAddr , regReward ) , yes (new , rem , q , refl)) →
141150 case ¿ ∀[ e ∈ range new ] epoch < e × dom new ∩ rem ≡ᵉ ∅ ¿ of λ where
142- (yes newOk) → success (_ , GOV-Propose (wf , dep , vHFA , en , goodAddr))
151+ (yes newOk) → success (_ , GOV-Propose (wf , av , dep , vHFA , en , goodAddr , regReward ))
143152 (no ¬p) → failure (genErrors ¬p)
144- (yes (wf , dep , vHFA , L.HasParent' en , goodAddr) , no notNewComm) → success
145- (-, GOV-Propose (wf , dep , vHFA , en , goodAddr))
153+ (yes (wf , av , dep , vHFA , L.HasParent' en , goodAddr) , no notNewComm) → success
154+ (-, GOV-Propose (wf , av , dep , vHFA , en , goodAddr))
146155 (no ¬p , _) → case dec-de-morgan ¬p of λ where
147- (inj₁ q) → failure (genErrorsWellFormed q)
148- (inj₂ q) → failure (genErrors q)
156+ (inj₁ q) → failure (genErrorsActionWellFormed q)
157+ (inj₂ q) → case dec-de-morgan q of λ where
158+ (inj₁ r) → failure (genErrorsActionValid r)
159+ (inj₂ r) → failure (genErrors r)
149160
150161 completeness : ∀ s' → Γ ⊢ s ⇀⦇ inj₂ prop ,GOV'⦈ s' → map proj₁ computeProof ≡ success s'
151- completeness s' (GOV-Propose (wf , dep , vHFA , en , goodAddr)) with H
152- ... | (no ¬p , _) = ⊥-elim (¬p (wf , dep , vHFA , L.HasParent' en , goodAddr))
153- ... | (yes (_ , _ , _ , L.HasParent' _ , _) , no notNewComm) = refl
154- ... | (yes ((_ , allOk) , _ , _ , L.HasParent' _ , _) , yes (new , rem , q , refl))
162+ completeness s' (GOV-Propose (wf , av , dep , vHFA , en , goodAddr)) with H
163+ ... | (no ¬p , _) = ⊥-elim (¬p (wf , av , dep , vHFA , L.HasParent' en , goodAddr))
164+ ... | (yes (_ , _ , _ , _ , L.HasParent' _ , _) , no notNewComm) = refl
165+ ... | (yes (_ , (_ , allOk) , _ , _ , L.HasParent' _ , _) , yes (new , rem , q , refl))
155166 rewrite dec-yes ¿ ∀[ e ∈ range new ] epoch < e × dom new ∩ rem ≡ᵉ ∅ ¿ allOk .proj₂ = refl
156167
157168 computeProof : (sig : GovVote ⊎ GovProposal) → _
0 commit comments