-
Notifications
You must be signed in to change notification settings - Fork 177
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
[Access] Relay messages to unstaked network directly #1106
Comments
I believe this is an improvement not only for the unstaked side of the network but also on the staked side of the network where multiple consensus nodes are publishing the same blocks. |
So I've done some more digging, and it turns out we won’t be able to access the However, I realized that we may be approaching this completely wrong in the first place. First of all, on the staked access node, we're creating two entirely separate instances of
I'm guessing the reason it's implemented this way is because conceptually we are creating two "separate" networks, but in fact I'm not sure we have to explicitly separate them this way. Here is a method that allows us to register a topic validator: https://github.com/libp2p/go-libp2p-pubsub/blob/master/pubsub.go#L1297 The validators are run before any message is sent or gossiped-forward on the network
What we could to instead, is the following:
The reason this should work is because unstaked nodes can only bootstrap from staked AN's and other unstaked nodes. In other words, the staked AN's are the only things connecting the staked network with the public network, and the two would be completely disconnected otherwise. This is ensured by connection gating on all of the staked nodes. Therefore, all traffic between the public and private networks has to pass through them. One thing I'm not sure about is how this would work with DHT. Ideally, we would want to ensure that it is possible for the rest of the staked nodes to not participate in the DHT, so that unstaked nodes can't find out their addresses via the DHT. However, i believe it should be okay even if they do find out about the addresses because connection gating will prevent any messages from unstaked nodes to be gossiped by staked nodes. |
The separation of the networks is intentional. We do not want any traffic on the staked network from nodes which are not staked. |
Yes, but we have a Connection gater, don't we @vishalchangrani ? |
Additional notes here: (Recording things here so I remember before putting everything into notion doc)
|
Another note: Since we would be intercepting messages from unstaked nodes at the gossip layer, they would never make it to the engines on their own. In other words, they wouldn't go through the normal processing flow of messages received on the staked network (from libp2p -> our network layer -> engine). Instead, we will need some way of injecting that message back into the processing flow once it's been validated, whether by directly passing it to the network layer or directly passing it to an engine. |
This is done |
This issue is to address the following concern raised about allowing unstaked nodes to connect to multiple upstream staked nodes:
Currently, we are implementing our own relay engine to relay messages received on the staked network to the unstaked network:
https://github.com/onflow/flow-go/blob/master/engine/access/relay/engine.go#L107-L108
However, this calls
Publish
on the libp2ppubsub.Topic
:https://github.com/onflow/flow-go/blob/master/network/p2p/libp2pNode.go#L487
Which creates a new libp2p
Message
with the node's own ID / signature:https://github.com/libp2p/go-libp2p-pubsub/blob/master/topic.go#L224-L234
In order to take advantage of libp2p's built-in message deduplication, we need to relay the libp2p
Message
unchanged.Code pointers:
Publish
: https://github.com/libp2p/go-libp2p-pubsub/blob/master/gossipsub.go#L943Instead of using the relay engine, what we probably need to do is to call
GossipSubRouter.Publish
directly to publish the message onto the unstaked network.Here is where we process the libp2p
Message
: https://github.com/onflow/flow-go/blob/master/network/p2p/readSubscription.go#L58-L59As you can see, we only pass on
rawMsg.Data
to the engine level, meaning we lose all the other information. Instead, we need some mechanism that intercepts therawMsg
at this level, and directly passes that toGossipSub.Publish
on the unstaked network.The benefit of this approach, is that it should reduce amount of messages on the gossip layer.
Previously, the same block proposal sent from two different staked AN's were treated as two different messages at the gossip layer, and so they would both be processed and forwarded. This means that both would have to go through the hotstuff validation logic, and only at that point does the second one that was received get discarded.
With the new approach, the same block proposal is detected as a duplicate at the gossip layer, preventing it from being further disseminated in the network and also preventing further processing up the stack.
The text was updated successfully, but these errors were encountered: