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

peer selection exports #5081

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

peer selection exports #5081

wants to merge 3 commits into from

Conversation

coot
Copy link
Contributor

@coot coot commented Feb 20, 2025

  • peer-selection: import and export lists
  • sim-tests-lib: code style
  • ouroboros-network: renamed sim-test-lib as testlib

Depends on #5007

@coot coot requested a review from a team as a code owner February 20, 2025 10:08
@coot coot force-pushed the coot/peer-selection-exports branch from bb7e605 to 0255364 Compare February 20, 2025 14:39
@coot coot force-pushed the coot/peer-selection-exports branch from 0255364 to e233433 Compare February 21, 2025 15:01
@coot coot enabled auto-merge February 21, 2025 15:42
@coot coot self-assigned this Feb 21, 2025
@coot coot changed the title coot/peer selection exports peer selection exports Feb 21, 2025
Copy link
Contributor

@bolt12 bolt12 left a comment

Choose a reason for hiding this comment

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

I am not entirely sold on this import changes. It is nice to clean up imports and simplify them but I think meta modules are a bit of a stretch. I usually import the module that owns the expression definition or data type, I don't usually import from top level modules like these, I think it makes it clearer where things are coming from.

Comment on lines +1 to +42
{-# LANGUAGE ExplicitNamespaces #-}

module Ouroboros.Network.PeerSelection
( module Governor
, module PeerSelection
, module PeerSelection.Types
, module PeerSelection.PublicRootPeers
, module PeerSelection.PeerStateActions
, module PeerSelection.PeerSelectionActions
, module PeerSelection.RelayAccessPoint
, module PeerSelection.LedgerPeers
, module PeerSelection.PeerMetrics
, module PeerSelection.Churn
, module PeerSelection.PeerAdvertise
, module PeerSelection.PeerSharing
) where

import Ouroboros.Network.PeerSelection.Churn as PeerSelection.Churn
-- Only essential `Governor` types.
import Ouroboros.Network.PeerSelection.Governor as Governor
(DebugPeerSelection (..), PeerSelectionActions,
PeerSelectionInterfaces (..), PeerSelectionPolicy (..),
PeerSelectionState, PeerSelectionTargets (..), PeerStateActions,
PickPolicy)
import Ouroboros.Network.PeerSelection.LedgerPeers as PeerSelection.LedgerPeers
(AfterSlot (..), IsBigLedgerPeer (..), LedgerPeerSnapshot (..),
LedgerPeers (..), LedgerPeersConsensusInterface (..),
LedgerPeersKind (..), NumberOfPeers (..), TraceLedgerPeers (..),
UseLedgerPeers (..), WithLedgerPeersArgs (..), withLedgerPeers)
import Ouroboros.Network.PeerSelection.PeerAdvertise as PeerSelection.PeerAdvertise
import Ouroboros.Network.PeerSelection.PeerMetric as PeerSelection.PeerMetrics
(PeerMetrics, PeerMetricsConfiguration (..), ReportPeerMetrics (..),
newPeerMetric, newPeerMetric', nullMetric, reportMetric)
import Ouroboros.Network.PeerSelection.PeerSelectionActions as PeerSelection.PeerSelectionActions
import Ouroboros.Network.PeerSelection.PeerSharing as PeerSelection.PeerSharing
import Ouroboros.Network.PeerSelection.PeerStateActions as PeerSelection.PeerStateActions
import Ouroboros.Network.PeerSelection.PublicRootPeers as PeerSelection.PublicRootPeers
(PublicRootPeers)
import Ouroboros.Network.PeerSelection.RelayAccessPoint as PeerSelection.RelayAccessPoint
(DomainAccessPoint (..), IP (..), PortNumber, RelayAccessPoint (..))
import Ouroboros.Network.PeerSelection.Types as PeerSelection
import Ouroboros.Network.PeerSelection.Types as PeerSelection.Types
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like this... I prefer for the imports to come from the place where the expression is defined. Meta modules like these are confusing for large codebases

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's annoying when we have to solve 10s of rebase conflicts in imports; additionally we often introduced more mess into import statements which makes it less readable.

Finding out where something comes from is not that difficult, if one knows that it's coming from PeerSelection, or RootPeersDNS even without tools like hls or ghc-tags-plugin, a simple grep is enough (although once one is familiar it's easy to guess).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another solution could be to have explicit imports in the meta modules, but I am not sure if it's worth it in times of hls / ghc-tags-plugin etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right but, I also use HLS to manage automated imports for me and I usually import from the modules which defined the expression/function. So my worry is that we'll have inconsistencies still in the imports. At least I think the name should be more obvious so I know I should import from the Meta/General/Imports/All modules

Comment on lines +1 to +14
module Ouroboros.Network.PeerSelection.RootPeersDNS
( PeerActionsDNS (..)
, module DNSActions
, module DNSSemaphore
, module LedgerPeers
, module LocalRootPeers
, module PublicRootPeers
) where

import Data.IP (IP)
import Network.Socket (PortNumber)

import Ouroboros.Network.PeerSelection.RootPeersDNS.DNSActions

-- | Record of some parameters that are commonly used together
--
data PeerActionsDNS peeraddr resolver exception m = PeerActionsDNS {
paToPeerAddr :: IP -> PortNumber -> peeraddr,
paDnsActions :: DNSActions resolver exception m
}
import Ouroboros.Network.PeerSelection.RootPeersDNS.DNSActions as DNSActions
import Ouroboros.Network.PeerSelection.RootPeersDNS.DNSSemaphore as DNSSemaphore
import Ouroboros.Network.PeerSelection.RootPeersDNS.LedgerPeers as LedgerPeers
import Ouroboros.Network.PeerSelection.RootPeersDNS.LocalRootPeers as LocalRootPeers
import Ouroboros.Network.PeerSelection.RootPeersDNS.PublicRootPeers as PublicRootPeers
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. We can move PeerActionsDNS to a better module but we should import it from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants