Skip to content

Commit

Permalink
Adapt to the reorganised Node.run arguments in consensus
Browse files Browse the repository at this point in the history
In IntersectMBO/ouroboros-network#2720 we reorganised
the arguments to `Node.run` so that the consensus ThreadNet tests can use the
same `Node.run` function as the real node while using a custom network layer.

In this commit we propagate that change.

For people that want to override some arguments that now seem to have
disappeared: they have been moved to the `LowLevelRunNodeArgs` record in
consensus. See the `stdLowLevelRunNodeArgsIO` and `Node.runWith` functions for
constructing and running with custom `LowLevelRunNodeArgs`.
  • Loading branch information
mrBliss committed Nov 12, 2020
1 parent 53f4caa commit 81fdaf6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 60 deletions.
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: da2130c6b19d38cb9ec519ed4fb2d644b35e55cb
--sha256: 1jkic85qzp7lh2lab3iw6g1h71qar1ahvx0kinmh8hwjdrmyg6fl
tag: 35c5950088a7c9fc725868f1e68a2f3bf14f0595
--sha256: 1xizr0r36xnsmkcd1p0c9m1bj918n5bja1p6y30qrbxsph5wn94v
subdir:
io-sim
io-sim-classes
Expand Down
81 changes: 23 additions & 58 deletions cardano-node/src/Cardano/Node/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
{-# LANGUAGE GADTs #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}

#if !defined(mingw32_HOST_OS)
#define UNIX
Expand Down Expand Up @@ -56,23 +55,16 @@ import Cardano.Tracing.Config (TraceOptions (..), TraceSelection (..))
import Ouroboros.Consensus.Block (BlockProtocol)
import qualified Ouroboros.Consensus.Cardano as Consensus
import qualified Ouroboros.Consensus.Config as Consensus
import Ouroboros.Consensus.Config.SupportsNode (ConfigSupportsNode (..))
import Ouroboros.Consensus.Fragment.InFuture (defaultClockSkew)
import Ouroboros.Consensus.Config.SupportsNode (getNetworkMagic)
import Ouroboros.Consensus.Node (DiffusionArguments (..), DiffusionTracers (..),
DnsSubscriptionTarget (..), IPSubscriptionTarget (..), NodeArgs (..), RunNode,
RunNodeArgs (..))
DnsSubscriptionTarget (..), IPSubscriptionTarget (..), RunNode,
RunNodeArgs (..), StdRunNodeArgs (..))
import qualified Ouroboros.Consensus.Node as Node (getChainDB, run)
import Ouroboros.Consensus.Node.NetworkProtocolVersion
import Ouroboros.Consensus.Node.ProtocolInfo
import Ouroboros.Consensus.Util.Orphans ()
import Ouroboros.Network.BlockFetch (BlockFetchConfiguration (..))
import Ouroboros.Network.Magic (NetworkMagic (..))
import Ouroboros.Network.NodeToNode (AcceptedConnectionsLimit (..), DiffusionMode)

import qualified Ouroboros.Consensus.Storage.ChainDB as ChainDB
import Ouroboros.Consensus.Storage.ImmutableDB (ValidationPolicy (..))
import Ouroboros.Consensus.Storage.VolatileDB (BlockValidationPolicy (..))

import Cardano.Node.Configuration.Socket (SocketOrSocketInfo (..),
gatherConfiguredSockets, getSocketOrSocketInfoAddr)
import Cardano.Node.Configuration.Topology
Expand Down Expand Up @@ -194,7 +186,7 @@ handleSimpleNode
-> IO ()
handleSimpleNode p trace nodeTracers nc onKernel = do

let pInfo@ProtocolInfo{ pInfoConfig = cfg } = Consensus.protocolInfo p
let pInfo = Consensus.protocolInfo p
tracer = toLogObject trace

createTracers nc trace tracer
Expand Down Expand Up @@ -249,53 +241,26 @@ handleSimpleNode p trace nodeTracers nc onKernel = do

withShutdownHandling nc trace $ \sfds ->
Node.run
RunNodeArgs {
rnTraceConsensus = consensusTracers nodeTracers,
rnTraceNTN = nodeToNodeTracers nodeTracers,
rnTraceNTC = nodeToClientTracers nodeTracers,
rnTraceDB = chainDBTracer nodeTracers,
rnTraceDiffusion = diffusionTracers,
rnDiffusionArguments = diffusionArguments,
rnNetworkMagic = getNetworkMagic (Consensus.configBlock cfg),
rnDatabasePath = dbPath,
rnProtocolInfo = pInfo,
rnCustomiseChainDbArgs = customiseChainDbArgs $ ncValidateDB nc,
rnCustomiseNodeArgs = customiseNodeArgs (ncMaxConcurrencyBulkSync nc)
(ncMaxConcurrencyDeadline nc),
rnNodeToNodeVersions = supportedNodeToNodeVersions (Proxy @blk),
rnNodeToClientVersions = supportedNodeToClientVersions (Proxy @blk),
rnNodeKernelHook = \registry nodeKernel -> do
maybeSpawnOnSlotSyncedShutdownHandler nc sfds trace registry
(Node.getChainDB nodeKernel)
onKernel nodeKernel,
rnMaxClockSkew = defaultClockSkew
}
RunNodeArgs
{ rnTraceConsensus = consensusTracers nodeTracers
, rnTraceNTN = nodeToNodeTracers nodeTracers
, rnTraceNTC = nodeToClientTracers nodeTracers
, rnProtocolInfo = pInfo
, rnNodeKernelHook = \registry nodeKernel -> do
maybeSpawnOnSlotSyncedShutdownHandler nc sfds trace registry
(Node.getChainDB nodeKernel)
onKernel nodeKernel
}
StdRunNodeArgs
{ srnBfcMaxConcurrencyBulkSync = unMaxConcurrencyBulkSync <$> ncMaxConcurrencyBulkSync nc
, srnBfcMaxConcurrencyDeadline = unMaxConcurrencyDeadline <$> ncMaxConcurrencyDeadline nc
, srcChainDbValidateOverride = ncValidateDB nc
, srnDatabasePath = dbPath
, srnDiffusionArguments = diffusionArguments
, srnDiffusionTracers = diffusionTracers
, srnTraceChainDB = chainDBTracer nodeTracers
}
where
customiseNodeArgs :: Maybe MaxConcurrencyBulkSync
-> Maybe MaxConcurrencyDeadline
-> NodeArgs IO RemoteConnectionId LocalConnectionId blk
-> NodeArgs IO RemoteConnectionId LocalConnectionId blk
customiseNodeArgs bulk_m deadline_m args@NodeArgs{ blockFetchConfiguration } = args {
blockFetchConfiguration = blockFetchConfiguration {
bfcMaxConcurrencyBulkSync = maybe (bfcMaxConcurrencyBulkSync blockFetchConfiguration)
unMaxConcurrencyBulkSync bulk_m
, bfcMaxConcurrencyDeadline = maybe (bfcMaxConcurrencyDeadline blockFetchConfiguration)
unMaxConcurrencyDeadline deadline_m
}
}

customiseChainDbArgs :: Bool
-> ChainDB.ChainDbArgs Identity IO blk
-> ChainDB.ChainDbArgs Identity IO blk
customiseChainDbArgs runValid args
| runValid
= args
{ ChainDB.cdbImmutableDbValidation = ValidateAllChunks
, ChainDB.cdbVolatileDbValidation = ValidateAll
}
| otherwise
= args

createDiffusionTracers :: Tracers RemoteConnectionId LocalConnectionId blk
-> DiffusionTracers
createDiffusionTracers nodeTracers' = DiffusionTracers
Expand Down

0 comments on commit 81fdaf6

Please sign in to comment.