-
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
Extensible Ouroboros Network Diffusion Stack #5016
base: main
Are you sure you want to change the base?
Conversation
3cdb9a3
to
f00952f
Compare
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
ce99e1d
to
5400a7c
Compare
ouroboros-network/src/Ouroboros/Network/PeerSelection/PublicRootPeers.hs
Outdated
Show resolved
Hide resolved
ouroboros-network/src/Ouroboros/Network/PeerSelection/PublicRootPeers.hs
Outdated
Show resolved
Hide resolved
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.
ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano.hs
Outdated
Show resolved
Hide resolved
ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano.hs
Outdated
Show resolved
Hide resolved
ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano/Node.hs
Outdated
Show resolved
Hide resolved
ouroboros-network/src/Ouroboros/Network/PeerSelection/PublicRootPeers.hs
Show resolved
Hide resolved
ouroboros-network/src/Ouroboros/Network/PeerSelection/PublicRootPeers.hs
Outdated
Show resolved
Hide resolved
ouroboros-network/src/Cardano/Node/PeerSelection/Governor/PeerSelectionState.hs
Outdated
Show resolved
Hide resolved
ouroboros-network/src/Ouroboros/Network/PeerSelection/PeerSelectionActions.hs
Outdated
Show resolved
Hide resolved
0935d40
to
9a2980f
Compare
9a2980f
to
e1b0745
Compare
-- | For Genesis, this sets the floor for minimum number of | ||
-- active big ledger peers we must be connected to in order | ||
-- to be able to signal trusted state (OutboundConnectionsState) | ||
, numberOfBigLedgerPeers :: NumberOfBigLedgerPeers |
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 don't think just adding numberOfBigLedgerPeers
is enough. If the target for established peers is insufficient, then we won't have a chance to achieve the target of big ledger peers.
I think in main
we pass all the targets, not just active ones.
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.
Is this somehow related to genesisPeerTargets
from Ouroboros.Cardano.Network.PeerSeledction.Churn.ExtraArguments
?
If it is the same, we should organise the code better. E.g. pass genesisPeerTargets
through AgumentsExtra
here rather than the Churn
ones.
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 is the same but this one in ArgumentsExtra
comes from configuration file which is going to be passed to Churn.ExtraArguments
ouroboros-network/src/Ouroboros/Network/PeerSelection/Governor.hs
Outdated
Show resolved
Hide resolved
peerconn | ||
BootstrapPeersCriticalTimeoutError | ||
m | ||
cardanoPeerSelectionGovernorArgs readUseLedgerPeers peerSharing updateOutboundConnectionsState = |
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 something wrong if we need to call it in cardano-node
. It seems the arguments in Cardano
diffusion are too general. Please investigate how to call this function inside of Cardano
diffusion.
@@ -366,6 +367,16 @@ data PeerSelectionActions peeraddr peerconn m = PeerSelectionActions { | |||
-- | |||
peerConnToPeerSharing :: peerconn -> PeerSharing, | |||
|
|||
-- | Public Extra Peers Actions | |||
-- | |||
extraPeersAPI :: PublicExtraPeersAPI extraPeers 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.
I think I confused PeerSelectionActions
, with PeerStateActions
. It's fine to pass it as part of the former. It's already a mixture of things.
ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/Diffusion/Testnet/Cardano/Simulation.hs
Outdated
Show resolved
Hide resolved
ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/MiniProtocols/BlockFetch.hs
Outdated
Show resolved
Hide resolved
ouroboros-network/src/Ouroboros/Cardano/Diffusion/Configuration.hs
Outdated
Show resolved
Hide resolved
ouroboros-network/src/Ouroboros/Cardano/Diffusion/Configuration.hs
Outdated
Show resolved
Hide resolved
|
||
-- | Extension point for third party users to be able to add more | ||
-- arguments. | ||
, daExtraArgs :: extraArgs |
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.
Is this used anywhere? I don't see how it is used inside Ouroboros.Network.Diffusion.P2P.run
function. This indicates that it could be removed.
ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/Diffusion/Testnet/P2P/Node.hs
Outdated
Show resolved
Hide resolved
a84ba63
to
7e02959
Compare
(See CHANGELOG for more details) - Extract Cardano-specific components into separate modules to resolve cyclic dependency issues: - `ConsensusModePeerTargets` and `PeerSelectionTargets` were refactored to avoid circular dependencies. - Introduce extension points in Diffusion data structures: - Split P2P functionality into `P2PCardano` (for Cardano Node specifics) and a more general `P2P` module. - Added `Minimal/Node.hs` as a placeholder for a minimal Node diffusion instantiation example. - Refactor Peer Selection: - Removed redundant `PeerSelectionActionsArgs`. - Reorganized `DNSActions` and `LedgerPeersArgs`. - Improved API for `PeerSelectionActions`. - Rename `Cardano.Node` to `Cardano.Network`. - Generalize and refactor the following components: - `ConsensusModePeerTargets`. - `PeerSelection{Views, Counters}` to allow extensibility for third-party users. - `PublicRootPeers`. - Enhance the Outbound Governor: - Generalize `MinimalP2P` for diffusion initialization. - Update `ArgumentsExtra` with new parameters for a more flexible diffusion setup. - Refactor `PeerSelection.Governor.Monitor` to separate Cardano-specific monitoring actions and support third-party custom actions. - Ensure the `Diffusion` module is fully polymorphic: - Removed `CardanoP2P` dependencies. - Updated the test suite to align with the new structure. - Miscellaneous updates: - Update CHaP and fix build issues. - Remove `daBlockFetchMode`. - Address review feedback. - Fix churn timeout tests and increase `shortDelay` to stabilize tests. - Recover `sigusr1` signal handler. - Make addresses polymorphic. - Refactor `extraDebugState` and introduce `P2PDecisionType`. - Refactor `requestPublicRootPeers` type.
It's not needed.
They are passed as a closure, no need to leak them outside of `Cardano` (or any other 3rd party integration).
Instead of specifying `extraAPI ~ ()` for non-p2p, we can make it polymorphic. This way both p2p & non-p2 `Application` type is using the same type variables, and the wrapper type can be removed. This is more in-line with removal of non-p2p code base.
Also adhere to the convention: first `extraFlags`, then `extraPeers`
We can pass `PeerSelectionInterfaces` to `updateWithState` function to get access to `readUseLedgerPeers`.
1e6f14a
to
87bd453
Compare
testnet: organised imports
Also edit export lists so that we need fewer imports.
98025d3
to
d0f1f93
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
Description
This PR refactors
ouroboros-network
in order to make diffusion layer general/polymorphic and extensible. This will allow us (or 3rd parties) to have access to a flexible network stack which can be extended/configured to ones needs.For more details about this refactoring, see https://github.com/IntersectMBO/ouroboros-network/wiki/Reusable-Diffusion-Investigation
TODOs:
daBlockFetchMode
For next steps (e,.g. when developing mithril) this will be in the todo list: