Skip to content

Conversation

@Frando
Copy link
Member

@Frando Frando commented Oct 13, 2025

Description

iroh-gossip includes a node's addressing information in all Join and ForwardJoin messages (in the peer_data field). This is used by receives of the messages to be able to dial the sender directly, even when not using external discovery mechanisms.

We are using Endpoint::add_node_addr_with_source to add the received addr info to the endpoint. In iroh 0.93, Endpoint::add_node_addr was removed, and add_node_addr_with_source should have been removed as well, but was overlooked, and thus iroh-gossip 0.93 only works like previously right now because of an oversight in n0-computer/iroh#3338. We will remove add_node_addr_with_source in 0.94 and maybe already deprecate sooner.

This PR changes iroh-gossip to not use Endpoint::add_node_addr_with_source anymore and instead get the received addressing info to the endpoint through a discoery service.

The discovery service is fully internal atm: It is not exposed, only added to the endpoint and used from within the crate.

I first used a StaticProvider but that would keep the records forever, which is a memory leak for a long-running busy gossip node. So I switched to an impl that evicts entries after some time.

Right now I hard-coded the retention to 5 minutes, evicting expired entries every 30s. Should this be configurable? Maybe yes, I think.

Breaking Changes

Notes & open questions

Should the retention settings be configurable? Could quite easily add it to the builder.

Previously, this "retention" was fully outside the control of either iroh-gossip or the user, as it was handled by iroh's magic socket internal pruning of unused entries from the node map. Would need to look up what intervals that are.

Change checklist

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant.
  • All breaking changes documented.

@github-actions
Copy link

github-actions bot commented Oct 13, 2025

Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh-gossip/pr/108/docs/iroh_gossip/

Last updated: 2025-10-21T11:26:32Z

@github-actions
Copy link

github-actions bot commented Oct 13, 2025

Simulation report
GossipAll-n100-r5 with 4 seeds
        RMR    LDH  missed  duration 
 mean  1.03  10.40    0.00     665ms 
  max  1.05  11.00    0.00     737ms 
  min  1.00   9.00    0.00     506ms 

GossipAll-n20-r30 with 4 seeds
        RMR   LDH  missed  duration 
 mean  1.33  4.60    0.00     388ms 
  max  1.50  6.00    0.00     415ms 
  min  1.08  3.00    0.00     207ms 

GossipMulti-n100-r30 with 4 seeds
        RMR    LDH  missed  duration 
 mean  0.42  10.50    0.00     302ms 
  max  1.55  14.00    0.00     389ms 
  min  0.08   5.00    0.00     163ms 

GossipMulti-n1000-r30 with 4 seeds
        RMR    LDH  missed  duration 
 mean  0.48  20.30    0.00     594ms 
  max  2.08  25.00    0.00     703ms 
  min  0.15  13.00    0.00     350ms 

GossipMulti-n20-r30 with 4 seeds
        RMR   LDH  missed  duration 
 mean  0.23  4.07    0.00     145ms 
  max  1.83  5.00    0.00     293ms 
  min  0.06  2.00    0.00      83ms 

GossipSingle-n100-r30 with 4 seeds
        RMR   LDH  missed  duration 
 mean  0.08  5.00    0.00     163ms 
  max  1.55  5.00    0.00     163ms 
  min  0.01  5.00    0.00     163ms 

GossipSingle-n1000-r30 with 4 seeds
        RMR    LDH  missed  duration 
 mean  0.07  13.00    0.00     350ms 
  max  2.08  13.00    0.00     350ms 
  min  0.00  13.00    0.00     350ms 

GossipSingle-n20-r30 with 4 seeds
        RMR   LDH  missed  duration 
 mean  0.15  3.00    0.00      83ms 
  max  1.83  3.00    0.00      83ms 
  min  0.06  3.00    0.00      83ms 

comparing GossipAll-n100-r5
               RMR          LDH       missed     duration 
 mean       +0.00%       +0.00%       +0.00%       +0.00% 
 max        +0.00%       +0.00%       +0.00%       +0.00% 
 min        +0.00%       +0.00%       +0.00%       +0.00% 
comparing GossipAll-n20-r30
               RMR          LDH       missed     duration 
 mean       +0.00%       +0.00%       +0.00%       +0.00% 
 max        +0.00%       +0.00%       +0.00%       +0.00% 
 min        +0.00%       +0.00%       +0.00%       +0.00% 
comparing GossipMulti-n100-r30
               RMR          LDH       missed     duration 
 mean       +0.00%       +0.00%       +0.00%       +0.00% 
 max        +0.00%       +0.00%       +0.00%       +0.00% 
 min        +0.00%       +0.00%       +0.00%       +0.00% 
comparing GossipMulti-n1000-r30
               RMR          LDH       missed     duration 
 mean       +0.00%       +0.00%       +0.00%       +0.00% 
 max        +0.00%       +0.00%       +0.00%       +0.00% 
 min        +0.00%       +0.00%       +0.00%       +0.00% 
comparing GossipMulti-n20-r30
               RMR          LDH       missed     duration 
 mean       +0.00%       +0.00%       +0.00%       +0.00% 
 max        +0.00%       +0.00%       +0.00%       +0.00% 
 min        +0.00%       +0.00%       +0.00%       +0.00% 
comparing GossipSingle-n100-r30
               RMR          LDH       missed     duration 
 mean       +0.00%       +0.00%       +0.00%       +0.00% 
 max        +0.00%       +0.00%       +0.00%       +0.00% 
 min        +0.00%       +0.00%       +0.00%       +0.00% 
comparing GossipSingle-n1000-r30
               RMR          LDH       missed     duration 
 mean       +0.00%       +0.00%       +0.00%       +0.00% 
 max        +0.00%       +0.00%       +0.00%       +0.00% 
 min        +0.00%       +0.00%       +0.00%       +0.00% 
comparing GossipSingle-n20-r30
               RMR          LDH       missed     duration 
 mean       +0.00%       +0.00%       +0.00%       +0.00% 
 max        +0.00%       +0.00%       +0.00%       +0.00% 
 min        +0.00%       +0.00%       +0.00%       +0.00% 

Last updated: 2025-10-21T11:27:52Z

rng: &mut impl CryptoRng,
) -> n0_snafu::Result<(NodeId, Router, Gossip, GossipSender, GossipReceiver)> {
let topic_id = TopicId::from([0u8; 32]);
let ep = Endpoint::builder()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty_builder?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is still on the last released iroh, will fix in #110

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, too many APIs 😅

Some(Ok(_))
));

tokio::time::sleep(Duration::from_millis(200)).await;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could use the paused tests to avoid making this actually wait

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entries use SystemTime so I don't think this would work? I think time::pause() only works for Instants.

loop {
n0_future::time::sleep(opts.evict_interval).await;
let Some(nodes) = nodes.upgrade() else {
break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when would that happen? should maybe log sth as this means this task is dead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only happens when the GossipDiscovery is dropped, and then it's fine to just break the task. I think it will depend on the drop order if this happens first or if the task is aborted. Fine to leave as is IMO.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see 👍

@Frando Frando merged commit f7e3ef4 into main Oct 21, 2025
26 checks passed
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in iroh Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants