-
Notifications
You must be signed in to change notification settings - Fork 6
feat: Add GossipDiscovery
and thus make broadcasting our addressing information optional
#51
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
base: fix/confirmed-neighbor-up
Are you sure you want to change the base?
Conversation
f84d742
to
7b024dd
Compare
444e3ae
to
a56d030
Compare
7b024dd
to
e70a6ec
Compare
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh-gossip/pr/51/docs/iroh_gossip/ Last updated: 2025-03-28T20:21:14Z |
3033395
to
76bd26f
Compare
How long does a |
In the default config up to 6 hops on a random walk between connected peers. |
6f8624e
to
5d1088a
Compare
5d1088a
to
b2257bf
Compare
Heh, I guess I meant in units of time... I assume 6 hops are like, less than a second? In which case the staleness of it's addressing info really isn't an issue I guess. |
Description
Background:
Currently,
iroh-gossip
always and unconditionally includes a node'sNodeAddr
inJoin
andForwardJoin
messages. This is a good feature if no other node discovery sources are available, because in the case ofForwardJoin
it allows a node receiving aForwardJoin
to directly connect to the original sender (which is not the node we received theForwardJoin
from). However,ForwardJoin
s take a number of hops in a random walk, and by the time a node replies to aForwardJoin
and thus tries to establish a connection to the original sender, the address info included in theForwardJoin
might already be outdated, because the original sender has switched relays or networks. As long as other discovery mechanisms are enabled on all nodes, it might be better to rely on those instead of trying to connect to the outdated address info.Change in this PR
The always-on inclusion of a node's address info as
PeerData
inJoin
messages is removed, as is adding received address info to the endpoint viaEndpoint::add_node_addr
. This means that by default, iroh-gossip only works well if the endpoint has other discovery mechanisms enabled. Instead, this PR introduces a newGossipDiscovery
struct. It can be constructed before building an endpoint and gossip, and is then added to both the endpoint (throughEndpointBuilder::discovery
and the gossip (throughGossipBuilder::use_gossip_for_discovery
). If done, the behavior is exactly as previously: when our node address changes, the changed address is pushed into the gossip state to be included in futureJoin
messages. When we receivePeerData
with node address info, it is added to theGossipDiscovery
, which is a regular discovery source to the endpoint.Endpoint::add_node_addr
is not used anymore, which will make @flub happy.The PR also adds a test that demonstrates the change with regard to
ForwardJoin
: Without discovery, we cannot contact nodes from aForwardJoin
. With theGossipDiscovery
, everything works as previously.Based on #50 (without #50, we'd get
NeighborUp
messages for peers fromForwardJoin
even though we cannot connect to them)Breaking Changes
iroh-gossip
does, by default, not broadcast node addresses withJoin
messages anymore. If you are not using discovery services on the endpoint, use the newGossipDiscovery
to keep the previous behavior. See the docs ofGossipBuilder::use_gossip_for_discovery
for details.GossipBuilder::spawn
is notasync
anymore, and returnsGossip
instead ofResult<Gossip>
.Notes & open questions
Change checklist