-
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
Reusable Diffusion - Make diffusion fully polymorphic #5016
base: main
Are you sure you want to change the base?
Conversation
3cdb9a3
to
f00952f
Compare
Cardano.Node.ConsensusMode | ||
Cardano.Node.PeerSelection.Bootstrap | ||
Cardano.Node.PeerSelection.LocalRootPeers | ||
Cardano.Node.PeerSelection.PeerTrustable | ||
Cardano.Node.Types |
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.
Check what consensus uses.
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 did you decide to use?
ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/Diffusion/Policies.hs
Show resolved
Hide resolved
ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/PeerSelection/Cardano/MockEnvironment.hs
Outdated
Show resolved
Hide resolved
ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/Types.hs
Outdated
Show resolved
Hide resolved
ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/Types.hs
Outdated
Show resolved
Hide resolved
ouroboros-network/src/Ouroboros/Network/PeerSelection/PublicRootPeers.hs
Show resolved
Hide resolved
ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor.hs
Outdated
Show resolved
Hide resolved
ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor/Types.hs
Outdated
Show resolved
Hide resolved
ouroboros-network/src/Cardano/Network/PeerSelection/Governor/Types.hs
Outdated
Show resolved
Hide resolved
ouroboros-network/src/Ouroboros/Network/Diffusion/MinimalP2P.hs
Outdated
Show resolved
Hide resolved
c14d5cb
to
3b30f43
Compare
a step toward haskell blockchain sdk? 😄 |
@yihuang as you can see from the PR description this is some interesting step towards a fully polymorphic diffusion that might be used by others to create their own overlay network! Thank you for noticing 😃 |
f922210
to
3cdf98d
Compare
There's a cyclic dependency issue in this commit that is fixed in the next one. The problem is that I pulled out `ConsensusModePeerTargets` which depend on `PeerSelectionTargets` and then the module that defines `PeerSelectionTargets` requires `ConsensusModePeerTargets`. This is fixed by abstracting over Cardano Node specific types such as `ConsensusModePeerTargets`.
Moved Diffusion Cardano specifics to their own folder, separating utilities and functions accordingly. Changed Diffusion selection by splitting P2P in two: P2PCardano and P2P. The former instantiates diffusion using Cardano Node specifics. The latter is able to accommodate with other use cases. Added a Minimal/Node.hs that is incomplete but will hold the minimal Node diffusion instantiation example that highlights how one can use their own custom types.
- Removed PeerSelectionActionsArgs: This data type was bit redundant. - Reorganized DNSActions and LedgerPeersArgs - Improved API for PeerSelectionActions
fb13f01
to
bd855c2
Compare
bd855c2
to
ce99e1d
Compare
Make PeerSelection{Views, Counters} extensible by third party users. Generalised PublicRootPeers First refactor of Outbound Governor
- Generalize MinimalP2P Module - `MinimalP2P` is _the_ module for diffusion initialization. - Updated parameter plumbing to support generalization and polymorphism. - Enhance ArgumentsExtra - Added additional parameters to `ArgumentsExtra` to facilitate a more general and polymorphic diffusion setup. This includes `requestPublicRootPeers`, `peerChurnGovernor`, etc.. - Refactor PeerSelection.Governor.Monitor - Moved Cardano-specific monitoring actions to a separate module. - Implemented general `localRoots` and `targetPeers` monitoring actions. - Pulled out Cardano specific implementation details that allowed to generalise the minimal set of monitoring actions. Added fields to `ExtraGuardedDecisions` so that 3rd party users can pass their own `localRoots` and `targetPeers` actions and also backdoors/callbacks like `abortGovernor`, `updateWithState` to not only support Cardano specific needs but to give more power/flexibility to 3rd party users. - Polymorphize Diffusion Module - Removed `CardanoP2P` dependencies from the `Diffusion` module. - Ensured the `Diffusion` module remains fully polymorphic and adaptable to different use cases. - Refactored test suite to compile with new changes.
Make addresses polymorphic
ce99e1d
to
5400a7c
Compare
instance ( Ord peeraddr | ||
, extraPeers ~ CardanoPublicRootPeers peeraddr | ||
) => Semigroup (PublicRootPeers extraPeers peeraddr) 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.
instance ( Ord peeraddr | |
, extraPeers ~ CardanoPublicRootPeers peeraddr | |
) => Semigroup (PublicRootPeers extraPeers peeraddr) where | |
instance ( Ord peeraddr | |
) => Semigroup (PublicRootPeers (CardanoPublicRootPeers peeraddr) peeraddr) 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.
ref: cb0da21
instance ( Ord peeraddr | ||
, extraPeers ~ CardanoPublicRootPeers peeraddr | ||
) => Monoid (PublicRootPeers extraPeers peeraddr) 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.
same suggestion as above.
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.
Cardano.Node.ConsensusMode | ||
Cardano.Node.PeerSelection.Bootstrap | ||
Cardano.Node.PeerSelection.LocalRootPeers | ||
Cardano.Node.PeerSelection.PeerTrustable | ||
Cardano.Node.Types |
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 did you decide to use?
newtype MinBigLedgerPeersForTrustedState = | ||
MinBigLedgerPeersForTrustedState { getMinBigLedgerPeersForTrustedState :: Int } |
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.
newtype MinBigLedgerPeersForTrustedState = | |
MinBigLedgerPeersForTrustedState { getMinBigLedgerPeersForTrustedState :: Int } | |
newtype NumberOfBigLedgerPeers = | |
NumberOfBigLedgerPeers { getNumberOfBigLedgerPeers :: Int } |
the rest is explained in the haddock.
targetNumberOfRootPeers = 1, | ||
targetNumberOfKnownPeers = 1, | ||
targetNumberOfEstablishedPeers = 1, | ||
targetNumberOfActivePeers = 1, |
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 the targets are changed?
ref: cb0da21
targetNumberOfRootPeers = 0, | ||
targetNumberOfKnownPeers = 0, | ||
targetNumberOfEstablishedPeers = 0, | ||
targetNumberOfActivePeers = 0, |
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 the targets are changed?
ref: cb0da21
, caeConsensusMode = aConsensusMode na | ||
, caePeerTargets = aPeerTargets na |
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 should drop the a
prefix
, caeConsensusMode = aConsensusMode na | |
, caePeerTargets = aPeerTargets na | |
, caeConsensusMode = consensusMode na | |
, caePeerTargets = peerTargets na |
ref: cb0da21
=> Set peeraddr | ||
-> PublicRootPeers extraPeers peeraddr | ||
fromLedgerPeers lp = | ||
(empty mempty) { getLedgerPeers = lp } |
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.
empty mempty sounds a bit like Humpty Dumpty 😁
instance ( Ord peeraddr | ||
, extraPeers ~ CardanoPublicRootPeers peeraddr | ||
) => Semigroup (PublicRootPeers extraPeers peeraddr) 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.
ref: cb0da21
data CardanoPublicRootPeers peeraddr = | ||
CardanoPublicRootPeers | ||
{ cprpGetPublicConfigPeers :: !(Map peeraddr PeerAdvertise) | ||
, cprpGetBootstrapPeers :: !(Set peeraddr) | ||
} | ||
deriving (Eq, Show, Typeable) |
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.
This type should be called CardanoExtraPeers
, and then we could provide & use the following:
type CardanoPublicRootPeers peeraddr = PublicRootPeers (CardanoExtraPeers peeraddr) peeraddr
ref: bae4f75
data CardanoPeerSelectionState = | ||
CardanoPeerSelectionState { |
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'd call this CardanoExtraState
and then we can have & use
type CardanoPeerSelectionState = PeerSelectionState CardanoExtraState ...
ref: bae4f75
-> PeerSelectionActionsArgs (CardanoPeerSelectionActions m) (CardanoLedgerPeersConsensusInterface m) (CardanoPublicRootPeers peeraddr) PeerTrustable peeraddr peerconn exception m | ||
-> WithLedgerPeersArgs (CardanoLedgerPeersConsensusInterface m) m | ||
-> PeerSelectionActionsDiffusionMode peeraddr peerconn m | ||
-> ( (Async m Void, Async m Void) | ||
-> PeerSelectionActions peeraddr peerconn m | ||
-> PeerSelectionActions (CardanoPeerSelectionActions m) (CardanoPublicRootPeers peeraddr) PeerTrustable (CardanoLedgerPeersConsensusInterface m) peeraddr peerconn m | ||
-> m a) |
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.
With some type aliases this could look simpler:
-> CardanoPeerSelectionActionsArgs ...
-> WithLedgerPeersArgs (CardanoLedgerPeersConsensusInterface m) m
-> PeerSelectionActionsDiffusionMode peeraddr peerconn m
-> ( (Async m Void, Async m Void)
-> CardanoPeerSelectionActions ...
-> m a)
ref: cb0da21
Description
This PR completely refactors ouroboros-network in order to make diffusion layer fully general/polymorphic and extensible. This will allow 3rd party users to instantiate their own diffusion and their own diffusion parameters, creating their own overlay network.
More details about this refactor refer to https://github.com/IntersectMBO/ouroboros-network/wiki/Reusable-Diffusion-Investigation
TODOs:
daBlockFetchMode