Implement IPFS multiple gateway support with automatic fallback #2276
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.
Overview
This PR implements support for multiple IPFS gateway URLs with automatic fallback logic in the DAppNode Manager toolkit. The system now tries multiple gateways in order until content is successfully fetched, providing better resilience against gateway failures.
Problem
Previously, the IPFS content fetching relied on a single gateway URL. If that gateway was down or slow, the entire IPFS functionality would fail. This created a single point of failure for package installation and content retrieval.
Solution
The implementation adds multiple gateway support with the following features:
🔄 Automatic Fallback Logic
🔧 API Changes
DappnodeRepository Constructor:
New Gateway URL Management:
🛡️ Error Handling
When all gateways fail, detailed error information is provided:
✅ Backward Compatibility
getIpfsUrl()function maintained for compatibilityKey Changes
DappnodeRepositoryto accept both single URLs and arrays of URLsgetAndVerifyContentFromGateway()andlist()methodsgetIpfsUrls()function that returns prioritized array of gateway URLsBenefits
Testing
This implementation provides a robust foundation for IPFS content fetching that gracefully handles gateway failures while maintaining full backward compatibility with existing DAppNode installations.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
binaries.soliditylang.org/usr/local/bin/node ./build/cli.bundled.js obtain --solc=0.5.16(dns block)ethereum.github.io/usr/local/bin/node ./build/cli.bundled.js obtain --solc=0.5.16(dns block)gateway.ipfs.dappnode.ionode /tmp/demo-simple.js(dns block)node /tmp/demo-single.js(dns block)nonexistent.example.comnode /tmp/demo-simple.js(dns block)ns.dappnode.io/usr/local/bin/node --experimental-specifier-resolution=node --import=tsx/esm /home/REDACTED/work/DNP_DAPPMANAGER/DNP_DAPPMANAGER/packages/utils/node_modules/mocha/lib/cli/cli.js ./test/unit --no-config --recursive --passWithNoTests --no-package --color --exit --extension ts --require dotenv/config --diff --reporter spec --slow 75 --timeout 2000 --ui bdd --watch-ignore node_modules --watch-ignore .git(dns block)relay.trufflesuite.com/usr/local/bin/node ./build/cli.bundled.js obtain --solc=0.5.16(dns block)solc-bin.ethereum.org/usr/local/bin/node ./build/cli.bundled.js obtain --solc=0.5.16(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.