Skip to content

Commit

Permalink
wip 4: remove ProtocolConfigHasSecurityParam, as it now offers nothin…
Browse files Browse the repository at this point in the history
…g that ConsensusProtocol doesn't
  • Loading branch information
fraser-iohk committed Feb 20, 2024
1 parent e382496 commit 09adfd2
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import Ouroboros.Consensus.Ledger.SupportsProtocol
(LedgerSupportsProtocol)
import Ouroboros.Consensus.Node.ProtocolInfo
import Ouroboros.Consensus.Node.Run
import Ouroboros.Consensus.Protocol.Abstract
import Ouroboros.Consensus.Protocol.TPraos
import Ouroboros.Consensus.Shelley.Eras (EraCrypto)
import Ouroboros.Consensus.Shelley.Ledger
Expand Down Expand Up @@ -106,9 +107,8 @@ instance ShelleyCompatible proto era => BlockSupportsMetrics (ShelleyBlock proto
(SL.VKey 'SL.BlockIssuer (EraCrypto era))
issuerVKeys = shelleyBlockIssuerVKeys cfg

instance ProtocolConfigHasSecurityParam proto
=> BlockSupportsSanityCheck (ShelleyBlock proto era) where
configAllSecurityParams = pure . protocolConfigSecurityParam . topLevelConfigProtocol
instance ConsensusProtocol proto => BlockSupportsSanityCheck (ShelleyBlock proto era) where
configAllSecurityParams = pure . protocolSecurityParam . topLevelConfigProtocol

instance
( ShelleyCompatible proto era
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import Ouroboros.Consensus.Node.InitStorage
import Ouroboros.Consensus.Node.ProtocolInfo
import Ouroboros.Consensus.Node.Run
import Ouroboros.Consensus.NodeId
import Ouroboros.Consensus.Protocol.Abstract
import Ouroboros.Consensus.Protocol.PBFT
import qualified Ouroboros.Consensus.Protocol.PBFT.State as S
import Ouroboros.Consensus.Storage.ChainDB.Init (InitChainDB (..))
Expand Down Expand Up @@ -251,6 +252,6 @@ instance BlockSupportsMetrics DualByronBlock where
isSelfIssued = isSelfIssuedConstUnknown

instance BlockSupportsSanityCheck DualByronBlock where
configAllSecurityParams = pure . protocolConfigSecurityParam . topLevelConfigProtocol
configAllSecurityParams = pure . protocolSecurityParam . topLevelConfigProtocol

instance RunNode DualByronBlock
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ import Data.Word (Word64)
import GHC.Generics (Generic)
import NoThunks.Class (NoThunks)
import Numeric.Natural (Natural)
import Ouroboros.Consensus.Block (WithOrigin (NotOrigin), ProtocolConfigHasSecurityParam(..))
import Ouroboros.Consensus.Block (WithOrigin (NotOrigin))
import qualified Ouroboros.Consensus.HardFork.History as History
import Ouroboros.Consensus.Protocol.Abstract
import Ouroboros.Consensus.Protocol.Ledger.HotKey (HotKey)
Expand Down Expand Up @@ -230,9 +230,6 @@ data instance ConsensusConfig (Praos c) = PraosConfig

instance PraosCrypto c => NoThunks (ConsensusConfig (Praos c))

instance ProtocolConfigHasSecurityParam (Praos c) where
protocolConfigSecurityParam = praosSecurityParam . praosParams

type PraosValidateView c = Views.HeaderView c

{-------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,6 @@ data instance ConsensusConfig (TPraos c) = TPraosConfig {

instance SL.PraosCrypto c => NoThunks (ConsensusConfig (TPraos c))

instance ProtocolConfigHasSecurityParam (TPraos c) where
protocolConfigSecurityParam = tpraosSecurityParam . tpraosParams

-- | Transitional Praos consensus state.
--
-- In addition to the 'ChainDepState' provided by the ledger, we track the slot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
-- own peril.
module Ouroboros.Consensus.Block.SupportsSanityCheck (
BlockSupportsSanityCheck (..)
, ProtocolConfigHasSecurityParam (..)
, SanityCheckIssue (..)
, checkSecurityParamConsistency
, issueDescription
Expand All @@ -23,7 +22,6 @@ import qualified Data.List.NonEmpty as NonEmpty
import Data.Maybe (catMaybes)
import Ouroboros.Consensus.Config (TopLevelConfig)
import Ouroboros.Consensus.Config.SecurityParam
import Ouroboros.Consensus.Protocol.Abstract

-- | An issue found in the 'TopLevelConfig' for a block. See 'issueDescription'
-- for human-readable descriptions of each of these cases, especially when
Expand Down Expand Up @@ -84,6 +82,3 @@ sanityCheckConfig
-> [SanityCheckIssue]
sanityCheckConfig cfg =
catMaybes [checkSecurityParamConsistency cfg]

class ProtocolConfigHasSecurityParam p where
protocolConfigSecurityParam :: ConsensusConfig p -> SecurityParam
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import Data.Typeable
import GHC.Generics (Generic)
import NoThunks.Class (NoThunks (..))
import Ouroboros.Consensus.Block.Abstract
import Ouroboros.Consensus.Block.SupportsSanityCheck
import Ouroboros.Consensus.Node.ProtocolInfo
import Ouroboros.Consensus.NodeId (CoreNodeId (..), NodeId (..))
import Ouroboros.Consensus.Protocol.Abstract
Expand Down Expand Up @@ -163,9 +162,6 @@ instance BftCrypto c => ConsensusProtocol (Bft c) where
instance BftCrypto c => NoThunks (ConsensusConfig (Bft c))
-- use generic instance

instance ProtocolConfigHasSecurityParam (Bft c) where
protocolConfigSecurityParam = bftSecurityParam . bftParams

{-------------------------------------------------------------------------------
BFT specific types
-------------------------------------------------------------------------------}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,6 @@ instance PBftCrypto c => ConsensusProtocol (PBft c) where
where
params = pbftWindowParams cfg

instance ProtocolConfigHasSecurityParam (PBft c) where
protocolConfigSecurityParam = pbftSecurityParam . pbftParams

{-------------------------------------------------------------------------------
Internal: thin wrapper on top of 'PBftState'
-------------------------------------------------------------------------------}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,11 @@ instance NodeInitStorage (SimpleBlock SimpleMockCrypto ext) where
instance BlockSupportsMetrics (SimpleBlock c ext) where
isSelfIssued = isSelfIssuedConstUnknown

instance ProtocolConfigHasSecurityParam (BlockProtocol (SimpleBlock c ext))
=> BlockSupportsSanityCheck (SimpleBlock c ext) where
instance ConsensusProtocol (BlockProtocol (SimpleBlock c ext)) => BlockSupportsSanityCheck (SimpleBlock c ext) where
configAllSecurityParams =
pure . protocolConfigSecurityParam . topLevelConfigProtocol
pure . protocolSecurityParam . topLevelConfigProtocol

instance ( LedgerSupportsProtocol (SimpleBlock SimpleMockCrypto ext)
, ProtocolConfigHasSecurityParam (BlockProtocol (SimpleBlock SimpleMockCrypto ext))
, Show (CannotForge (SimpleBlock SimpleMockCrypto ext))
, Show (ForgeStateInfo (SimpleBlock SimpleMockCrypto ext))
, Show (ForgeStateUpdateError (SimpleBlock SimpleMockCrypto ext))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ module Ouroboros.Consensus.Mock.Protocol.LeaderSchedule (
import qualified Data.Map.Strict as Map
import GHC.Generics (Generic)
import NoThunks.Class (NoThunks)
import Ouroboros.Consensus.Block
import Ouroboros.Consensus.NodeId (CoreNodeId (..))
import Ouroboros.Consensus.Protocol.Abstract
import Ouroboros.Consensus.Protocol.LeaderSchedule
Expand Down Expand Up @@ -61,6 +60,3 @@ instance ConsensusProtocol p => ConsensusProtocol (WithLeaderSchedule p) where

instance ConsensusProtocol p
=> NoThunks (ConsensusConfig (WithLeaderSchedule p))

instance ProtocolConfigHasSecurityParam p => ProtocolConfigHasSecurityParam (WithLeaderSchedule p) where
protocolConfigSecurityParam = protocolConfigSecurityParam . wlsConfigP
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,6 @@ data instance ConsensusConfig (Praos c) = PraosConfig

instance PraosCrypto c => NoThunks (ConsensusConfig (Praos c))

instance ProtocolConfigHasSecurityParam (Praos c) where
protocolConfigSecurityParam = praosSecurityParam . praosParams

slotEpoch :: ConsensusConfig (Praos c) -> SlotNo -> EpochNo
slotEpoch PraosConfig{..} s =
fixedEpochInfoEpoch (EpochSize praosSlotsPerEpoch) s
Expand Down

0 comments on commit 09adfd2

Please sign in to comment.