Skip to content

Commit

Permalink
Update dependency on ouroboros-network
Browse files Browse the repository at this point in the history
  • Loading branch information
mrBliss authored and newhoggy committed Oct 9, 2020
1 parent 865caac commit 7548f98
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 82 deletions.
48 changes: 24 additions & 24 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -282,85 +282,85 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: 9e498e0962044c582df0cbf2f81fa0450a67d5f7
--sha256: 000ypfbdc6i6plc91vrcywj4yrw5vvafn7c6993xn1pvd18xjm5g
tag: e142c7153b9ff0505a84ec68124f5bd80449eebd
--sha256: 1sd418jfd6mavm0kbx7yhyhlmjcl2sc4fnkf3xd9ws13mxz2qbaf
subdir: ouroboros-network

source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: 9e498e0962044c582df0cbf2f81fa0450a67d5f7
--sha256: 000ypfbdc6i6plc91vrcywj4yrw5vvafn7c6993xn1pvd18xjm5g
tag: e142c7153b9ff0505a84ec68124f5bd80449eebd
--sha256: 1sd418jfd6mavm0kbx7yhyhlmjcl2sc4fnkf3xd9ws13mxz2qbaf
subdir: io-sim

source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: 9e498e0962044c582df0cbf2f81fa0450a67d5f7
--sha256: 000ypfbdc6i6plc91vrcywj4yrw5vvafn7c6993xn1pvd18xjm5g
tag: e142c7153b9ff0505a84ec68124f5bd80449eebd
--sha256: 1sd418jfd6mavm0kbx7yhyhlmjcl2sc4fnkf3xd9ws13mxz2qbaf
subdir: ouroboros-consensus

source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: 9e498e0962044c582df0cbf2f81fa0450a67d5f7
--sha256: 000ypfbdc6i6plc91vrcywj4yrw5vvafn7c6993xn1pvd18xjm5g
tag: e142c7153b9ff0505a84ec68124f5bd80449eebd
--sha256: 1sd418jfd6mavm0kbx7yhyhlmjcl2sc4fnkf3xd9ws13mxz2qbaf
subdir: ouroboros-consensus-byron

source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: 9e498e0962044c582df0cbf2f81fa0450a67d5f7
--sha256: 000ypfbdc6i6plc91vrcywj4yrw5vvafn7c6993xn1pvd18xjm5g
tag: e142c7153b9ff0505a84ec68124f5bd80449eebd
--sha256: 1sd418jfd6mavm0kbx7yhyhlmjcl2sc4fnkf3xd9ws13mxz2qbaf
subdir: ouroboros-consensus-shelley

source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: 9e498e0962044c582df0cbf2f81fa0450a67d5f7
--sha256: 000ypfbdc6i6plc91vrcywj4yrw5vvafn7c6993xn1pvd18xjm5g
tag: e142c7153b9ff0505a84ec68124f5bd80449eebd
--sha256: 1sd418jfd6mavm0kbx7yhyhlmjcl2sc4fnkf3xd9ws13mxz2qbaf
subdir: ouroboros-consensus-cardano

source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: 9e498e0962044c582df0cbf2f81fa0450a67d5f7
--sha256: 000ypfbdc6i6plc91vrcywj4yrw5vvafn7c6993xn1pvd18xjm5g
tag: e142c7153b9ff0505a84ec68124f5bd80449eebd
--sha256: 1sd418jfd6mavm0kbx7yhyhlmjcl2sc4fnkf3xd9ws13mxz2qbaf
subdir: typed-protocols

source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: 9e498e0962044c582df0cbf2f81fa0450a67d5f7
--sha256: 000ypfbdc6i6plc91vrcywj4yrw5vvafn7c6993xn1pvd18xjm5g
tag: e142c7153b9ff0505a84ec68124f5bd80449eebd
--sha256: 1sd418jfd6mavm0kbx7yhyhlmjcl2sc4fnkf3xd9ws13mxz2qbaf
subdir: typed-protocols-examples

source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: 9e498e0962044c582df0cbf2f81fa0450a67d5f7
--sha256: 000ypfbdc6i6plc91vrcywj4yrw5vvafn7c6993xn1pvd18xjm5g
tag: e142c7153b9ff0505a84ec68124f5bd80449eebd
--sha256: 1sd418jfd6mavm0kbx7yhyhlmjcl2sc4fnkf3xd9ws13mxz2qbaf
subdir: ouroboros-network-framework

source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: 9e498e0962044c582df0cbf2f81fa0450a67d5f7
--sha256: 000ypfbdc6i6plc91vrcywj4yrw5vvafn7c6993xn1pvd18xjm5g
tag: e142c7153b9ff0505a84ec68124f5bd80449eebd
--sha256: 1sd418jfd6mavm0kbx7yhyhlmjcl2sc4fnkf3xd9ws13mxz2qbaf
subdir: network-mux

source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: 9e498e0962044c582df0cbf2f81fa0450a67d5f7
--sha256: 000ypfbdc6i6plc91vrcywj4yrw5vvafn7c6993xn1pvd18xjm5g
tag: e142c7153b9ff0505a84ec68124f5bd80449eebd
--sha256: 1sd418jfd6mavm0kbx7yhyhlmjcl2sc4fnkf3xd9ws13mxz2qbaf
subdir: io-sim-classes

source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: 9e498e0962044c582df0cbf2f81fa0450a67d5f7
--sha256: 000ypfbdc6i6plc91vrcywj4yrw5vvafn7c6993xn1pvd18xjm5g
tag: e142c7153b9ff0505a84ec68124f5bd80449eebd
--sha256: 1sd418jfd6mavm0kbx7yhyhlmjcl2sc4fnkf3xd9ws13mxz2qbaf
subdir: Win32-network

constraints:
Expand Down
1 change: 0 additions & 1 deletion cardano-node-chairman/app/Cardano/Chairman.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ module Cardano.Chairman (chairmanTest) where
import Cardano.Api.Protocol.Types (SomeNodeClientProtocol (..))
import Cardano.Node.Types (SocketPath (..))
import Cardano.Prelude hiding (ByteString, STM, atomically, catch, option, show)
import Control.Concurrent.Async (forConcurrently_)
import Control.Monad (void)
import Control.Monad.Class.MonadAsync
import Control.Monad.Class.MonadST
Expand Down
1 change: 0 additions & 1 deletion cardano-node/chairman/Cardano/Chairman.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ module Cardano.Chairman (chairmanTest) where
import Cardano.Prelude hiding (ByteString, STM, atomically, catch, option, show)
import Prelude (String, error, show)

import Control.Concurrent.Async (forConcurrently_)
import Control.Monad (void)
import Data.ByteString.Lazy (ByteString)
import Data.Coerce (coerce)
Expand Down
8 changes: 6 additions & 2 deletions cardano-node/src/Cardano/Node/Protocol/Byron.hs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ mkConsensusProtocolByron NodeByronProtocolConfiguration {
npcByronSupportedProtocolVersionAlt)
(Update.SoftwareVersion npcByronApplicationName
npcByronApplicationVersion)
optionalLeaderCredentials
(maybeToList optionalLeaderCredentials)


readGenesis :: GenesisFile
Expand Down Expand Up @@ -177,9 +177,13 @@ readLeaderCredentials genesisConfig
. hoistEither
$ canonicalDecodePretty delegCertFileBytes

-- The label is used to distinguish multiple sets of credentials
-- during tracing. We use the public signing key as the label.
let label = Text.pack $ show $ Byron.Crypto.toVerification signingKey

bimapExceptT CredentialsError Just
. hoistEither
$ mkByronLeaderCredentials genesisConfig signingKey delegCert
$ mkByronLeaderCredentials genesisConfig signingKey delegCert label

where
deserialiseSigningKey :: LB.ByteString
Expand Down
5 changes: 3 additions & 2 deletions cardano-node/src/Cardano/Node/Protocol/Cardano.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import Prelude

import Control.Monad.Trans.Except (ExceptT)
import Control.Monad.Trans.Except.Extra (firstExceptT)
import Data.Maybe (maybeToList)
import qualified Data.Text as T

import qualified Cardano.Chain.Update as Byron
Expand Down Expand Up @@ -144,15 +145,15 @@ mkConsensusProtocolCardano NodeByronProtocolConfiguration {
npcByronSupportedProtocolVersionAlt)
(Byron.SoftwareVersion npcByronApplicationName
npcByronApplicationVersion)
byronLeaderCredentials
(maybeToList byronLeaderCredentials)

-- Shelley parameters
shelleyGenesis
(Shelley.genesisHashToPraosNonce shelleyGenesisHash)
(Shelley.ProtVer npcShelleySupportedProtocolVersionMajor
npcShelleySupportedProtocolVersionMinor)
(MaxMajorProtVer npcShelleyMaxSupportedProtocolVersion)
shelleyLeaderCredentials
(maybeToList shelleyLeaderCredentials)

-- Hard fork parameters
npcShelleyHardForkNotBeforeEpoch
Expand Down
10 changes: 8 additions & 2 deletions cardano-node/src/Cardano/Node/Protocol/Shelley.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import Control.Monad.Trans.Except.Extra (firstExceptT, handleIOExceptT
newExceptT)

import qualified Cardano.Crypto.Hash.Class as Crypto
import Cardano.Crypto.KES (deriveVerKeyKES)

import qualified Ouroboros.Consensus.Cardano as Consensus
import Ouroboros.Consensus.Cardano.ShelleyHFC
Expand Down Expand Up @@ -110,7 +111,7 @@ mkConsensusProtocolShelley NodeShelleyProtocolConfiguration {
(ProtVer npcShelleySupportedProtocolVersionMajor
npcShelleySupportedProtocolVersionMinor)
(MaxMajorProtVer npcShelleyMaxSupportedProtocolVersion)
optionalLeaderCredentials
(maybeToList optionalLeaderCredentials)

genesisHashToPraosNonce :: GenesisHash -> Nonce
genesisHashToPraosNonce (GenesisHash h) = Nonce (Crypto.castHash h)
Expand Down Expand Up @@ -163,14 +164,19 @@ readLeaderCredentials (Just ProtocolFilepaths {
KesSigningKey kesKey <-
firstExceptT FileError . newExceptT $ readFileTextEnvelope (AsSigningKey AsKesKey) kesFile

-- The label is used to distinguish multiple sets of credentials during
-- tracing. We use the public KES key as the label.
let label = T.pack (show (deriveVerKeyKES kesKey))

return $ Just TPraosLeaderCredentials {
tpraosLeaderCredentialsCanBeLeader =
TPraosCanBeLeader {
tpraosCanBeLeaderOpCert = opcert,
tpraosCanBeLeaderColdVerKey = coerceKeyRole vkey,
tpraosCanBeLeaderSignKeyVRF = vrfKey
},
tpraosLeaderCredentialsInitSignKey = kesKey
tpraosLeaderCredentialsInitSignKey = kesKey,
tpraosLeaderCredentialsLabel = label
}

-- But not OK to supply some of the files without the others.
Expand Down
33 changes: 7 additions & 26 deletions cardano-node/src/Cardano/Tracing/Metrics.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}

module Cardano.Tracing.Metrics
Expand All @@ -19,16 +18,15 @@ module Cardano.Tracing.Metrics
import Cardano.Prelude hiding (All, (:.:))

import Cardano.Crypto.KES.Class (Period)
import Data.SOP.Strict (All, (:.:)(..), hcmap, K (..), hcollapse)
import Data.SOP.Strict (All, hcmap, K (..), hcollapse)
import Ouroboros.Consensus.Block (ForgeStateInfo)
import Ouroboros.Consensus.Byron.Ledger.Block (ByronBlock)
import Ouroboros.Consensus.HardFork.Combinator
import Ouroboros.Consensus.TypeFamilyWrappers (WrapForgeStateInfo (..))
import Ouroboros.Consensus.HardFork.Combinator.AcrossEras (PerEraForgeStateInfo (..))
import Ouroboros.Consensus.HardFork.Combinator.AcrossEras (OneEraForgeStateInfo (..))
import Ouroboros.Consensus.Shelley.Ledger.Block (ShelleyBlock)
import Ouroboros.Consensus.Shelley.Node ()
import qualified Ouroboros.Consensus.Shelley.Protocol.HotKey as HotKey
import qualified Ouroboros.Consensus.Util.OptNP as OptNP
import Shelley.Spec.Ledger.OCert (KESPeriod (..))


Expand Down Expand Up @@ -79,29 +77,12 @@ instance HasKESMetricsData ByronBlock where

instance All HasKESMetricsData xs => HasKESMetricsData (HardForkBlock xs) where
getKESMetricsData _ forgeStateInfo =
combineKESMetrics
. hcollapse
. hcmap (Proxy @ HasKESMetricsData) getOne
. OptNP.toNP
. getPerEraForgeStateInfo
hcollapse
. hcmap (Proxy @HasKESMetricsData) getOne
. getOneEraForgeStateInfo
$ forgeStateInfo
where
getOne :: forall blk. HasKESMetricsData blk
=> (Maybe :.: WrapForgeStateInfo) blk
=> WrapForgeStateInfo blk
-> K KESMetricsData blk
getOne (Comp mbWrapForgeStateInfo) = K $
case unwrapForgeStateInfo <$> mbWrapForgeStateInfo of
Nothing -> NoKESMetricsData
Just oneForgeStateInfo ->
getKESMetricsData (Proxy @ blk) oneForgeStateInfo

-- Multiple eras can have 'KESMetricsData', e.g., Shelley and Shelley +
-- native assets. We don't know which era we're in, so we have to make a
-- choice: we choose the last era's 'KESMetricsData'.
--
-- TODO this might need revision when we have updated everything for the
-- first hard fork after Shelley, but before it actually happened. At
-- that moment, we'll trace the KESMetricsData of the upcoming era,
-- instead of the KESMetricsData of the current Shelley era.
combineKESMetrics :: [KESMetricsData] -> KESMetricsData
combineKESMetrics = lastDef NoKESMetricsData
getOne = K . getKESMetricsData (Proxy @blk) . unwrapForgeStateInfo
39 changes: 17 additions & 22 deletions cardano-node/src/Cardano/Tracing/OrphanInstances/HardFork.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import Ouroboros.Consensus.HardFork.Combinator
import Ouroboros.Consensus.HardFork.Combinator.AcrossEras (EraMismatch (..),
OneEraCannotForge (..), OneEraEnvelopeErr (..), OneEraLedgerError (..),
OneEraLedgerUpdate (..), OneEraLedgerWarning (..), OneEraValidationErr (..),
PerEraForgeStateInfo (..), PerEraForgeStateUpdateError (..), mkEraMismatch)
OneEraForgeStateInfo (..), OneEraForgeStateUpdateError (..), mkEraMismatch)
import Ouroboros.Consensus.HardFork.Combinator.Condense ()
import Ouroboros.Consensus.HardFork.History.EraParams (EraParams (..), SafeBeforeEpoch,
SafeZone)
Expand All @@ -46,7 +46,6 @@ import Ouroboros.Consensus.Ledger.SupportsMempool (ApplyTxErr, GenTx,
import Ouroboros.Consensus.Protocol.Abstract (ValidationErr)
import Ouroboros.Consensus.TypeFamilyWrappers
import Ouroboros.Consensus.Util.Condense (Condense (..))
import qualified Ouroboros.Consensus.Util.OptNP as OptNP


--
Expand Down Expand Up @@ -320,23 +319,21 @@ instance ToObject (CannotForge blk) => ToObject (WrapCannotForge blk) where
--

-- It's a type alias:
-- type HardForkForgeStateInfo xs = PerEraForgeStateInfo xs
-- type HardForkForgeStateInfo xs = OneEraForgeStateInfo xs

instance All (ToObject `Compose` WrapForgeStateInfo) xs => ToObject (PerEraForgeStateInfo xs) where
instance All (ToObject `Compose` WrapForgeStateInfo) xs => ToObject (OneEraForgeStateInfo xs) where
toObject verb forgeStateInfo =
mkObject
[ "kind" .= String "HardForkForgeStateInfo"
, "forgeStateInfos" .= toJSON forgeStateInfos
, "forgeStateInfo" .= toJSON forgeStateInfo'
]
where
forgeStateInfos :: [Object]
forgeStateInfos =
catMaybes
. hcollapse
forgeStateInfo' :: Object
forgeStateInfo' =
hcollapse
. hcmap (Proxy @ (ToObject `Compose` WrapForgeStateInfo))
(K . fmap (toObject verb) . unComp)
. OptNP.toNP
. getPerEraForgeStateInfo
(K . toObject verb)
. getOneEraForgeStateInfo
$ forgeStateInfo

instance ToObject (ForgeStateInfo blk) => ToObject (WrapForgeStateInfo blk) where
Expand All @@ -348,23 +345,21 @@ instance ToObject (ForgeStateInfo blk) => ToObject (WrapForgeStateInfo blk) wher
--

-- It's a type alias:
-- type HardForkForgeStateUpdateError xs = PerEraForgeStateUpdateError xs
-- type HardForkForgeStateUpdateError xs = OneEraForgeStateUpdateError xs

instance All (ToObject `Compose` WrapForgeStateUpdateError) xs => ToObject (PerEraForgeStateUpdateError xs) where
instance All (ToObject `Compose` WrapForgeStateUpdateError) xs => ToObject (OneEraForgeStateUpdateError xs) where
toObject verb forgeStateUpdateError =
mkObject
[ "kind" .= String "HardForkForgeStateUpdateError"
, "forgeStateUpdateErrors" .= toJSON forgeStateUpdateErrors
, "forgeStateUpdateError" .= toJSON forgeStateUpdateError'
]
where
forgeStateUpdateErrors :: [Object]
forgeStateUpdateErrors =
catMaybes
. hcollapse
forgeStateUpdateError' :: Object
forgeStateUpdateError' =
hcollapse
. hcmap (Proxy @ (ToObject `Compose` WrapForgeStateUpdateError))
(K . fmap (toObject verb) . unComp)
. OptNP.toNP
. getPerEraForgeStateUpdateError
(K . toObject verb)
. getOneEraForgeStateUpdateError
$ forgeStateUpdateError

instance ToObject (ForgeStateUpdateError blk) => ToObject (WrapForgeStateUpdateError blk) where
Expand Down
6 changes: 4 additions & 2 deletions cardano-node/src/Cardano/Tracing/Tracers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -447,13 +447,15 @@ mkConsensusTracers trSel verb tr nodeKern bcCounters = do
annotateSeverity $ teeTraceBlockFetchDecision verb elidedFetchDecision $ appendName "BlockFetchDecision" tr
, Consensus.blockFetchClientTracer = tracerOnOff (traceBlockFetchClient trSel) verb "BlockFetchClient" tr
, Consensus.blockFetchServerTracer = tracerOnOff (traceBlockFetchServer trSel) verb "BlockFetchServer" tr
, Consensus.forgeStateInfoTracer = tracerOnOff' (traceForgeStateInfo trSel) $ forgeStateInfoTracer (Proxy @ blk) trSel tr
, Consensus.forgeStateInfoTracer = tracerOnOff' (traceForgeStateInfo trSel) $
contramap (\(Consensus.TraceLabelCreds _ ev) -> ev) $
forgeStateInfoTracer (Proxy @ blk) trSel tr
, Consensus.txInboundTracer = tracerOnOff (traceTxInbound trSel) verb "TxInbound" tr
, Consensus.txOutboundTracer = tracerOnOff (traceTxOutbound trSel) verb "TxOutbound" tr
, Consensus.localTxSubmissionServerTracer = tracerOnOff (traceLocalTxSubmissionServer trSel) verb "LocalTxSubmissionServer" tr
, Consensus.mempoolTracer = tracerOnOff' (traceMempool trSel) $ mempoolTracer trSel tr bcCounters
, Consensus.forgeTracer = tracerOnOff' (traceForge trSel) $
Tracer $ \ev -> do
Tracer $ \(Consensus.TraceLabelCreds _ ev) -> do
traceWith (forgeTracer verb tr forgeTracers nodeKern bcCounters) ev
traceWith (blockForgeOutcomeExtractor
$ toLogObject' verb
Expand Down

0 comments on commit 7548f98

Please sign in to comment.