forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(forc-pkg): Support IPFS-sourced dependencies (FuelLabs#4299)
## Description Closes FuelLabs#3926. (edited by @kayagokalp to reflect latest status of the PR) This PR adds IPFS support for forc-pkg. To do so, forc relies on existing ipfs local node without embedding a node to forc itself. If local system does not have an ipfs node running, a public gateway (https://ipfs.io) is used as a fallback mechanism and packages are fetched through that. ## Some Context and Future Work For our package registry stuff to work properly we will eventually need to host an IPFS node to make sure that our published packages are pinned by at least one node in the network. That is the case as long as we don't have a way to incentivize people pinning the packages they published. What will happen is that a package will be published by a developer and after we detect the published package our own IPFS node will pin it to make sure it is always accessible. Also some benchmarks are done for public gateway during development. It looks like for initial fetch operations from public gateway spends some time looking for the package pinned by the IPFS node simulating our incoming fuel IPFS node which is explained above. It is manageable but fetching from the fuel IPFS node is instant as it already got the package pinned. We can consider falling back to our own node's gateway api rather than a public one to smooth the process. Finally maybe we can explore embedded ipfs node option as a follow-up, due to the status of IPFS with Rust, it is not very obvious (maybe not event possible atm) how to be able to be fully compatible with kubo, for fetching/publishing our packages. But this is still an open question worth exploring. ## Testing ### To test with a local node: 1. You can install kubo, you can follow the instructions in their website while installing https://docs.ipfs.tech/install/command-line/ 2. Run the `ipfs daemon` service with `ipfs daemon` 3. Add an ipfs source, I have a package already pinned by my IPFS node that you can use: ```toml [dependencies] test_lib = { ipfs = "QmfZ3uH7dFEDkYN5RQfyu4m7L8uk8kGiLkNwzHqsrormSj" } ``` 4. Run `forc build` ### To test public gateway fallback: 1. Either do this before starting `ipfs daemon` or stop your local daemon with `ipfs shutdown`. Add an ipfs source, I have a package already pinned by my IPFS node that you can use: ```toml [dependencies] test_lib = { ipfs = "QmfZ3uH7dFEDkYN5RQfyu4m7L8uk8kGiLkNwzHqsrormSj" } ``` 2. Run `forc build` --------- Co-authored-by: kayagokalp <[email protected]>
- Loading branch information
1 parent
fd2b56d
commit 96c6103
Showing
24 changed files
with
1,084 additions
and
248 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.