-
Notifications
You must be signed in to change notification settings - Fork 100
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
feat!: namesys refactor, ipns TTL bubbled up to gateway #459
Conversation
Codecov Report
@@ Coverage Diff @@
## main #459 +/- ##
==========================================
+ Coverage 65.78% 65.87% +0.09%
==========================================
Files 207 205 -2
Lines 25156 25134 -22
==========================================
+ Hits 16549 16558 +9
+ Misses 7147 7112 -35
- Partials 1460 1464 +4
|
@lidel IPNS TTL is easy. We already have it inside |
c790a66
to
b335bde
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hacdias sounds like a sensible compromise. quick thoughts:
- update specs for
Cache-Control
andLast-Modified
to reflect that acting on TTL is SHOULD, but implementation that have no access to TTL information SHOULD returnLast-Modified
instead (replace language from legacy/new etc) [https://github.com/gateway: clean Cache-Control and Last-Modified specs#436] - testing this will need something like
AnyOf
from Support MUST / MAY / SHOULD responses gateway-conformance#153 i think?
6779eb2
to
4daa75d
Compare
@lidel thanks for the preliminary review. Here's some notes and further questions:
Lines 114 to 129 in d213160
|
4daa75d
to
fb409c2
Compare
c5a7219
to
17cd5dd
Compare
re:
ps. We probably want to KEEP |
Not sure how we're supposed to achieve that. Somehow we'd have to tap into the resolver cache to get that information out of it. Besides, the time it is in cache is, at most TTL or "time until EOL" if TTL is smaller. |
e29ffd2
to
4e023b4
Compare
Namesys has own cache. The idea here is to leverage that cache and store (value, lastmodified, ttl) instead of (value, ttl). When ttl expires namesys knows it should check if there is a new updated version of the record. This way, we could have a more meaningful |
Btw, I want to note that that is not the case at the time. Namesys cache keeps the record value until EOL: Lines 33 to 35 in 574df96
I can definitely change it, because it would make more sense, but just a note. |
42af4f8
to
7610773
Compare
7610773
to
310943f
Compare
This PR is ready for review:
|
3d4e275
to
18aab37
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hacdias thank you for cleaning the coreifrace
and path leftovers and being patient with reviews on this.
I blocked some time today for review and pushed cosmetic refactors that unify implicit behaviors and docs for changes we should make to the IPNS publishing defaults.
Please check my changes and CHANGELOG I've added, namely the changes to defaults:
We had to increase TTL, now that it impacts caching in multiple places (namesys, gateway responses) 1 minute was too low. While at it, I also increased Lifetime and used it for publishing and reproviding to benefit from longer persistence window in Amino DHT.
Only remaining questions:
- why CI did not run? (it is in pendign for me)
- inline if we need separate
ResolveResult
andResolveAsyncResult
or can have one, but not a blocker.
If you are ok with my changes, and CI runs and is green, feel free to merge and bubble up – we want to include this in Kubo 0.24.
namesys/interface.go
Outdated
// ResolveResult is the return type for [Resolver.Resolve]. | ||
type ResolveResult struct { | ||
Path path.Path | ||
TTL time.Duration | ||
LastMod time.Time | ||
} | ||
|
||
// ResolveAsyncResult is the return type for [Resolver.ResolveAsync]. | ||
type ResolveAsyncResult struct { | ||
Path path.Path | ||
TTL time.Duration | ||
LastMod time.Time | ||
Err error | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💭
@hacdias this feels like overkill, do we need both? can we have only one ResolveResult
(or even shorter Result
) with Err
, like we did before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lidel the issue is that I don't think it makes sense for Resolve
(non-async) to return a struct that contains an Err
field. We can always add a comment saying that Err
is always nil
for .Resolve
, but that's a bit beating around the bush. I would however suggest:
// Result is the return type for [Resolver.Resolve].
type Result struct {
Path path.Path
TTL time.Duration
LastMod time.Time
}
// AsyncResult is the return type for [Resolver.ResolveAsync].
type AsyncResult struct {
Result Result
Err error
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lidel I have simplified the names, but I did not incorporate Result
inside AsyncResult
. I am going to merge the PR as-is. We can change this in a separate PR if we find a better of doing it. As long as it's before final release, it should be fine.
@lidel I think CI did not run because it has conflicts with the |
I made ipns.Name.src a string in order to make the struct comparable. It can now be used as a map key, but it's still protected from being converted around.
Since we've started using TTLs, we should adjust default to make them more useful by default. 1h comes from https://specs.ipfs.tech/ipns/ipns-record/#ipns-record and is a safer default than 1m.
Moving defaults that are not specific to (re)publisher
This defines the implicit defaults used for every 'ipns name resolve' DefaultResolverDhtTimeout DefaultResolverDhtRecordCount
8c1d32a
to
8d4e7dd
Compare
This applies changes necessary after ipfs/boxo#459 we need this to unblock ipfs/kubo#10161
Turns out, we already had the TTL for IPNS Records inside this package. We were just not bubbling it up. This, for IPNS Records. We can manage this without doing it for domains, but I think it would be great if we did. Closes #329.
/ipns
paths andCache-Control
HTTP header gateway-conformance#173