Skip to content

Remove dead protocolInfoPraosBabbage and protocolInfoPraosShelleyBased. #4238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,51 +12,28 @@ module Ouroboros.Consensus.Shelley.Node.Praos (
ProtocolParamsBabbage (..)
, praosBlockForging
, praosSharedBlockForging
, protocolInfoPraosBabbage
, protocolInfoPraosShelleyBased
) where

import qualified Cardano.Ledger.BaseTypes as SL (mkActiveSlotCoeff)
import qualified Cardano.Ledger.Era as Core
import qualified Cardano.Ledger.Shelley.API as SL
import qualified Cardano.Protocol.TPraos.OCert as Absolute
import qualified Cardano.Protocol.TPraos.OCert as SL
import Cardano.Slotting.EpochInfo (EpochInfo, fixedEpochInfo)
import Cardano.Slotting.Time (SystemStart (SystemStart), mkSlotLength)
import Control.Monad.Except (Except)
import Ouroboros.Consensus.Block
import Ouroboros.Consensus.Config (SecurityParam (SecurityParam),
TopLevelConfig (..), configConsensus)
import qualified Ouroboros.Consensus.HardFork.History as History
import Ouroboros.Consensus.HeaderValidation
(HeaderState (HeaderState))
import Ouroboros.Consensus.Ledger.Abstract (LedgerConfig)
import Ouroboros.Consensus.Ledger.Extended (ExtLedgerState (..))
import Ouroboros.Consensus.Config (configConsensus)
import Ouroboros.Consensus.Mempool.TxLimits
import qualified Ouroboros.Consensus.Mempool.TxLimits as TxLimits
import Ouroboros.Consensus.Node (ProtocolInfo (..))
import Ouroboros.Consensus.Protocol.Abstract (ConsensusConfig)
import qualified Ouroboros.Consensus.Protocol.Ledger.HotKey as HotKey
import Ouroboros.Consensus.Protocol.Praos (ConsensusConfig (..),
Praos, PraosParams (..), PraosState (..),
import Ouroboros.Consensus.Protocol.Praos (Praos, PraosParams (..),
praosCheckCanForge)
import Ouroboros.Consensus.Protocol.Praos.Common
(MaxMajorProtVer (MaxMajorProtVer),
PraosCanBeLeader (praosCanBeLeaderOpCert))
(PraosCanBeLeader (praosCanBeLeaderOpCert))
import Ouroboros.Consensus.Shelley.Eras (BabbageEra, EraCrypto,
ShelleyBasedEra (shelleyBasedEraName))
import Ouroboros.Consensus.Shelley.Ledger
(CodecConfig (ShelleyCodecConfig), LedgerState (..),
ShelleyBlock, ShelleyCompatible, ShelleyTransition (..),
StorageConfig (..), forgeShelleyBlock,
mkShelleyBlockConfig, mkShelleyLedgerConfig)
import Ouroboros.Consensus.Shelley.Ledger (ShelleyBlock,
ShelleyCompatible, forgeShelleyBlock)
import Ouroboros.Consensus.Shelley.Node
(ProtocolParamsShelleyBased (..),
ShelleyLeaderCredentials (..), validateGenesis)
import Ouroboros.Consensus.Shelley.Node.Common (ShelleyEraWithCrypto,
shelleyBlockIssuerVKey)
(ShelleyLeaderCredentials (..))
import Ouroboros.Consensus.Shelley.Node.Common (ShelleyEraWithCrypto)
import Ouroboros.Consensus.Shelley.Protocol.Praos ()
import Ouroboros.Consensus.Util.Assert (assertWithMsg)
import Ouroboros.Consensus.Util.IOLike (IOLike)

{-------------------------------------------------------------------------------
Expand Down Expand Up @@ -143,141 +120,3 @@ data ProtocolParamsBabbage c = ProtocolParamsBabbage
babbageMaxTxCapacityOverrides :: TxLimits.Overrides (ShelleyBlock (Praos c) (BabbageEra c))
}

protocolInfoPraosBabbage ::
forall m c.
( IOLike m,
ShelleyCompatible (Praos c) (BabbageEra c),
TxLimits (ShelleyBlock (Praos c) (BabbageEra c))
) =>
ProtocolParamsShelleyBased (BabbageEra c) ->
ProtocolParamsBabbage c ->
ProtocolInfo m (ShelleyBlock (Praos c) (BabbageEra c))
protocolInfoPraosBabbage
protocolParamsShelleyBased
ProtocolParamsBabbage
{ babbageProtVer = protVer,
babbageMaxTxCapacityOverrides = maxTxCapacityOverrides
} =
protocolInfoPraosShelleyBased
protocolParamsShelleyBased
(error "Babbage currently pretending to be Alonzo")
protVer
maxTxCapacityOverrides

protocolInfoPraosShelleyBased ::
forall m era c.
( IOLike m,
ShelleyCompatible (Praos c) era,
TxLimits (ShelleyBlock (Praos c) era),
c ~ EraCrypto era
) =>
ProtocolParamsShelleyBased era ->
Core.TranslationContext era ->
SL.ProtVer ->
TxLimits.Overrides (ShelleyBlock (Praos c) era) ->
ProtocolInfo m (ShelleyBlock (Praos c) era)
protocolInfoPraosShelleyBased
ProtocolParamsShelleyBased
{ shelleyBasedGenesis = genesis,
shelleyBasedInitialNonce = initialNonce,
shelleyBasedLeaderCredentials = credentialss
}
transCtxt
protVer
maxTxCapacityOverrides =
assertWithMsg (validateGenesis genesis) $
ProtocolInfo
{ pInfoConfig = topLevelConfig,
pInfoInitLedger = initExtLedgerState,
pInfoBlockForging =
traverse
(praosBlockForging praosParams maxTxCapacityOverrides)
credentialss
}
where
additionalGenesisConfig :: SL.AdditionalGenesisConfig era
additionalGenesisConfig = transCtxt

maxMajorProtVer :: MaxMajorProtVer
maxMajorProtVer = MaxMajorProtVer $ SL.pvMajor protVer

topLevelConfig :: TopLevelConfig (ShelleyBlock (Praos c) era)
topLevelConfig =
TopLevelConfig
{ topLevelConfigProtocol = consensusConfig,
topLevelConfigLedger = ledgerConfig,
topLevelConfigBlock = blockConfig,
topLevelConfigCodec = ShelleyCodecConfig,
topLevelConfigStorage = storageConfig
}

consensusConfig :: ConsensusConfig (BlockProtocol (ShelleyBlock (Praos c) era))
consensusConfig =
PraosConfig
{ praosParams,
praosEpochInfo = epochInfo
}

ledgerConfig :: LedgerConfig (ShelleyBlock (Praos c) era)
ledgerConfig = mkShelleyLedgerConfig genesis transCtxt epochInfo maxMajorProtVer

epochInfo :: EpochInfo (Except History.PastHorizonException)
epochInfo =
fixedEpochInfo
(SL.sgEpochLength genesis)
(mkSlotLength $ SL.sgSlotLength genesis)

praosParams :: PraosParams
praosParams =
PraosParams
{ praosSlotsPerKESPeriod = SL.sgSlotsPerKESPeriod genesis,
praosLeaderF = SL.mkActiveSlotCoeff $ SL.sgActiveSlotsCoeff genesis,
praosSecurityParam = SecurityParam $ SL.sgSecurityParam genesis,
praosMaxKESEvo = SL.sgMaxKESEvolutions genesis,
praosQuorum = SL.sgUpdateQuorum genesis,
praosMaxMajorPV = maxMajorProtVer,
praosMaxLovelaceSupply = SL.sgMaxLovelaceSupply genesis,
praosNetworkId = SL.sgNetworkId genesis,
praosSystemStart = SystemStart $ SL.sgSystemStart genesis
}

blockConfig :: BlockConfig (ShelleyBlock (Praos c) era)
blockConfig =
mkShelleyBlockConfig
protVer
genesis
(shelleyBlockIssuerVKey <$> credentialss)

storageConfig :: StorageConfig (ShelleyBlock (Praos c) era)
storageConfig =
ShelleyStorageConfig
{ shelleyStorageConfigSlotsPerKESPeriod = praosSlotsPerKESPeriod praosParams,
shelleyStorageConfigSecurityParam = praosSecurityParam praosParams
}

initLedgerState :: LedgerState (ShelleyBlock (Praos c) era)
initLedgerState =
ShelleyLedgerState
{ shelleyLedgerTip = Origin,
shelleyLedgerState = SL.initialState genesis additionalGenesisConfig,
shelleyLedgerTransition = ShelleyTransitionInfo {shelleyAfterVoting = 0}
}

initChainDepState :: PraosState c
initChainDepState =
PraosState
{ praosStateLastSlot = Origin,
praosStateOCertCounters = mempty,
praosStateEvolvingNonce = initialNonce,
praosStateCandidateNonce = initialNonce,
praosStateEpochNonce = initialNonce,
praosStateLabNonce = initialNonce,
praosStateLastEpochBlockNonce = initialNonce
}

initExtLedgerState :: ExtLedgerState (ShelleyBlock (Praos c) era)
initExtLedgerState =
ExtLedgerState
{ ledgerState = initLedgerState,
headerState = HeaderState Origin initChainDepState
}
4 changes: 4 additions & 0 deletions ouroboros-consensus/docs/interface-CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ https://keepachangelog.com/en/1.1.0/, adapted to our plan explained above.

## Circa 2022-11-23

- Removed dead `protocolInfoPraosBabbage` and `protocolInfoPraosShelleyBased`.

## Circa 2022-11-23

- Added `ouroboros-consensus-diffusion`, a top level integration package of
`ouroboros-network` & `ouroboros-consensus`

Expand Down