Skip to content
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

Change default discovery configuration of iroh-net endpoint #2753

Open
rklaehn opened this issue Sep 30, 2024 · 4 comments
Open

Change default discovery configuration of iroh-net endpoint #2753

rklaehn opened this issue Sep 30, 2024 · 4 comments
Labels
c-iroh-net feat New feature or request

Comments

@rklaehn
Copy link
Contributor

rklaehn commented Sep 30, 2024

Related to the discussion we had on discord:

https://discord.com/channels/949724860232392765/960896793195974708/1289232008979157115

When you create an iroh-net endpoint and want to be able to dial by raw node ids or by short tickets, you usually want to enable some kind of discovery. Enabling full discovery is pretty verbose and confusing. See below

let secret_key = SecretKey::generate();
let discovery = ConcurrentDiscovery::from_services(vec![
    Box::new(PkarrPublisher::n0_dns(secret_key.clone())),
    Box::new(DnsDiscovery::n0_dns()),
    Box::new(LocalSwarmDiscovery::new(secret_key.public())?),
]);
let ep = iroh_net::Endpoint::builder()
    .secret_key(secret_key)
    .discovery(Box::new(discovery))
    .alpns(vec![EXAMPLE_ALPN.to_vec()])
    .bind()
     .await

So possible options would be:

A) have discovery publish and resolve enabled by default, but provide a way to disable/manually configure it
B) have a builder helper method to enable discovery publish and subscribe that does not have as much ceremony as above. In addition have builder methods to enable just publish and just resolve
C) leave things as is but document things better

@rklaehn rklaehn added feat New feature or request c-iroh-net labels Sep 30, 2024
@rklaehn
Copy link
Contributor Author

rklaehn commented Sep 30, 2024

One reason for not wanting discovery publish and resolve enabled by default: when I write short iroh apps, I almost constantly have a client/server responsibility spilt. See sendme, dumbpipe, the workshop examples, and this new thing I wrote yesterday.

You have short-lived ephemeral "client" nodes that do not ever need to be resolved, and long lived "server" role nodes that do need to be resolved, but rarely need to do any resolutions themselves.

Having the ability to resolve things enabled when unused is no big deal, but having publishing enabled for ephemeral nodes that do not need it is a bit of a waste: it spams our dns server and/or the DHT with resolution info that is never going to be used.

@flub
Copy link
Contributor

flub commented Sep 30, 2024

The strongest objection seems to be against enabling local-swarm-discovery by default because this broadcasts your NodeId on every network you happen to be on.

The DNS discovery on the other hand is not that much different from using the relays: it normally only publishes the NodeId together with the RelayUrl and not much more.

(Note that the PkarrPublisher used for DNS discovery has the odd behaviour where it will publish the direct addresses if there is no home relay. That would probably cross the line into publishing too much again so would have to be changed to work as default-enabled. That behaviour is surprising anyway I think.)

@rklaehn
Copy link
Contributor Author

rklaehn commented Sep 30, 2024

The DNS discovery on the other hand is not that much different from using the relays: it normally only publishes the NodeId together with the RelayUrl and not much more.

@matheus23 s privacy objection regarding local-swarm-discovery is very valid. My objection regarding short-lived nodes is more that I don't want our poor dns server to store millions of completely useless mappings for short-lived ephemeral nodes, and I don't want the iroh-net endpoint to do http requests that are never going to be needed.

Having a single line in the builder to enable full publish/resolve discovery does not seem to much of an ask, especially since in 100% of all iroh-net based things I have written so far I never needed full discovery.

E.g. here is the thing I wrote yesterday.

Client that does not need to publish https://github.com/rklaehn/frosty/blob/master/src/main.rs#L319
Server that does not need to resolve https://github.com/rklaehn/frosty/blob/master/src/main.rs#L404

@rklaehn
Copy link
Contributor Author

rklaehn commented Oct 2, 2024

Here is a possible solution: #2775

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-iroh-net feat New feature or request
Projects
Status: No status
Development

No branches or pull requests

2 participants