-
Notifications
You must be signed in to change notification settings - Fork 176
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
[Networking] Refactoring Networking Layer for Improved Structure and Maintainability AND Eliminating Redundant Middleware Component #4664
[Networking] Refactoring Networking Layer for Improved Structure and Maintainability AND Eliminating Redundant Middleware Component #4664
Conversation
FVM Benchstat comparisonThis branch with compared with the base branch onflow:master commit 104ca4f The command Collapsed results for better readability
|
Co-authored-by: Misha <15269764+gomisha@users.noreply.github.com>
…e-part-2' into yahya/6851-refactoring-middleware-part-2
cmd/node_builder.go
Outdated
Middleware network.Middleware | ||
Network network.Network | ||
EngineRegistry network.EngineRegistry | ||
UnderlayNetwork network.Underlay |
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.
UnderlayNetwork network.Underlay | |
NetworkUnderlay network.Underlay |
I think its fine to call struct fields with the Network* prefix, UnderlayNetwork sounds like it is an actual network rather than a component in a network. Lets use NetworkUnderlay in these instances.
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.
network/p2p/libp2pNode.go
Outdated
AddPeer(ctx context.Context, peerInfo peer.AddrInfo) error | ||
// ConnectToPeerAddrInfo connects to the peer with the given peer address information. | ||
// This method is used to connect to a peer that is not in the peer store. | ||
ConnectToPeerAddrInfo(ctx context.Context, peerInfo peer.AddrInfo) error |
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.
ConnectToPeerAddrInfo(ctx context.Context, peerInfo peer.AddrInfo) error | |
ConnectToPeer(ctx context.Context, peerInfo peer.AddrInfo) error |
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.
mw network.Middleware | ||
mu sync.RWMutex | ||
engines map[channels.Channel]network.MessageProcessor | ||
middleware network.Underlay // the Underlay interface of the network layer |
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.
middleware network.Underlay // the Underlay interface of the network layer | |
networkUnderlay network.Underlay // the Underlay interface of the network layer |
Do we still need to use "middleware" at all?
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.
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.
Great work 🚀
Background:
This PR aims to address the issues raised in GH issue https://github.com/dapperlabs/flow-go/issues/6851, which highlights inefficiencies in the Flow blockchain's networking layer. The current three-layered architecture has led to complexities, making the system difficult to maintain and debug.
Changes:
Middleware
toNetwork
component.Specifically, the
Middleware.go
implementation has been removed. Instead, its functionality has been revamped and refactored into an interface integrated directly within theNetwork.go
. Now, ourNetwork.go
file embodies three distinct interfaces—Network
,Adapter
, andMiddleware
—each serving different components.Network Interface: Provides functionalities exposed to the Flow protocol layer (i.e., engines). This includes registering channels and services like
BlobService
andPingService
.Adapter Interface: Serves as the networking layer for individual conduits, allowing them to send various types of messages, such as unicast, multicast, and publish.
Middleware Interface: Offers functionalities to lower-level networking components like libp2p, including channel subscriptions and updating addresses for authorized participants.
We acknowledge that the naming conventions for these interfaces may need to be revised. While we welcome suggestions for better names, we have retained the current names to facilitate a more streamlined PR review process for this first round.
Your feedback on the naming or the structural changes themselves would be greatly appreciated.