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

archon.utils.validateFileFromURI fails to use provided gateway. #22

Open
eccentricexit opened this issue Oct 26, 2019 · 3 comments
Open

Comments

@eccentricexit
Copy link
Contributor

As the title says, this is the code:

const providerURL = 'https://kovan.infura.io/v3/1234342ba...'
const ipfsGateway = 'https://ipfs.kleros.io'
const archon = new Archon(providerURL, ipfsGateway)

...

const data = await archon.utils.validateFileFromURI('/ipfs/QmRNK2cpW2i4Q9BBp58ALuhHnXuKEPkSBLU5q4mdtBG9i4/dutchx-badge.pdf')

Error and prints the following to the console:
GET http://localhost:3000/ipfs/QmRNK2cpW2i4Q9BBp58ALuhHnXuKEPkSBLU5q4mdtBG9i4/dutchx-badge.pdf 404 (Not Found)

Setting the provider with archon.setIpfsGateway(uri) does not solve it.

@satello
Copy link
Contributor

satello commented Oct 26, 2019

This has been an outstanding issue of Archon for some time.

See #14

This issue here is that utils are not in the context of any of the standard contract apis. So these functions rely on higher level functions to do things like concat gateway and ipfs uri and determine if the file validation is necessary. It is unintuitive, but the correct usage here would be to call this function asking it not to validate the file.

const data = await archon.utils.validateFileFromURI(
    'https://ipfs.kleros.io/ipfs/QmRNK2cpW2i4Q9BBp58ALuhHnXuKEPkSBLU5q4mdtBG9i4/dutchx-badge.pdf',
    {
          preValidtated: true
    }
)

Which essentially is just fetching the file. If you are using a gateway that you trust, then the data integrity is already guaranteed by ipfs so there is no need to re-hash it. The major underlying issue that led to this decision in the first place instead of simply re-hashing everything is ipfs hashes use the CID multiformat (ethereum/EIPs#1497 (comment)) and would have to validated differently than our other standard hashes. I think it isn't a bad idea to use the CID multiformat in the standard, however it would cause extra friction for integrators, as it is another step of difficulty above multi hashes which some people already found unintuitive (see earlier in comment thread)

@satello
Copy link
Contributor

satello commented Oct 26, 2019

A refactor that could help with this is to allow for the ipfs gateway to be used in utils. The tradeoff being you need to instantiate the Archon object in order to access utils

@eccentricexit
Copy link
Contributor Author

Right I understand now. I think just updating the docs to provide this information would suffice but since the file is validated on ipfs anyway is not so urgent.

I lowered the priority on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants