Skip to content

deps: Inline pkarr#4026

Open
rklaehn wants to merge 32 commits intomainfrom
inline-pkarr
Open

deps: Inline pkarr#4026
rklaehn wants to merge 32 commits intomainfrom
inline-pkarr

Conversation

@rklaehn
Copy link
Copy Markdown
Contributor

@rklaehn rklaehn commented Mar 18, 2026

Description

On main we use the pkarr dependency, which comes with an entire tree of dependencies and is not under our control. But we do not use the reqwest based client at all in the dns discovery, instead we have our own. So what we use is just the encoding and decoding of DNS records.

It seems less than optimal to have a big dependency for just that. So this PR removes the pkarr dependency, inlines the DNS record encoding with the help of simple-dns, and implements the dht part manually, directly using the mainline crate.

Note for reviewers: just do cargo doc -p iroh_dns --open to see the API of the new crate. Almost everything is just copied, with the exception of using mainline directly to publish to the DHT.

(In a subsequent PR I might also try to get rid of the mainline dep)

Breaking Changes

A lot of stuff moves into iroh-dns

Notes & open questions

Note: I am using simple-dns for en/decoding. We could even inline this, but it is very lightweight compared to hickory or even hickory-proto. I was originally planning to use hickory-proto, but it has a lot of deps even with default features disabled. Simple-dns is not a new dependency - we used to have it via pkarr.

Note: this adds a dep to iroh-relay to iroh-dns-server, just for the pkarr SignedPacket impl. We could alternatively let iroh-relay-server depend on pkarr (it's not so critical regarding deps), or have a tiny iroh-pkarr crate.

Note: we are no longer using pkarr client (which has relay and dht built in) for the dht lookup. So there is a functionality change: the dht lookup can now only look up via the DHT. Before you could configure it with relays.

But I think that is fine, we already have a way to look up via relays.

Note: I also added a few comments and tests regarding storage on iroh-dns-server. These are unrelated but should do no harm.

Change checklist

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant.
  • All breaking changes documented.
    • List all breaking changes in the above "Breaking Changes" section.
    • Open an issue or PR on any number0 repos that are affected by this breaking change. Give guidance on how the updates should be handled or do the actual updates themselves. The major ones are:

rklaehn added 5 commits March 18, 2026 12:57
we use mainline directly for the optional address-lookup-pkarr-dht feature.
And some more simplifications
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 18, 2026

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

Last updated: 2026-04-10T07:00:23Z

@rklaehn rklaehn force-pushed the inline-pkarr branch 2 times, most recently from d4fbe07 to 6929e64 Compare March 18, 2026 12:06
@n0bot n0bot bot added this to iroh Mar 18, 2026
@github-project-automation github-project-automation bot moved this to 🚑 Needs Triage in iroh Mar 18, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 18, 2026

Netsim report & logs for this PR have been generated and is available at: LOGS
This report will remain available for 3 days.

Last updated for commit: 33f2804

rklaehn added 2 commits March 20, 2026 11:37
This allows us to not depend on iroh-relay in iroh-dns-server
@dignifiedquire dignifiedquire moved this from 🚑 Needs Triage to 👍 Ready in iroh Apr 7, 2026
rklaehn added 2 commits April 8, 2026 12:28
## Description

This allows us to not depend on iroh-relay in iroh-dns-server

## Breaking Changes

<!-- Optional, if there are any breaking changes document them,
including how to migrate older code. -->

## Notes & open questions

<!-- Any notes, remarks or open questions you have to make about the PR.
-->

## Change checklist
<!-- Remove any that are not relevant. -->
- [ ] Self-review.
- [ ] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [ ] Tests if relevant.
- [ ] All breaking changes documented.
- [ ] List all breaking changes in the above "Breaking Changes" section.
- [ ] Open an issue or PR on any number0 repos that are affected by this
breaking change. Give guidance on how the updates should be handled or
do the actual updates themselves. The major ones are:
    - [ ] [`quic-rpc`](https://github.com/n0-computer/quic-rpc)
    - [ ] [`iroh-gossip`](https://github.com/n0-computer/iroh-gossip)
    - [ ] [`iroh-blobs`](https://github.com/n0-computer/iroh-blobs)
    - [ ] [`dumbpipe`](https://github.com/n0-computer/dumbpipe)
    - [ ] [`sendme`](https://github.com/n0-computer/sendme)
@rklaehn rklaehn marked this pull request as ready for review April 9, 2026 09:08
@rklaehn rklaehn requested a review from dignifiedquire April 9, 2026 09:09
@Frando
Copy link
Copy Markdown
Member

Frando commented Apr 9, 2026

I would suggest to move the entire iroh_relay::dns module into the new iroh_dns crate. The whole module only lives in iroh-relay because that is the lowest in our dependency graph. It would be cleaner for that to move to iroh-dns IMO.

@rklaehn
Copy link
Copy Markdown
Contributor Author

rklaehn commented Apr 9, 2026

I would suggest to move the entire iroh_relay::dns module into the new iroh_dns crate. The whole module only lives in iroh-relay because that is the lowest in our dependency graph. It would be cleaner for that to move to iroh-dns IMO.

Good idea. That would make the crate a little less lightweight.

This is a major change though.

Edit: I think it would be best to do this in a separate PR. See #4094

@@ -0,0 +1,21 @@
[package]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please make sure to add a readme file, and anything else we might have in other crates for this one

}
}

impl Debug for SignedPacket {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why not derive-more?

// Ensure strictly monotonic: if the clock went backward or two calls
// land in the same microsecond, we increment from the last value.
let mut last = LAST_TIMESTAMP.load(Ordering::Relaxed);
loop {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this makes me a bit uneasy, do we really have to do this?

}
}

impl fmt::Debug for Timestamp {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why not derive-more?

DnsError(String),
}

impl fmt::Display for SignedPacketBuildError {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we use n0-error for this error type?

/// Error verifying a signed packet.
#[derive(Debug)]
#[allow(missing_docs)]
pub enum SignedPacketVerifyError {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same, lets use n0-error

}

#[derive(Debug, Clone)]
enum PkarrRelay {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

are all these options gone now or why did you remove them?

let res = this
.0
.pkarr
.resolve_most_recent(&public_key)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

so this is not needed anymore?

// We map the error to string, as in browsers the error is !Send
let public_key = pkarr::PublicKey::try_from(endpoint_id.as_bytes())
.map_err(|err| e!(PkarrError::PublicKey, err))?;
let public_key = endpoint_id;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

seems pointless?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 👍 Ready

Development

Successfully merging this pull request may close these issues.

4 participants