Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: move access-api delegation bytes out of d1 and into r2 #578
feat: move access-api delegation bytes out of d1 and into r2 #578
Changes from 14 commits
1e83d67
198e32d
963a0d4
e957d94
83c9c49
e65dd19
b491acb
000c704
044f76b
eeab7fd
a39b780
bd42ee4
568d095
0186d6a
9fce623
51e2835
8acaa8d
ecbe77d
c77d0cd
37b05c1
7f616d8
6fa5390
fe26c70
e379699
7d017e7
e2da517
3261215
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Can you avoid changing this unless needed as it would create conflict with my PR also changing this file.
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.
see #578 (comment)
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.
No need to cast it to v1 only DAG-PB nodes can be in V0 and delegations can be encoded in DAG-PB.
Looks like CIDs will retain original base encoding when parsed so if you want to normalize you should pass
base32
as an argument. Or alternatively do something likeCID.decode(d.cid.bytes).toString()
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.
is this a typo?
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.
good catch. I thought it would normalize to base32 for all v1. I will do it explicitly.
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.
I added tests asserting the cid kinds for cid column in d1 as well as the cid part of r2 keys e379699#diff-80f191e42400b9b26178ff477cf9edac5ac2e8106246b9be714368ed719525baR134
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.
We might succeed here, but then fail on the insert, in which case we will be storing more than is necessary in the R2Bucket, but I wrote this so we err on that side but at least avoid ever having delegation.cid in D1 but are unable to dereference CID -> bytes from r2.
If d1 had access to sql transactions, we might be able to use that here to do the write to r1 after trying the sql insert inside a transaction, but we don't so this is I think the best we can do without a much more involved 2pc
(but at that point IMHO we should be looking beyond d1, even to sql setup with transactions or away from sql entirely)
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.
Nit: Why
executeTakeFirst
?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.
Nit: Would be a good idea to allow filtering by the expiry as well.
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.
Also might be a good idea to make
audience
optional field on query.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.
let's add filtering by expiry as followup. We had discussed previously related to #526.
(I think adding column as migration should be easy)
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.
Nit: Should we perhaps not throw on first error and try to yield as much as we can and then throw ?
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.
I'd prefer to fail fast. afaict there is no good reason to keep going if this errors. something is very wrong
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.
Nit: We could actually create a delegation from the CAR regardless of the number of roots as long as it contains block with that CID.
Here I would instead find delegation that matches the desired CID and fail if not found instead.
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.
I changed this to just check that
delegations
contains an entry whose cid equals parsed row.cid