-
Notifications
You must be signed in to change notification settings - Fork 87
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
Creates 'cardano-node' sublibrary #5082
base: main
Are you sure you want to change the base?
Conversation
6d24443
to
7d6fc86
Compare
7d6fc86
to
d9c4151
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@@ -91,13 +91,14 @@ import Cardano.Network.PeerSelection.LocalRootPeers | |||
import Cardano.Network.PeerSelection.PeerTrustable (PeerTrustable) | |||
import Cardano.Network.Types (LedgerStateJudgement (..), | |||
NumberOfBigLedgerPeers (..)) | |||
import Ouroboros.Cardano.Network.ExtraRootPeers qualified as Cardano | |||
import Ouroboros.Cardano.Network.ExtraRootPeers qualified as ExtraPeers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not make this imported qualified once as Cardano.ExtraPeers
like Cardano.PublicRootPeers
below? This pattern is in a few other places in this patch so I just mention it once here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to qualify ExtraPeers
data type with Cardano to make it obvious it is an ExtraPeer
for Cardano, but then I want to qualify ExtraPeers
module definitions with ExtraPeers
to make it obvious they are coming from ExtraPeers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also imported twice with different qualifications, are we sure it's a good idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it helps clarity when reading the code and understanding where things are coming from.. We also can't have everything qualified under Cardano
since some record fields will clash
-- | This function returns false if non-trustable peers are configured | ||
-- | ||
isValidTrustedPeerConfiguration :: CardanoNetworkTopology -> Bool | ||
isValidTrustedPeerConfiguration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The node also has a check whether the options are compatible with Genesis, ie. we have UseBootstrapPeers enabled but so is Genesis - I'd have to take another look at the node code but maybe that can be moved here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see, I'll double check! I'll be making an integration branch soon and expect to catch more things to add here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @bolt12, some suggestions with possible improvements follow.
import Data.Set qualified as Set | ||
import Ouroboros.Cardano.Network.ExtraRootPeers (ExtraPeers (..)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually space seprate library imports from local ones:
import Data.Set qualified as Set | |
import Ouroboros.Cardano.Network.ExtraRootPeers (ExtraPeers (..)) | |
import Data.Set qualified as Set | |
import Ouroboros.Cardano.Network.ExtraRootPeers (ExtraPeers (..)) |
|
||
socketAddressType :: Socket.SockAddr -> Maybe AddressType | ||
socketAddressType Socket.SockAddrInet {} = Just IPv4Address | ||
socketAddressType Socket.SockAddrInet6 {} = Just IPv6Address | ||
socketAddressType Socket.SockAddrUnix {} = Nothing | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These double empty lines shouldn't be removed.
{-# OPTIONS_GHC -Wno-orphans #-} | ||
module Ouroboros.Cardano.Network.PublicRootPeers where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{-# OPTIONS_GHC -Wno-orphans #-} | |
module Ouroboros.Cardano.Network.PublicRootPeers where | |
{-# OPTIONS_GHC -Wno-orphans #-} | |
module Ouroboros.Cardano.Network.PublicRootPeers where |
@@ -0,0 +1,132 @@ | |||
{-# LANGUAGE FlexibleInstances #-} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From which module in main
this code is coming from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean? This is required for the instances that are defined in this module:
e.g.:
instance ( Ord peeraddr
) => Semigroup (CardanoPublicRootPeers peeraddr) where
(<>) = merge
module Ouroboros.Cardano.Network.Types where | ||
|
||
data ChurnMode = ChurnModeBulkSync | ||
| ChurnModeNormal | ||
deriving Show |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not move this to Ouroboros.Cardano.PeerSelection.Churn
? Types
at this level is a bit general for churn specific stuff, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's a much better thing to do!
@@ -91,13 +91,14 @@ import Cardano.Network.PeerSelection.LocalRootPeers | |||
import Cardano.Network.PeerSelection.PeerTrustable (PeerTrustable) | |||
import Cardano.Network.Types (LedgerStateJudgement (..), | |||
NumberOfBigLedgerPeers (..)) | |||
import Ouroboros.Cardano.Network.ExtraRootPeers qualified as Cardano | |||
import Ouroboros.Cardano.Network.ExtraRootPeers qualified as ExtraPeers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also imported twice with different qualifications, are we sure it's a good idea?
=> Gen (PublicRootPeers (Cardano.ExtraPeers peeraddr) peeraddr) | ||
=> Gen (CardanoPublicRootPeers peeraddr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
import Data.Map qualified as Map | ||
import Data.Map.Strict (Map) | ||
import Ouroboros.Network.Diffusion.Configuration (DiffusionMode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's group imports
import Data.Map qualified as Map | |
import Data.Map.Strict (Map) | |
import Ouroboros.Network.Diffusion.Configuration (DiffusionMode) | |
import Data.Map qualified as Map | |
import Data.Map.Strict (Map) | |
import Ouroboros.Network.Diffusion.Configuration (DiffusionMode) |
@@ -1797,7 +1796,6 @@ data TracePeerSelection extraDebugState extraFlags extraPeers peeraddr = | |||
-- | |||
|
|||
| TraceChurnWait DiffTime | |||
| TraceChurnMode ChurnMode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we have an extra tracer just for ChurnMode
; When we'll be integrating with cardano-node
it should be configured afterTracePeerSelection
(no need for a separate option for enabling / disabling it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes!
import Control.Concurrent.Class.MonadSTM | ||
import Data.Set (Set) | ||
import Data.Set qualified as Set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could organise the imports better.
8b6facd
to
cfcdb12
Compare
cfcdb12
to
d4cbca6
Compare
This is a Cardano specific type and this is a step to remove any lingering cardano-node details from the network code and move them to the cardano-node sublibrary.
This is a Cardano specific type and this is a step to remove any lingering cardano-node details from the network code and move them to the cardano-node sublibrary.
d4cbca6
to
7b2cd34
Compare
Two of the steps in #5065.
This PR:
ouroboros-network
that contains all cardano-node specific data types and definitions.NetworkTopology
data definition and auxiliary functions to the 'cardano-node' sublibrary.The idea is that everything network related currently in cardano-node that requires integration, should live in this sublibrary. This will make maintance and future integration work easier.