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

Implement eviction of iroh-dns-server based on last_seen, not timestamp #3013

Open
rklaehn opened this issue Dec 5, 2024 · 1 comment
Open
Labels
c-iroh-dns-server feat New feature or request

Comments

@rklaehn
Copy link
Contributor

rklaehn commented Dec 5, 2024

Currently eviction is implemented in terms of the timestamp of the packet, in #2997

The timestamp is the wallclock time when the packet is signed.

This works fine for us since we create new packets every time we publish discovery information. But for pkarr in general, it is perfectly valid to have a packet that was signed some time ago and republish it - that way the publisher does not need the private key. We should change the iroh-dns-server eviction to use the receive time instead of the timestamp.

The downside of this is that somebody, anybody, could prevent a packet from being evicted by just republishing it. However, they can not prevent the packet from being replaced by a newer one. So really nothing to worry about I think.

Doing eviction based on recv time would require storing the recv time separately, so it would be a schema change. There are some things coming in pkarr v3 that would make this easier, so maybe we wait until then...

Cc @Nuhvi

@rklaehn rklaehn added the feat New feature or request label Dec 5, 2024
@Nuhvi
Copy link
Contributor

Nuhvi commented Dec 5, 2024

You can review (try) this branch

It would work like this:

let keypair = Keypair::random();

let signed_packet = SignedPacket::builder()
    .sign(&keypair)
    .unwrap();
    
// Serializing/deserializing `<last_seen u64 big endian><singed_packet>`
let signed_packet =  SignedPacket::deserialize(&signed_packet.serialize()).unwrap();

// And you can get the `last_seen` and it itself is serializable as a u64 big endian too.
signed_packet.last_seen().to_bytes();

Edit: renamed V3 to v3-snapshot since I don't think anyone needs this published any time soon, so no need for v3 and v4.

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

No branches or pull requests

2 participants