Skip to content

Commit

Permalink
Added SPO voting thresholds for security relevant parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Soupstraw committed Jan 11, 2024
1 parent 4cbd804 commit 04ab57b
Show file tree
Hide file tree
Showing 11 changed files with 395 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ import Cardano.Crypto.Hash (Hash)
import Cardano.Ledger.Alonzo (AlonzoEra)
import Cardano.Ledger.Alonzo.PParams (AlonzoEraPParams, ppMaxValSizeL)
import Cardano.Ledger.Coin (Coin)
import Cardano.Ledger.Core (EraIndependentTxBody, EraTxOut)
import Cardano.Ledger.Core (EraIndependentTxBody)
import Cardano.Ledger.Crypto (Crypto (..))
import Cardano.Ledger.Shelley.Core (EraGov)
import Cardano.Ledger.Shelley.LedgerState (
NewEpochState,
StashedAVVMAddresses,
Expand All @@ -29,10 +28,9 @@ import Test.Cardano.Ledger.Common
import Test.Cardano.Ledger.Shelley.ImpTest as ImpTest

emptyAlonzoImpNES ::
( EraGov era
, EraTxOut era
, AlonzoEraPParams era
( AlonzoEraPParams era
, Default (StashedAVVMAddresses era)
, ShelleyEraImp era
) =>
Coin ->
NewEpochState era
Expand Down
1 change: 1 addition & 0 deletions eras/conway/impl/cddl-files/conway.cddl
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ pool_voting_thresholds =
, unit_interval ; committee normal
, unit_interval ; committee no confidence
, unit_interval ; hard fork initiation
, unit_interval ; security relevant parameter voting threshold
]

drep_voting_thresholds =
Expand Down
17 changes: 14 additions & 3 deletions eras/conway/impl/src/Cardano/Ledger/Conway/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ import Cardano.Ledger.Conway.PParams (
ConwayEraPParams (..),
DRepVotingThresholds (..),
PPGroup (..),
ParameterInfo (..),
PoolVotingThresholds (..),
Security (..),
dvtPPEconomicGroupL,
dvtPPGovGroupL,
dvtPPNetworkGroupL,
Expand Down Expand Up @@ -675,11 +677,11 @@ pparamsUpdateThreshold pp ppu =
GovGroup -> dvtPPGovGroupL
TechnicalGroup -> dvtPPTechnicalGroupL
EconomicGroup -> dvtPPEconomicGroupL
lookupGroupThreshold grp =
lookupGroupThreshold (PInfo grp _) =
pp ^. ppDRepVotingThresholdsL . thresholdLens grp
in Set.foldr' max minBound $
Set.map lookupGroupThreshold $
modifiedPPGroups @era ppu
modifiedParameterInfos @era ppu

data VotingThreshold
= -- | This is the actual threshold. It is lazy, because upon proposal we only care if
Expand Down Expand Up @@ -736,7 +738,16 @@ votingStakePoolThresholdInternal pp isElectedCommittee action =
{ pvtCommitteeNoConfidence
, pvtCommitteeNormal
, pvtHardForkInitiation
, pvtSecurityRelevant
} = pp ^. ppPoolVotingThresholdsL
isSecurityRelevant (PInfo _ s) =
case s of
SecurityRelevant -> True
Regular -> False
paramChangeThreshold ppu
| any isSecurityRelevant (modifiedParameterInfos ppu) =
VotingThreshold pvtSecurityRelevant
| otherwise = NoVotingAllowed
in case action of
NoConfidence {} -> VotingThreshold pvtCommitteeNoConfidence
UpdateCommittee {} ->
Expand All @@ -746,7 +757,7 @@ votingStakePoolThresholdInternal pp isElectedCommittee action =
else pvtCommitteeNoConfidence
NewConstitution {} -> NoVotingAllowed
HardForkInitiation {} -> VotingThreshold pvtHardForkInitiation
ParameterChange {} -> NoVotingAllowed
ParameterChange _ ppu -> paramChangeThreshold ppu
TreasuryWithdrawals {} -> NoVotingAllowed
InfoAction {} -> NoVotingThreshold

Expand Down
Loading

0 comments on commit 04ab57b

Please sign in to comment.