diff --git a/src/Ledger/Conway/Conformance/Properties.agda b/src/Ledger/Conway/Conformance/Properties.agda index b5d0cf224..81ae8a04d 100644 --- a/src/Ledger/Conway/Conformance/Properties.agda +++ b/src/Ledger/Conway/Conformance/Properties.agda @@ -48,9 +48,6 @@ getRewards = DState.rewards ∘ CertState.dState ∘ LState.certState ∘ getLSt allDReps : NewEpochState → DReps allDReps = GState.dreps ∘ CertState.gState ∘ LState.certState ∘ getLState -activeDReps : Epoch → NewEpochState → ℙ Credential -activeDReps currentEpoch s = dom (filterᵐ (λ (_ , e) → currentEpoch ≤ e) (allDReps s)) - getGovState : NewEpochState → GovState getGovState = LState.govSt ∘ getLState diff --git a/src/Ledger/Conway/Specification/Certs.lagda.md b/src/Ledger/Conway/Specification/Certs.lagda.md index e3fc393fe..47a3c1393 100644 --- a/src/Ledger/Conway/Specification/Certs.lagda.md +++ b/src/Ledger/Conway/Specification/Certs.lagda.md @@ -67,9 +67,6 @@ instance CCHotKeys : Type CCHotKeys = Credential ⇀ Maybe Credential -DReps : Type -DReps = Credential ⇀ Epoch - PoolEnv : Type PoolEnv = PParams @@ -94,9 +91,6 @@ StakeDelegs = Credential ⇀ KeyHash record HasCCHotKeys {a} (A : Type a) : Type a where field CCHotKeysOf : A → CCHotKeys -record HasDReps {a} (A : Type a) : Type a where - field DRepsOf : A → DReps - record HasPools {a} (A : Type a) : Type a where field PoolsOf : A → Pools @@ -113,7 +107,6 @@ record HasStakeDelegs {a} (A : Type a) : Type a where field StakeDelegsOf : A -> StakeDelegs open HasCCHotKeys ⦃...⦄ public -open HasDReps ⦃...⦄ public open HasPools ⦃...⦄ public open HasRetiring ⦃...⦄ public open HasRewards ⦃...⦄ public @@ -125,6 +118,7 @@ open HasStakeDelegs ⦃...⦄ public ## Delegation Definitions + ```agda data DCert : Type where delegate : Credential → Maybe VDeleg → Maybe KeyHash → Coin → DCert diff --git a/src/Ledger/Conway/Specification/Enact.lagda.md b/src/Ledger/Conway/Specification/Enact.lagda.md index 476867e3e..2e96dda4d 100644 --- a/src/Ledger/Conway/Specification/Enact.lagda.md +++ b/src/Ledger/Conway/Specification/Enact.lagda.md @@ -84,6 +84,9 @@ ccCreds : HashProtected (Maybe ((Credential ⇀ Epoch) × ℚ)) → ℙ Credenti ccCreds (just x , _) = dom (x .proj₁) ccCreds (nothing , _) = ∅ +ℚof? : HashProtected (Maybe ((Credential ⇀ Epoch) × ℚ)) → Maybe ℚ +ℚof? cc' = proj₂ <$> (proj₁ cc') + getHash : ∀ {a} → NeedsHash a → Maybe GovActionID getHash {NoConfidence} h = just h getHash {UpdateCommittee} h = just h diff --git a/src/Ledger/Conway/Specification/Epoch.lagda.md b/src/Ledger/Conway/Specification/Epoch.lagda.md index 79242c380..c9d556d89 100644 --- a/src/Ledger/Conway/Specification/Epoch.lagda.md +++ b/src/Ledger/Conway/Specification/Epoch.lagda.md @@ -461,31 +461,21 @@ module VDelegDelegatedStake (gState : GState) (dState : DState) where -``` - -```agda - -- active DReps + activeDReps : ℙ Credential - activeDReps = dom (filterᵐ (λ (_ , e) → currentEpoch ≤ e) dreps) + activeDReps = dom (DRepsOf gState ∣ currentEpoch ≤Expiry) - -- active vote delegations activeVDelegs : ℙ VDeleg activeVDelegs = mapˢ vDelegCredential activeDReps ∪ ❴ vDelegNoConfidence ❵ ∪ ❴ vDelegAbstain ❵ -- compute the stake for a credential stakePerCredential : Credential → Coin - stakePerCredential c = cbalance (utxo ∣^' λ txout → getStakeCred txout ≡ just c) + stakePerCredential c = cbalance ((UTxOOf utxoSt) ∣^' λ txout → getStakeCred txout ≡ just c) + fromMaybe 0 (lookupᵐ? (stakeFromGADeposits govSt utxoSt) c) + fromMaybe 0 (lookupᵐ? (RewardsOf dState) c) calculate : VDeleg ⇀ Coin - calculate = mapFromFun (λ vd → ∑ˢ[ c ← voteDelegs ⁻¹ vd ] (stakePerCredential c)) + calculate = mapFromFun (λ vd → ∑ˢ[ c ← (VoteDelegsOf dState) ⁻¹ vd ] (stakePerCredential c)) activeVDelegs ``` @@ -441,3 +442,27 @@ proposedCC ⟦ UpdateCommittee , (x , _ , _) ⟧ᵍᵃ = dom x proposedCC _ = ∅ ``` +```agda +DReps : Type +DReps = Credential ⇀ Epoch +``` + + + +The following function takes a type `A`{.AgdaDatatype} with an associated set of +`DReps`{.AgdaDatatype}, and an epoch `e`{.AgdaBound}, and returns the +`DReps`{.AgdaDatatype} of `A`{.AgdaDatatype} that expire in epoch `e`{.AgdaBound} or +later. + +```agda + DRepsOf_∣_≤Expiry : {A : Type} ⦃ _ : HasDReps A ⦄ → A → Epoch → DReps + DRepsOf a ∣ e ≤Expiry = filterᵐ (λ (_ , expEpoch) → e ≤ expEpoch) (DRepsOf a) +``` diff --git a/src/Ledger/Conway/Specification/Properties.lagda.md b/src/Ledger/Conway/Specification/Properties.lagda.md index 7bd6debf8..3f8d09795 100644 --- a/src/Ledger/Conway/Specification/Properties.lagda.md +++ b/src/Ledger/Conway/Specification/Properties.lagda.md @@ -74,16 +74,7 @@ instance isGADeposit? {PoolDeposit x} = ⁇ (no λ ()) isGADeposit? {DRepDeposit x} = ⁇ (no λ ()) isGADeposit? {GovActionDeposit x} = ⁇ (yes tt) -``` ---> -```agda -activeDReps : Epoch → NewEpochState → ℙ Credential -activeDReps currentEpoch s = dom (filterᵐ (λ (_ , e) → currentEpoch ≤ e) (DRepsOf s)) -``` - -