Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: remove dependency on js-ipfs #359

Closed
3 of 4 tasks
Tracked by #107
SgtPooki opened this issue May 5, 2023 · 5 comments · Fixed by #360
Closed
3 of 4 tasks
Tracked by #107

feat: remove dependency on js-ipfs #359

SgtPooki opened this issue May 5, 2023 · 5 comments · Fixed by #360
Assignees
Labels
effort/days Estimated to take multiple days, but less than a week exp/intermediate Prior experience is likely helpful status/ready Ready to be worked

Comments

@SgtPooki
Copy link
Member

SgtPooki commented May 5, 2023

Tasks

Preview Give feedback
@SgtPooki SgtPooki added the need/triage Needs initial labeling and prioritization label May 5, 2023
@SgtPooki SgtPooki self-assigned this May 5, 2023
@github-project-automation github-project-automation bot moved this to Needs Grooming in IPFS-GUI (PL EngRes) May 6, 2023
@SgtPooki SgtPooki moved this from Needs Grooming to Planned / Backlog in IPFS-GUI (PL EngRes) May 8, 2023
@SgtPooki SgtPooki added exp/intermediate Prior experience is likely helpful effort/days Estimated to take multiple days, but less than a week status/ready Ready to be worked and removed need/triage Needs initial labeling and prioritization labels May 8, 2023
@BigLep
Copy link

BigLep commented May 12, 2023

@SgtPooki : a couple of thoughts:

  1. Do we maybe want to start building out a "client library" for hitting the Trustless HTTP Gateway API for getting blocks and cars. My guess is dotStorage has likely already created this in some form? @lidel may also know of other cases of this being created in JS already.
  2. What is Kubo specific about ipld-explorer-components? I'm basically wondering why we even need a dependency on kubo-rpc-client.

@lidel
Copy link
Member

lidel commented May 12, 2023

  • There is nothing specific about Kubo or JS-IPFS here per se, we just happen to be tightly couple to legacy APIS.
  • The smallest interface this type of app really needs is a function that takes a CID and returns bytes for a single block, all parsing happens in JS in the browser (self-contained).
  • For this app specifically, (diagnostic tool that slowly fetches small chunk of DAG), i advise against CARs, and do block-by-block
  • A single block can be fetched:
    • from a trustless gateway as application/vnd.ipld.raw
    • or be fetched via Helia instance running on page
    • or (opportunistic/if we really need) be fetched from Kubo RPC via ipfs.block.get from js-kubo-rpc-client (if CORS headers are set, and RPC is at the default port)

@SgtPooki
Copy link
Member Author

For this app specifically, (diagnostic tool that slowly fetches small chunk of DAG), i advise against CARs, and do block-by-block

There is already some CAR logic in there, so i assume you're talking about fetching blocks instead of fetching CARs

A single block can be fetched:

I've got this mostly done now, where I query with helia first, with a 5sec timeout, and then query with the trustless gateway.

Prior art for this exists in Peers screen of ipfs-webui (https://www.npmjs.com/package/ipfs-geoip fetches raw blocks from HTTP gateway and does all parsing in JS – see code here)

It looks like the geoip code is not validating the blocks after retrieving? There isn't any info at https://docs.ipfs.tech/reference/http/gateway/#example-fetching-a-single-raw-block-from-a-public-gateway on how to do that, but I think it's something like:

  1. have CID instance (with codec type and whatnot)
  2. fetch raw block
  3. construct CID using raw block bytes, using multihash+codec+base+cidVersion from CID instance in step 1 above.
  4. ensure step 1 CID.toString() matches step3 CID.toString() ?

@BigLep
Copy link

BigLep commented May 20, 2023

Thanks @SgtPooki . Looking forward to seeing the PR here.

For your last question, if you're getting blocked, I would post in #ip-js. I expect various folks can point to the JS way of doing block validation.

@SgtPooki
Copy link
Member Author

FYI: the verify block functionality is handled by

export async function verifyBytes (providedCid: HeliaCID, bytes: Uint8Array): Promise<void> {

@BigLep BigLep moved this from 🥞 Todo to 🔎 In Review in Helia Working Group (inactive) May 31, 2023
@github-project-automation github-project-automation bot moved this from 🔎 In Review to 🎉 Done in Helia Working Group (inactive) Jun 8, 2023
@github-project-automation github-project-automation bot moved this from Planned / Backlog to Done in IPFS-GUI (PL EngRes) Jun 8, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
effort/days Estimated to take multiple days, but less than a week exp/intermediate Prior experience is likely helpful status/ready Ready to be worked
Projects
No open projects
Status: Done
3 participants