Skip to content
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

Update dependency on ouroboros-network #2114

Merged
merged 1 commit into from
Nov 24, 2020
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
4 changes: 2 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: 9aa3cb03deb367f5f237ab694d2c9e01b6cf431f
--sha256: 0nn1ywww0drvvdsr0yqlgg0dmhjgz9zpdp3rmq94zihbpl4sms99
tag: 57ab00435e6c38d146e029ac2d3f824ff6e738a8
--sha256: 0l9nv0lr9wxf9z7gs91dvpci7ghfbk9d4mcly1mm5xd76d21jbbb
subdir:
io-sim
io-sim-classes
Expand Down
3 changes: 3 additions & 0 deletions cardano-node/src/Cardano/Node/Configuration/Logging.hs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ nodeBasicInfo nc p nodeStartTime' = do
Consensus.ProtocolShelley {} ->
let DegenLedgerConfig cfgShelley = Consensus.configLedger cfg
in getGenesisValues "Shelley" cfgShelley
Consensus.ProtocolMary {} ->
let DegenLedgerConfig cfgMary = Consensus.configLedger cfg
in getGenesisValues "Mary" cfgMary
Consensus.ProtocolCardano {} ->
let CardanoLedgerConfig cfgByron cfgShelley cfgAllegra cfgMary = Consensus.configLedger cfg
in getGenesisValuesByron cfg cfgByron
Expand Down
24 changes: 10 additions & 14 deletions cardano-node/src/Cardano/Node/Protocol/Cardano.hs
Original file line number Diff line number Diff line change
Expand Up @@ -153,34 +153,30 @@ mkConsensusProtocolCardano NodeByronProtocolConfiguration {
byronLeaderCredentials =
byronLeaderCredentials
}
Consensus.ProtocolParamsShelley {
shelleyGenesis = shelleyGenesis,
shelleyInitialNonce =
Consensus.ProtocolParamsShelleyBased {
shelleyBasedGenesis = shelleyGenesis,
shelleyBasedInitialNonce =
Shelley.genesisHashToPraosNonce shelleyGenesisHash,
shelleyBasedLeaderCredentials =
shelleyLeaderCredentials
}
Consensus.ProtocolParamsShelley {
shelleyProtVer =
ProtVer
npcShelleySupportedProtocolVersionMajor
npcShelleySupportedProtocolVersionMinor,
shelleyLeaderCredentials =
shelleyLeaderCredentials
npcShelleySupportedProtocolVersionMinor
}
Consensus.ProtocolParamsAllegra {
allegraProtVer =
ProtVer
npcShelleySupportedProtocolVersionMajor
npcShelleySupportedProtocolVersionMinor,
allegraLeaderCredentials =
-- TODO: separate credentials for Allega
Nothing
npcShelleySupportedProtocolVersionMinor
}
Consensus.ProtocolParamsMary {
maryProtVer =
ProtVer
npcShelleySupportedProtocolVersionMajor
npcShelleySupportedProtocolVersionMinor,
maryLeaderCredentials =
-- TODO: separate credentials for Mary
Nothing
npcShelleySupportedProtocolVersionMinor
}
-- ProtocolParamsTransition specifies the parameters needed to transition between two eras
-- The comments below also apply for the Shelley -> Allegra and Allegra -> Mary hard forks.
Expand Down
22 changes: 12 additions & 10 deletions cardano-node/src/Cardano/Node/Protocol/Shelley.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ import qualified Cardano.Crypto.Hash.Class as Crypto
import qualified Ouroboros.Consensus.Cardano as Consensus
import Ouroboros.Consensus.Cardano.ShelleyHFC

import Ouroboros.Consensus.Shelley.Node (Nonce (..),
ProtocolParamsShelley (..), ShelleyGenesis, TPraosLeaderCredentials (..))
import Ouroboros.Consensus.Shelley.Protocol (TPraosCanBeLeader (..), StandardCrypto)
import Ouroboros.Consensus.Shelley.Node (Nonce (..), ProtocolParamsShelley (..),
ProtocolParamsShelleyBased (..), ShelleyGenesis, TPraosLeaderCredentials (..))
import Ouroboros.Consensus.Shelley.Protocol (StandardCrypto, TPraosCanBeLeader (..))

import Shelley.Spec.Ledger.Genesis (ValidationErr (..), describeValidationErr,
validateGenesis)
Expand Down Expand Up @@ -101,16 +101,18 @@ mkConsensusProtocolShelley NodeShelleyProtocolConfiguration {
firstExceptT GenesisValidationFailure . hoistEither $ validateGenesis genesis
optionalLeaderCredentials <- readLeaderCredentials files

return $
Consensus.ProtocolShelley $ Consensus.ProtocolParamsShelley {
shelleyGenesis = genesis,
shelleyInitialNonce = genesisHashToPraosNonce genesisHash,
return $ Consensus.ProtocolShelley
Consensus.ProtocolParamsShelleyBased {
shelleyBasedGenesis = genesis,
shelleyBasedInitialNonce = genesisHashToPraosNonce genesisHash,
shelleyBasedLeaderCredentials =
maybeToList optionalLeaderCredentials
}
Consensus.ProtocolParamsShelley {
shelleyProtVer =
ProtVer
npcShelleySupportedProtocolVersionMajor
npcShelleySupportedProtocolVersionMinor,
shelleyLeaderCredentials =
maybeToList optionalLeaderCredentials
npcShelleySupportedProtocolVersionMinor
}

genesisHashToPraosNonce :: GenesisHash -> Nonce
Expand Down
54 changes: 34 additions & 20 deletions cardano-node/src/Cardano/Node/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ import qualified Cardano.Chain.Genesis as Byron
import qualified Ouroboros.Consensus.Byron.Ledger.Conversions as Byron

-- Shelley
import Ouroboros.Consensus.Shelley.Ledger.Ledger (shelleyLedgerGenesis)
import Ouroboros.Consensus.Shelley.Ledger (shelleyLedgerGenesis)
import qualified Shelley.Spec.Ledger.API as SL

-- Cardano
import qualified Ouroboros.Consensus.Cardano as Consensus
import Ouroboros.Consensus.Cardano.ByronHFC (ByronBlockHFC)
import Ouroboros.Consensus.Cardano.ShelleyHFC (ShelleyBlockHFC)
import qualified Ouroboros.Consensus.Cardano.CanHardFork as CanHardFork

import Cardano.Tracing.Kernel
Expand Down Expand Up @@ -68,26 +70,11 @@ answerQueryWithLedgerState
answerQueryWithLedgerState protocol extLedgerState query = runIdentity $
case protocol of
Consensus.ProtocolByron {} ->
let DegenLedgerConfig ledgerConfig = configLedger cfg
genesis = CanHardFork.byronLedgerConfig ledgerConfig
epochSize = Byron.fromByronEpochSlots $ Byron.configEpochSlots genesis
slotLength = Byron.fromByronSlotLength $ Byron.genesisSlotLength genesis
in HF.singleEraCompatQuery
epochSize
slotLength
answerQueryHelper
query
byronQuery
Consensus.ProtocolShelley {} ->
let DegenLedgerConfig ledgerConfig = configLedger cfg
genesis = shelleyLedgerGenesis $
CanHardFork.shelleyLedgerConfig ledgerConfig
epochSize = SL.sgEpochLength genesis
slotLength = WCT.mkSlotLength $ SL.sgSlotLength genesis
in HF.singleEraCompatQuery
epochSize
slotLength
answerQueryHelper
query
shelleyBasedQuery
Consensus.ProtocolMary {} ->
shelleyBasedQuery
Consensus.ProtocolCardano {} ->
HF.forwardCompatQuery
answerQueryHelper
Expand All @@ -103,6 +90,33 @@ answerQueryWithLedgerState protocol extLedgerState query = runIdentity $
answerQueryHelper q = pure $
Consensus.answerQuery (ExtLedgerCfg cfg) q extLedgerState

byronQuery :: blk ~ ByronBlockHFC => Identity result
byronQuery =
HF.singleEraCompatQuery
epochSize
slotLength
answerQueryHelper
query
where
DegenLedgerConfig ledgerConfig = configLedger cfg
genesis = CanHardFork.byronLedgerConfig ledgerConfig
epochSize = Byron.fromByronEpochSlots $ Byron.configEpochSlots genesis
slotLength = Byron.fromByronSlotLength $ Byron.genesisSlotLength genesis

shelleyBasedQuery :: blk ~ ShelleyBlockHFC era => Identity result
shelleyBasedQuery =
HF.singleEraCompatQuery
epochSize
slotLength
answerQueryHelper
query
where
DegenLedgerConfig ledgerConfig = configLedger cfg
genesis = shelleyLedgerGenesis $
CanHardFork.shelleyLedgerConfig ledgerConfig
epochSize = SL.sgEpochLength genesis
slotLength = WCT.mkSlotLength $ SL.sgSlotLength genesis

-- | To avoid confusing 'HFI.Qry' with 'HF.Query' and 'HF.HardForkCompatQuery,
-- we introduce a type synonym for the former which we can use in docstrings
-- (and type signatures, of course).
Expand Down
12 changes: 8 additions & 4 deletions cardano-node/src/Cardano/Tracing/Metrics.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{-# LANGUAGE DisambiguateRecordFields #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE UndecidableInstances #-}
Expand Down Expand Up @@ -77,10 +78,13 @@ instance HasKESMetricsData ByronBlock where

instance All HasKESMetricsData xs => HasKESMetricsData (HardForkBlock xs) where
getKESMetricsData _ forgeStateInfo =
hcollapse
. hcmap (Proxy @HasKESMetricsData) getOne
. getOneEraForgeStateInfo
$ forgeStateInfo
case forgeStateInfo of
CurrentEraLacksBlockForging _ -> NoKESMetricsData
CurrentEraForgeStateUpdated currentEraForgeStateInfo ->
hcollapse
. hcmap (Proxy @HasKESMetricsData) getOne
. getOneEraForgeStateInfo
$ currentEraForgeStateInfo
where
getOne :: forall blk. HasKESMetricsData blk
=> WrapForgeStateInfo blk
Expand Down
2 changes: 1 addition & 1 deletion cardano-node/src/Cardano/Tracing/Queries.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Prelude (Int, (.))
import qualified Data.Map.Strict as Map

import Ouroboros.Consensus.HardFork.Combinator
import Ouroboros.Consensus.HardFork.Combinator.Unary
import Ouroboros.Consensus.HardFork.Combinator.Embed.Unary

import qualified Cardano.Chain.Block as Byron
import qualified Cardano.Chain.UTxO as Byron
Expand Down