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

Unable to PIN existing CID in IPFS browser node #139

Open
logesh2496 opened this issue May 30, 2023 · 18 comments
Open

Unable to PIN existing CID in IPFS browser node #139

logesh2496 opened this issue May 30, 2023 · 18 comments
Labels
kind/bug A bug in existing code (including security flaws) kind/support This is a question or a request for support

Comments

@logesh2496
Copy link

logesh2496 commented May 30, 2023

Pinning only works If I upload some data using unixfs and then use that CID. I couldn't pin a CID thats already available on ipfs.

So how do I use a CID thats already available on ipfs and pin it in my node?

example: I want to pin this CID: QmRrzxiXGefcF9VbbThGrkhiQeuhPFjRbGgqYZmxYXYkHr on my node

At the moment Im getting the below error:

errors.js:27 Uncaught (in promise) Error: Not Found
at Module.notFoundError (errors.js:27:1)
at MemoryBlockstore.get (memory.js:19:19)
at #walkDag (pins.js:97:1)
at eval (pins.js:52:1)
at eval (index.js:111:1)
at PQueue._PQueue_tryToStartAnother (index.js:285:1)
at eval (index.js:135:1)
at new Promise ()
at PQueue.add (index.js:99:1)
at PinsImpl.add (pins.js:51:1)
at async onPin (ipfs.js:69:17)

@achingbrain
Copy link
Member

Can you please share a full repro case please? Pinning will fetch missing blocks from the network but the error thrown looks like you may be running offline or it could be unrelated.

@logesh2496
Copy link
Author

logesh2496 commented Jun 1, 2023

I'm working on the nextjs examples provided in the helia-examples/helia-nextjs

export default async function getLibp2p ({ datastore }) {
  return await createLibp2p({
    datastore,
    addresses: {
      listen: [
        '/webrtc'
      ],
    },
    transports: [
      webSockets(),
      webRTC()
    ],
    connectionEncryption: [
      noise()
    ],
    streamMuxers: [
      yamux()
    ],
    services: {
      identify: identifyService()
    }
  })
}

const blockstore = new MemoryBlockstore()
const datastore = new MemoryDatastore()

const libp2p = await getLibp2p({ datastore })

// create a Helia node
return await createHelia({
  datastore,
  blockstore,
  libp2p
})
const cid = CID.parse('QmRrzxiXGefcF9VbbThGrkhiQeuhPFjRbGgqYZmxYXYkHr');
const pin = await helia.pins?.add(cid);
//Error here

@achingbrain
Copy link
Member

Ah, I think there was a small bug with how the internal blockstores were being created - please can you try with [email protected]?

@logesh2496
Copy link
Author

logesh2496 commented Jun 2, 2023

That worked, thanks! btw is there any option to get progress from the pin operation? It takes a alot of time and the UI is waiting cluelessly, it would be great to have a progress bar that shows the % downloaded.

So How do I know how much of the content is downloaded, Thanks again!

Screenshot 2023-06-02 at 10 14 04 AM

@achingbrain
Copy link
Member

Almost every API accepts a onProgress event callback with information about the current operation.

Note that it's impossible to know in advance how big a DAG is, unless it's part of the codec or data encoding.

For example @helia/unixfs has a .stat method that will return the UnixFS metadata from the root node that you can use before pinning to see how big the DAG is, but other codecs like dag-cbor may not provide this feature.

@achingbrain achingbrain added kind/support This is a question or a request for support need/author-input Needs input from the original author labels Jun 7, 2023
@logesh2496
Copy link
Author

Tried, but it isn't working. Below is the code:

const cid = CID.parse('QmVXy4WyMaz4ajm2LUUjyu33cH7UDdytHvctdYmchdvdMy')

    const pin = await helia.pins.add(cid, {
        onProgress: (evt) => {
        console.info('pin event', evt.type, evt.detail)
      }
    });

You can try with the same CID, its an image and I expected to see some progress but didn't do anything, and no error too.

@logesh2496
Copy link
Author

@achingbrain any help here?

@whizzzkid
Copy link
Contributor

whizzzkid commented Jun 13, 2023

@logesh2496 I tried your example, but CustomProgressEvent does not have detail property has the detail property, but the value is generic according to the event type, so modifying your example gives me:

const testcid = CID.parse('QmVXy4WyMaz4ajm2LUUjyu33cH7UDdytHvctdYmchdvdMy')

const pin = await helia.pins.add(testcid, {
    onProgress: (evt) => console.log('pin event', evt)
});

and I get:

Added file: bafkreih7eug2oqxx7ft427q4fcce6lnl73q6kmtzaxeldllx266mxr6os4
pin event CustomProgressEvent {
  type: 'blocks:get:bitswap:get',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 1845.2695000171661
}
pin event CustomProgressEvent {
  type: 'bitswap:network:find-providers',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 1846.5817499756813
}
pin event CustomProgressEvent {
  type: 'bitswap:network:dial',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 2155.9229999780655
}
pin event CustomProgressEvent {
  type: 'bitswap:want-block:block',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 3077.842584013939
}
pin event CustomProgressEvent {
  type: 'bitswap:want-block:block',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 3078.4099590182304
}
pin event CustomProgressEvent {
  type: 'blocks:get:blockstore:put',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 3079.382166981697
}
pin event CustomProgressEvent {
  type: 'helia:pin:add',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 3080.369666993618
}
pin event CustomProgressEvent {
  type: 'blocks:get:bitswap:get',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 3081.4172499775887
}
pin event CustomProgressEvent {
  type: 'bitswap:network:find-providers',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 3081.5880420207977
}
pin event CustomProgressEvent {
  type: 'bitswap:network:dial',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 3084.3530420064926
}
pin event CustomProgressEvent {
  type: 'bitswap:network:send-wantlist',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 3084.5707499980927
}
pin event CustomProgressEvent {
  type: 'bitswap:network:dial',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 3185.429834008217
}
pin event CustomProgressEvent {
  type: 'bitswap:want-block:block',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 3683.4932919740677
}
pin event CustomProgressEvent {
  type: 'bitswap:want-block:block',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 3684.056666970253
}
pin event CustomProgressEvent {
  type: 'blocks:get:blockstore:put',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 3685.3889999985695
}
pin event CustomProgressEvent {
  type: 'helia:pin:add',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 3685.647750020027
}
pin event CustomProgressEvent {
  type: 'blocks:get:bitswap:get',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 3686.0805420279503
}
pin event CustomProgressEvent {
  type: 'bitswap:network:find-providers',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 3686.1782090067863
}
pin event CustomProgressEvent {
  type: 'bitswap:network:dial',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 3687.336709022522
}
pin event CustomProgressEvent {
  type: 'bitswap:network:send-wantlist',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 3687.422375023365
}
pin event CustomProgressEvent {
  type: 'bitswap:network:dial',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 3792.3495839834213
}
pin event CustomProgressEvent {
  type: 'bitswap:want-block:block',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 4064.3595420122147
}
pin event CustomProgressEvent {
  type: 'bitswap:want-block:block',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 4064.498000025749
}
pin event CustomProgressEvent {
  type: 'blocks:get:blockstore:put',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 4065.210792005062
}
pin event CustomProgressEvent {
  type: 'helia:pin:add',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 4065.5434169769287
}
pin event CustomProgressEvent {
  type: 'blocks:get:bitswap:get',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 4065.7790840268135
}
pin event CustomProgressEvent {
  type: 'bitswap:network:find-providers',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 4065.855333983898
}
pin event CustomProgressEvent {
  type: 'bitswap:network:dial',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 4068.029708981514
}
pin event CustomProgressEvent {
  type: 'bitswap:network:send-wantlist',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 4068.1246669888496
}
pin event CustomProgressEvent {
  type: 'bitswap:network:dial',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 4314.306874990463
}
pin event CustomProgressEvent {
  type: 'bitswap:want-block:block',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 4371.186583995819
}
pin event CustomProgressEvent {
  type: 'bitswap:want-block:block',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 4371.299166977406
}
pin event CustomProgressEvent {
  type: 'blocks:get:blockstore:put',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 4371.788959026337
}
pin event CustomProgressEvent {
  type: 'helia:pin:add',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 4372.11087501049
}
pin event CustomProgressEvent {
  type: 'blocks:get:bitswap:get',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 4372.401666998863
}
pin event CustomProgressEvent {
  type: 'bitswap:network:find-providers',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 4372.487167000771
}
pin event CustomProgressEvent {
  type: 'bitswap:network:dial',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 4373.6427500247955
}
pin event CustomProgressEvent {
  type: 'bitswap:network:send-wantlist',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 4373.714959025383
}
pin event CustomProgressEvent {
  type: 'bitswap:network:dial',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 4466.31320899725
}
pin event CustomProgressEvent {
  type: 'bitswap:want-block:block',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 4910.378666996956
}
pin event CustomProgressEvent {
  type: 'bitswap:want-block:block',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 4910.617749989033
}
pin event CustomProgressEvent {
  type: 'blocks:get:blockstore:put',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 4911.877375006676
}
pin event CustomProgressEvent {
  type: 'helia:pin:add',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 4912.259917020798
}

Reiterating what @achingbrain said before, it would be hard to use this to create a progress bar, but seems to work as expected. Can you please share a repo/pr where this fails?

@achingbrain
Copy link
Member

CustomProgressEvent does not have detail property

Yes it does, but the value is generic according to the event type.

@logesh2496
Copy link
Author

Thanks @achingbrain & @whizzzkid for taking the time to resolve my query.

However the method pins.add() itself wasn't working in the 1.2.1 version. I noticed that many changes had been made to the helia-examples for nextjs now: ipfs-examples/helia-examples@ccc40f0

So I updated the helia package version to 1.3.2 and removed getLibp2p as shown in the current examples repo to keep it simple. I do get some events now, but it errors out pretty quickly:

Screenshot 2023-06-14 at 4 46 55 PM

I understand that the event types are generic. Where can I read about all the event types during the pinning operation?
any events related to the below list could be helpful for better UX.

  • Pinning Started
  • Pinning Completed
  • Pinning Errored

Questions:

  1. Pinning doesn't work and errors.
  2. Does helia package provide the above-listed event types? & reference to all other event types during pinning operation.

Thanks.

@marten-seemann
Copy link
Member

@logesh2496 Are you sure these nodes are online? The errors look like handshake timeouts, which you'd expect to see if the nodes has gone offline.

@github-actions
Copy link
Contributor

Oops, seems like we needed more information for this issue, please comment with more details or this issue will be closed in 7 days.

@logesh2496
Copy link
Author

the page still shows the status of the node as "Online"
image

@achingbrain
Copy link
Member

No, Marten means the remote nodes, the ones being connected to.

@logesh2496
Copy link
Author

ah, got it. Shouldn't it find another node that has a copy of the file? How do I handle this situation where I need to pin a file?

@achingbrain achingbrain removed need/author-input Needs input from the original author kind/stale labels Jul 7, 2023
@ipfs ipfs deleted a comment from github-actions bot Jul 7, 2023
@SgtPooki
Copy link
Member

I can't seem to get files to pin using helia either

@SgtPooki SgtPooki added the kind/bug A bug in existing code (including security flaws) label Jul 11, 2023
@SgtPooki SgtPooki moved this to 🛑 Blocked in Helia Working Group (inactive) Jul 12, 2023
@BigLep
Copy link
Contributor

BigLep commented Jul 13, 2023

@SgtPooki : what repo case were you trying? (I just want to make sure we're all trying the same thing.)

@SgtPooki
Copy link
Member

SgtPooki commented Dec 4, 2023

what repo case were you trying? (I just want to make sure we're all trying the same thing.)

I can't remember at the moment but I will come back to this when I can

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A bug in existing code (including security flaws) kind/support This is a question or a request for support
Projects
No open projects
Development

No branches or pull requests

6 participants