IntersectMBO / ouroboros-network

Specifications of network protocols and implementations of components running these protocols which support a family of Ouroboros Consesus protocols; the diffusion layer of the Cardano Node.
https://ouroboros-network.cardano.intersectmbo.org
Apache License 2.0
275 stars 86 forks source link

data diffusion startup in cardano-node #2067

Open coot opened 4 years ago

coot commented 4 years ago

Currently the flow of data in cardano-node is not very clear. Partially the confusion comes from the fact that runDataDiffusion is run by consensus application. The current flow is:

environment (genesis, config, cli options) → consensus protocol setupconsensus options & network optionsconsensus starts data diffusion

Some network options go into consensus like network magic (it's needed to start protocols), some not (node addresses for diffusion). We should have something like this:

runDataDiffusion
  ∷ DiffusionArguments
  → (NetworkArgumentsRequiredByConsensus → m NodeToNodeProtocols)
  → m Void

NetworkArgumentsRequiredByConsensus would be passed as part of DiffusionArguments and they can come from environment (genesis, CLI args, etc), without going through consensus setup first (the protocolInfo and friends).

nfrisby commented 3 years ago

Currently (4a058ccc8), it looks like this:

runDataDiffusion
    :: DiffusionTracers
    -> DiffusionArguments 
    -> DiffusionApplications
    -> IO ()

Ouroboros.Consensus.Node.run receives all sorts of data from from the cardano-node invocation, including DiffusionTracers and DiffusionArguments which is simply passes through. With the rest of that data, run spawns the ChainDB and the NodeKernel. From these it derives the various mini protocol applications, which it then bundles up as DiffusionApplications, letting it ultimately continue as runDataDiffusion.

At the moment, NetworkMagic is passed explicitly to run, but it's only used in the "bundle up as DiffusionApplications" step.

I'm not aware of any other network options being passed-through via Node.run to runDataDiffusion. Would you share a concrete list of what you (even roughly) had in mind for the contents of NetworkArgumentsRequiredByConsensus?

For convenience: here's the current cardano-node invocation:

https://github.com/input-output-hk/cardano-node/blob/623fbe6af6d28555432730ea89d6da0c05391c1d/cardano-node/src/Cardano/Node/Run.hs#L268-L289

coot commented 3 years ago

@nfrisby you maybe right that's only NetworkMagic. I'll review this once I'm done with connection-manager & p2p-governor.