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 cardano-node after addition of the new BulkSync implementation #5942

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 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
29 changes: 29 additions & 0 deletions cardano-node/src/Cardano/Node/Configuration/POM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import Cardano.Tracing.OrphanInstances.Network ()
import Ouroboros.Consensus.Mempool (MempoolCapacityBytes (..),
MempoolCapacityBytesOverride (..))
import qualified Ouroboros.Consensus.Node as Consensus (NetworkP2PMode (..))
import Ouroboros.Consensus.Node.Genesis (GenesisConfig,
GenesisConfigFlags (..), defaultGenesisConfigFlags, mkGenesisConfig)
import Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy (NumOfDiskSnapshots (..),
SnapshotInterval (..))
import Ouroboros.Network.NodeToNode (AcceptedConnectionsLimit (..), DiffusionMode (..))
Expand Down Expand Up @@ -162,6 +164,9 @@ data NodeConfiguration

-- Enable Peer Sharing
, ncPeerSharing :: PeerSharing

-- Genesis syncing protocol configuration
, ncGenesisConfig :: GenesisConfig
} deriving (Eq, Show)


Expand Down Expand Up @@ -225,6 +230,10 @@ data PartialNodeConfiguration

-- Peer Sharing
, pncPeerSharing :: !(Last PeerSharing)

-- Genesis syncing protocol
, pncEnableGenesis :: !(Last Bool)
, pncGenesisConfigFlags :: !(Last GenesisConfigFlags)
} deriving (Eq, Generic, Show)

instance AdjustFilePaths PartialNodeConfiguration where
Expand Down Expand Up @@ -321,6 +330,11 @@ instance FromJSON PartialNodeConfiguration where
-- DISABLED BY DEFAULT
pncPeerSharing <- Last <$> v .:? "PeerSharing" .!= Just PeerSharingDisabled

-- Genesis syncing protocol
-- DISABLED BY DEFAULT
pncEnableGenesis <- Last <$> v .:? "EnableGenesis" .!= Just False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why two configuration values? If the genesis config plans aren't present then we know to not enable it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, what would you prefer instead? Something like

Genesis:
  Enable: True
  # optionally
  LowLevelOptions: 
    ....

?

pncGenesisConfigFlags <- Last <$> v .:? "LowLevelGenesisOptions"

pure PartialNodeConfiguration {
pncProtocolConfig
, pncSocketConfig = Last . Just $ SocketConfig mempty mempty mempty pncSocketPath
Expand Down Expand Up @@ -355,6 +369,8 @@ instance FromJSON PartialNodeConfiguration where
, pncTargetNumberOfActiveBigLedgerPeers
, pncEnableP2P
, pncPeerSharing
, pncEnableGenesis
, pncGenesisConfigFlags
}
where
parseMempoolCapacityBytesOverride v = parseNoOverride <|> parseOverride
Expand Down Expand Up @@ -531,6 +547,8 @@ defaultPartialNodeConfiguration =
, pncTargetNumberOfActiveBigLedgerPeers = Last (Just 5)
, pncEnableP2P = Last (Just EnabledP2PMode)
, pncPeerSharing = Last (Just PeerSharingDisabled)
, pncEnableGenesis = Last (Just False)
, pncGenesisConfigFlags = Last (Just defaultGenesisConfigFlags)
}

lastOption :: Parser a -> Parser (Last a)
Expand Down Expand Up @@ -596,6 +614,16 @@ makeNodeConfiguration pnc = do
lastToEither "Missing PeerSharing"
$ pncPeerSharing pnc

enableGenesis <-
lastToEither "Missing EnableGenesis"
$ pncEnableGenesis pnc

mGenesisConfigFlags <- if enableGenesis
then fmap Just <$>
lastToEither "Missing GenesisConfigFlags"
$ pncGenesisConfigFlags pnc
else pure Nothing

-- TODO: This is not mandatory
experimentalProtocols <-
lastToEither "Missing ExperimentalProtocolsEnabled" $
Expand Down Expand Up @@ -643,6 +671,7 @@ makeNodeConfiguration pnc = do
EnabledP2PMode -> SomeNetworkP2PMode Consensus.EnabledP2PMode
DisabledP2PMode -> SomeNetworkP2PMode Consensus.DisabledP2PMode
, ncPeerSharing
, ncGenesisConfig = mkGenesisConfig mGenesisConfigFlags
}

ncProtocol :: NodeConfiguration -> Protocol
Expand Down
13 changes: 13 additions & 0 deletions cardano-node/src/Cardano/Node/Orphans.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Cardano.Node.Orphans () where

import Cardano.Api ()

import Ouroboros.Consensus.Node.Genesis (GenesisConfigFlags (..))
import Ouroboros.Network.NodeToNode (AcceptedConnectionsLimit (..))
import Ouroboros.Network.SizeInBytes (SizeInBytes (..))

Expand Down Expand Up @@ -38,3 +39,15 @@ instance FromJSON AcceptedConnectionsLimit where
<$> v .: "hardLimit"
<*> v .: "softLimit"
<*> v .: "delay"

instance FromJSON GenesisConfigFlags where
parseJSON = withObject "GenesisConfigFlags" $ \v ->
GenesisConfigFlags
<$> v .:? "EnableCSJ" .!= True
<*> v .:? "EnableLoEAndGDD" .!= True
<*> v .:? "EnableLoP" .!= True
<*> v .:? "BulkSyncGracePeriod"
<*> v .:? "BucketCapacity"
<*> v .:? "BucketRate"
<*> v .:? "CSJJumpSize"
<*> v .:? "GDDRateLimit"
2 changes: 2 additions & 0 deletions cardano-node/src/Cardano/Node/Parsers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ nodeRunParser = do
, pncTargetNumberOfActiveBigLedgerPeers = mempty
, pncEnableP2P = mempty
, pncPeerSharing = mempty
, pncEnableGenesis = mempty
, pncGenesisConfigFlags = mempty
}

parseSocketPath :: Text -> Parser SocketPath
Expand Down
14 changes: 9 additions & 5 deletions cardano-node/src/Cardano/Node/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}

{-# LANGUAGE TypeApplications #-}

Expand Down Expand Up @@ -45,7 +47,7 @@ import "contra-tracer" Control.Tracer
import Data.Either (partitionEithers)
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import Data.Maybe (catMaybes, fromMaybe, mapMaybe)
import Data.Maybe (catMaybes, fromMaybe, mapMaybe, isJust)
import Data.Monoid (Last (..))
import Data.Proxy (Proxy (..))
import Data.Text (Text, breakOn, pack)
Expand Down Expand Up @@ -93,9 +95,11 @@ import Cardano.Tracing.Config (TraceOptions (..), TraceSelection (..))

import qualified Ouroboros.Consensus.Config as Consensus
import Ouroboros.Consensus.Config.SupportsNode (ConfigSupportsNode (..))
import qualified Ouroboros.Consensus.MiniProtocol.ChainSync.Client as ChainSync.Client
import Ouroboros.Consensus.Node (DiskPolicyArgs (..), NetworkP2PMode (..),
RunNodeArgs (..), StdRunNodeArgs (..))
import qualified Ouroboros.Consensus.Node as Node (getChainDB, run)
import qualified Ouroboros.Consensus.Node.Genesis as Genesis
import Ouroboros.Consensus.Node.NetworkProtocolVersion
import Ouroboros.Consensus.Node.ProtocolInfo
import Ouroboros.Consensus.Util.Orphans ()
Expand Down Expand Up @@ -476,6 +480,7 @@ handleSimpleNode blockType runP p2pMode tracers nc onKernel = do
, rnEnableP2P = p2pMode
, rnPeerSharing = ncPeerSharing nc
, rnGetUseBootstrapPeers = readTVar useBootstrapVar
, rnGenesisConfig = ncGenesisConfig nc
}
#ifdef UNIX
-- initial `SIGHUP` handler, which only rereads the topology file but
Expand Down Expand Up @@ -508,8 +513,7 @@ handleSimpleNode blockType runP p2pMode tracers nc onKernel = do
rnNodeKernelHook nodeArgs registry nodeKernel
}
StdRunNodeArgs
{ srnBfcMaxConcurrencyBulkSync = unMaxConcurrencyBulkSync <$> ncMaxConcurrencyBulkSync nc
Jimbo4350 marked this conversation as resolved.
Show resolved Hide resolved
, srnBfcMaxConcurrencyDeadline = unMaxConcurrencyDeadline <$> ncMaxConcurrencyDeadline nc
{ srnBfcMaxConcurrencyDeadline = unMaxConcurrencyDeadline <$> ncMaxConcurrencyDeadline nc
, srnChainDbValidateOverride = ncValidateDB nc
, srnDiskPolicyArgs = diskPolicyArgs
, srnDatabasePath = dbPath
Expand Down Expand Up @@ -559,6 +563,7 @@ handleSimpleNode blockType runP p2pMode tracers nc onKernel = do
, rnEnableP2P = p2pMode
, rnPeerSharing = ncPeerSharing nc
, rnGetUseBootstrapPeers = pure DontUseBootstrapPeers
, rnGenesisConfig = ncGenesisConfig nc
}
#ifdef UNIX
-- initial `SIGHUP` handler; it only warns that neither updating of
Expand All @@ -581,8 +586,7 @@ handleSimpleNode blockType runP p2pMode tracers nc onKernel = do
rnNodeKernelHook nodeArgs registry nodeKernel
}
StdRunNodeArgs
{ srnBfcMaxConcurrencyBulkSync = unMaxConcurrencyBulkSync <$> ncMaxConcurrencyBulkSync nc
, srnBfcMaxConcurrencyDeadline = unMaxConcurrencyDeadline <$> ncMaxConcurrencyDeadline nc
{ srnBfcMaxConcurrencyDeadline = unMaxConcurrencyDeadline <$> ncMaxConcurrencyDeadline nc
, srnChainDbValidateOverride = ncValidateDB nc
, srnDiskPolicyArgs = diskPolicyArgs
, srnDatabasePath = dbPath
Expand Down
21 changes: 17 additions & 4 deletions cardano-node/src/Cardano/Node/Tracing/Consistency.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import Ouroboros.Consensus.BlockchainTime.WallClock.Types (RelativeTim
import Ouroboros.Consensus.BlockchainTime.WallClock.Util (TraceBlockchainTimeEvent (..))
import Ouroboros.Consensus.Cardano.Block
import Ouroboros.Consensus.Ledger.Query (Query)
import Ouroboros.Consensus.Genesis.Governor (TraceGDDEvent)
import Ouroboros.Consensus.Ledger.SupportsMempool (ApplyTxErr, GenTxId)
import Ouroboros.Consensus.Mempool (TraceEventMempool (..))
import Ouroboros.Consensus.MiniProtocol.BlockFetch.Server
Expand All @@ -46,11 +47,13 @@ import Ouroboros.Consensus.MiniProtocol.ChainSync.Client (TraceChainSy
import Ouroboros.Consensus.MiniProtocol.ChainSync.Server (TraceChainSyncServerEvent)
import Ouroboros.Consensus.MiniProtocol.LocalTxSubmission.Server
(TraceLocalTxSubmissionServerEvent (..))
import Ouroboros.Consensus.Node.GSM (TraceGsmEvent)
import qualified Ouroboros.Consensus.Protocol.Ledger.HotKey as HotKey
import qualified Ouroboros.Consensus.Storage.ChainDB as ChainDB
import qualified Ouroboros.Consensus.MiniProtocol.ChainSync.Client.Jumping as CSJumping
import Ouroboros.Network.Block (Point (..), SlotNo, Tip)
import qualified Ouroboros.Network.BlockFetch.ClientState as BlockFetch
import Ouroboros.Network.BlockFetch.Decision
import Ouroboros.Network.BlockFetch.Decision.Trace as BlockFetch
import Ouroboros.Network.ConnectionHandler (ConnectionHandlerTrace (..))
import Ouroboros.Network.ConnectionId (ConnectionId)
import Ouroboros.Network.ConnectionManager.Types (ConnectionManagerTrace (..))
Expand Down Expand Up @@ -151,9 +154,7 @@ getAllNamespaces =
chainSyncServerBlockNS = map (nsGetTuple . nsReplacePrefix ["ChainSync", "ServerBlock"])
(allNamespaces :: [Namespace (TraceChainSyncServerEvent blk)])
blockFetchDecisionNS = map (nsGetTuple . nsReplacePrefix ["BlockFetch", "Decision"])
(allNamespaces :: [Namespace [BlockFetch.TraceLabelPeer
remotePeer
(FetchDecision [Point (Header blk)])]])
(allNamespaces :: [Namespace (TraceDecisionEvent remotePeer (Header blk))])
blockFetchClientNS = map (nsGetTuple . nsReplacePrefix ["BlockFetch", "Client"])
(allNamespaces :: [Namespace (BlockFetch.TraceLabelPeer
remotePeer
Expand Down Expand Up @@ -185,6 +186,15 @@ getAllNamespaces =
blockchainTimeNS = map (nsGetTuple . nsReplacePrefix ["BlockchainTime"])
(allNamespaces :: [Namespace (TraceBlockchainTimeEvent RelativeTime)])

gsmEventNS = map (nsGetTuple . nsReplacePrefix ["GsmEvent"])
(allNamespaces :: [Namespace (TraceGsmEvent selection)])

csjEventNS = map nsGetTuple
(allNamespaces :: [Namespace (CSJumping.TraceEvent peer)])

gddEventNS = map nsGetTuple
(allNamespaces :: [Namespace (TraceGDDEvent peer blk)])

-- Node to client
keepAliveClientNS = map (nsGetTuple . nsReplacePrefix ["Net"])
(allNamespaces :: [Namespace (TraceKeepAliveClient peer)])
Expand Down Expand Up @@ -390,6 +400,9 @@ getAllNamespaces =
<> mempoolNS
<> forgeNS
<> blockchainTimeNS
<> gsmEventNS
<> csjEventNS
<> gddEventNS
-- NodeToClient
<> keepAliveClientNS
<> chainSyncNS
Expand Down
6 changes: 2 additions & 4 deletions cardano-node/src/Cardano/Node/Tracing/Documentation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import qualified Ouroboros.Consensus.Protocol.Ledger.HotKey as HotKey
import qualified Ouroboros.Consensus.Storage.ChainDB as ChainDB
import Ouroboros.Network.Block (Point (..), Serialised, SlotNo, Tip)
import qualified Ouroboros.Network.BlockFetch.ClientState as BlockFetch
import Ouroboros.Network.BlockFetch.Decision
import qualified Ouroboros.Network.BlockFetch.Decision.Trace as BlockFetch
import Ouroboros.Network.ConnectionHandler (ConnectionHandlerTrace (..))
import Ouroboros.Network.ConnectionId (ConnectionId)
import Ouroboros.Network.ConnectionManager.Types (ConnectionManagerTrace (..))
Expand Down Expand Up @@ -278,9 +278,7 @@ docTracersFirstPhase condConfigFileName = do
["BlockFetch", "Decision"]
configureTracers configReflection trConfig [blockFetchDecisionTr]
blockFetchDecisionTrDoc <- documentTracer (blockFetchDecisionTr ::
Trace IO [BlockFetch.TraceLabelPeer
remotePeer
(FetchDecision [Point (Header blk)])])
Trace IO (BlockFetch.TraceDecisionEvent remotePeer (Header blk)))

blockFetchClientTr <- mkCardanoTracer
trBase trForward mbTrEKG
Expand Down
9 changes: 8 additions & 1 deletion cardano-node/src/Cardano/Node/Tracing/Tracers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,17 @@ mkConsensusTracers configReflection trBase trForward mbTrEKG _trDataPoint trConf
!consensusStartupErrorTr <- mkCardanoTracer
trBase trForward mbTrEKG
["Consensus", "Startup"]
configureTracers configReflection trConfig [consensusStartupErrorTr]

!consensusGsmTr <- mkCardanoTracer
trBase trForward mbTrEKG
["Consensus", "GSM"]
configureTracers configReflection trConfig [consensusGsmTr]

configureTracers configReflection trConfig [consensusStartupErrorTr]
!consensusCsjTr <- mkCardanoTracer
trBase trForward mbTrEKG
["Consensus", "CSJ"]
configureTracers configReflection trConfig [consensusCsjTr]

pure $ Consensus.Tracers
{ Consensus.chainSyncClientTracer = Tracer $
Expand Down Expand Up @@ -361,6 +366,8 @@ mkConsensusTracers configReflection trBase trForward mbTrEKG _trDataPoint trConf
traceWith consensusStartupErrorTr . ConsensusStartupException
, Consensus.gsmTracer = Tracer $
traceWith consensusGsmTr
, Consensus.gddTracer = Tracer $ \_ -> pure () -- TODO
, Consensus.csjTracer = Tracer $ traceWith consensusCsjTr
}

mkNodeToClientTracers :: forall blk.
Expand Down
Loading
Loading