-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat: logic for atoma p2p for gossip nodes public urls #286
Conversation
atoma-p2p/src/service.rs
Outdated
event = "gossipsub_message_data", | ||
"Received gossipsub message data" | ||
); | ||
let message_acceptance = |
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.
@sdbondi I added here error handling for message validation, and providing the acceptance criteria resulting from it, which is then passed below in the report_message_validation_result
. How does this look like ?
atoma-p2p/src/service.rs
Outdated
"Received gossipsub message data" | ||
); | ||
// Address request messages are always accepted and propagated on the p2p network | ||
self.swarm |
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.
@sdbondi also added a report_message_validation_result
to always accept requests for node addresses, as if I understand correctly, otherwise this message would not be propagated to other nodes.
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.
That is correct - however since gossipsub gossips the message to all subscribers, you probably don't want to use it for this part of the protocol. i.e. a single request will arrive at all subscribers (i.e all nodes) and will result in all nodes sending a response to all nodes. I assume that all nodes also send a request.
https://docs.rs/libp2p-request-response/latest/libp2p_request_response/ might be what you're looking for
atoma-p2p/src/service.rs
Outdated
.swarm | ||
.behaviour_mut() | ||
.gossipsub | ||
.publish(topic, serialized_response) |
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.
@sdbondi publishing new messages does not require further validation, am I correct ?
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'm still not convinced having p2p nodes register their public url is an effective mechanism for peer routing
If we are going to be using Kademlia DHTs for discovery this seems counter intuitive, nodes should be located by their PeerID and the content of that peer's route be stored upon discovery.
We can use the NewListenAddress
event to dial them upon discovery.
It may be useful to examine how Kademlia works so that this is clearer
EDIT: After discussing with @jorgeantonio21 we decided that for this first iteration we would like to leverage the easy API request routing via axum and then we can move to a more decoupled seperation of concerns with the proxy having an exposed compatible [OpenAPI}(https://www.openapis.org/) which will then routing requests to the nodes, which will be discovered via Kademlia and connected in mesh.
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.
Awesome work on this @jorgeantonio21 🚀
Looking good but left some comments
); | ||
// TODO: should we remove the locally stored public url from an unsubscribed peer? | ||
} | ||
_ => {} |
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 there are quite a few more events we will want to explicitly handle here, namely:
SwarmEvent::Behaviour(MyBehaviourEvent::Mdns(mdns::Event::Discovered(list))) => {
for (peer_id, _multiaddr) in list {
debug!(
target = "atoma-p2p",
event = "mdns_discovered",
peer_id = %peer_id,
"mDNS discovered a new peer"
);
// Let's explicitly add peers discovered that, they may allow us to find new peers or they may be already subscribed to the topic
swarm.behaviour_mut().gossipsub.add_explicit_peer(&peer_id);
}
},
SwarmEvent::Behaviour(MyBehaviourEvent::Mdns(mdns::Event::Expired(list))) => {
for (peer_id, _multiaddr) in list {
debug!(
target = "atoma-p2p",
event = "mdns_expired",
peer_id = %peer_id,
"mDNS peer expired"
);
swarm.behaviour_mut().gossipsub.remove_explicit_peer(&peer_id);
}
},
SwarmEvent::NewListenAddr { address, .. } => {
debug!(
target = "atoma-p2p",
event = "new_listen_address",
peer_id = %peer_id,
""
);
}
SwarmEvent::Dialing {
peer_id: Some(peer_id),
..
} => debug!("Dialing {peer_id}"),
e => panic!("{e:?}"),
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.
Are all these the events to handle ? If I understand correctly gossipsub already integrates kademlia for peer discovery, so there seems to not be much to do on that front..
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.
That's inaccurate for rust-libp2p
see libp2p/rust-libp2p#5313
At the moment one has to explicitly add them when the Discovered
event is emitted as you can see the discovered_nodes is not merged into the gossipsub nor Kademlia properties, which is why in this example it's done explicitly
EDIT: mdns
will update the gossipsub mesh but not Kademlia, so this still applies here for that use case.
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 believe we don't need to update kademlia for any new mdns discovery, as these peers are mostly residing on a local network. What do you think ?
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 disagree I think it will help because the bootstrap nodes will now have any locally discovered nodes, which will help any future node during it's bootstrap node.
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 minus this one comment #286 (comment) Great job @jorgeantonio21 🚀
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.
Excellent work!
e124fd0
to
dea556c
Compare
b5371f2
to
0cfa379
Compare
No description provided.