Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Implement registry proofs #244

Merged
merged 21 commits into from
Sep 14, 2021
Merged

Implement registry proofs #244

merged 21 commits into from
Sep 14, 2021

Conversation

mrcnski
Copy link
Contributor

@mrcnski mrcnski commented Aug 9, 2021

  • [BREAKING] Make client.registry.getEntryLink a standalone function and non-async
  • Export crypto length constants
  • Implement registry proofs
  • Throw if expected headers are not found

@mrcnski mrcnski force-pushed the registry-proofs branch 3 times, most recently from 3ef7b15 to 0bfbb8a Compare August 9, 2021 21:44
src/client.ts Show resolved Hide resolved
@mrcnski
Copy link
Contributor Author

mrcnski commented Aug 13, 2021

I would like to improve the "Could not verify registry proof chain" error messages but not sure how to do that without the error being overly technical and confusing. Ideas are welcome.

@mrcnski
Copy link
Contributor Author

mrcnski commented Aug 16, 2021

This PR is waiting for the Skynet-Proof header to be added to access controls. @kwypchlo

src/client.ts Show resolved Hide resolved
src/skydb.test.ts Show resolved Hide resolved
src/download.ts Outdated Show resolved Hide resolved
src/download.ts Outdated Show resolved Hide resolved
src/download.ts Outdated Show resolved Hide resolved
src/download.ts Outdated Show resolved Hide resolved
src/download.ts Outdated Show resolved Hide resolved
src/download.ts Outdated Show resolved Hide resolved
src/download.ts Outdated Show resolved Hide resolved
src/download.ts Show resolved Hide resolved
src/index.test.ts Outdated Show resolved Hide resolved
@ro-tex ro-tex self-requested a review September 8, 2021 16:08
ro-tex
ro-tex previously approved these changes Sep 8, 2021
Copy link
Collaborator

@ro-tex ro-tex left a comment

Choose a reason for hiding this comment

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

LGTM, aside from the ongoing discussions. If those are resolved feel free to merge.

@mrcnski mrcnski requested a review from ro-tex September 8, 2021 16:15
ro-tex
ro-tex previously approved these changes Sep 9, 2021
kwypchlo
kwypchlo previously approved these changes Sep 10, 2021
@@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 16
node-version: 16.8
Copy link
Collaborator

Choose a reason for hiding this comment

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

is there a reason why you are defining specific minor version of nodejs ? people are updating minor versions on their machines and it is beneficial to catch any issue with new version before it's reported by broken user code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it was necessary because CI breaks on Node 16.9. See commit 8e00300.

Copy link
Collaborator

Choose a reason for hiding this comment

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

that commit doesn't say much about the nature of the issue 8e00300

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad, the issue is nodejs/node#40030. Looks like it might have been resolved.

src/download.ts Outdated
Comment on lines 721 to 731
if (isSkylinkV1(inputSkylink)) {
if (inputSkylink !== dataLink) {
throw new Error("Expected returned skylink to be the same as input data link");
}
// If input skylink is not an entry link, no proof should be present.
if (proofArray.length > 0) {
throw new Error("Expected 'skynet-proof' header to be empty for data link");
}
// Nothing else to do for data links, there is no proof to validate.
return;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should assert that proof header is not set for skylink v1, checking proofArray wouldn't then make sense because in the first try-catch block you already check for if(proof)

@mrcnski
Copy link
Contributor Author

mrcnski commented Sep 10, 2021

The CI is failing because of a bug nodejs/node#40030. However tests do pass, which can be confirmed by running yarn test locally.

src/client.ts Show resolved Hide resolved

it("should throw if skynet-portal-api header is missing", async () => {
const incompleteHeaders: Record<string, unknown> = { ...headers };
incompleteHeaders["skynet-portal-api"] = undefined;

Choose a reason for hiding this comment

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

what about empty string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Braised #285


it("should throw if skynet-skylink header is missing", async () => {
const incompleteHeaders: Record<string, unknown> = { ...headers };
incompleteHeaders["skynet-skylink"] = undefined;

Choose a reason for hiding this comment

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

what about empty string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Braised #285

@peterjan
Copy link

peterjan commented Sep 14, 2021

@m-cat only one real comment about the breaking changes, looks good otherwise! Will press approve when that comment gets resolved. Do we have to break compat. here? I don't see why that's absolutely necessary.

edit: got confused by naming, LGTM 👍

@mrcnski mrcnski merged commit f755e69 into master Sep 14, 2021
@mrcnski mrcnski deleted the registry-proofs branch September 14, 2021 15:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants