tellor-io / dataSpecs

Data specifications for oracle queries
17 stars 9 forks source link

GetCID: #143

Closed lordshashank closed 8 months ago

lordshashank commented 8 months ago

Contact Details

shashanktrivedi1917@gmail.com

Just need a new Spot Price?

No response

Query Type Name

GetCID

Description

It would take the link to file and return the CID of the file in location. This would ensure correct decentralized CID calculation for files and getting that data on-chain resolving insolvency cases for both miners and clients in filecoin network resolving major issue.

Your query parameters

  1. url
    • description: File URL
    • value type: string

Your response type

Dispute Considerations

cid will be converted to bytes and posted on-chain. For dispute consideration anyone can run the functions being used to calculate cid which would be opensourced.

Suggested Data Sources

A backend would be deployed to calculate cid from any url, and made opensource. An API of deployed instance would be used to fetch data and for dispute consideration anyone can clone and run the functions to check if data provided is correct.

Form Feedback

No response

tkernell commented 8 months ago

This is a cool idea!

To clarify, let's say I have a cid: ipfs://bafkreibno34e5vklsc4ubyz6q7py6afhjnyz3eti6azicxdj5qmzxnvwva/.

Is this how you would want this cid encoded (in solidity)?

bytes memory cidEncoded = abi.encodePacked("ipfs://bafkreibno34e5vklsc4ubyz6q7py6afhjnyz3eti6azicxdj5qmzxnvwva")

Or would you want the ipfs:// prefix removed?

Also, just so you know, all tellor oracle data is encoded into bytes before being reported. So the above example would be encoded as:

bytes reportData = abi.encode(cidEncoded)
lordshashank commented 8 months ago

sorry encodePacked would not work, changed it to encode.

ipfs:// is not needed. So it should be like - bytes memory cidEncoded = abi.encode("bafkreibno34e5vklsc4ubyz6q7py6afhjnyz3eti6azicxdj5qmzxnvwva")

While using encode would tellor encode it again?

tkernell commented 8 months ago

Yes tellor would encode it again, so if we just define it as a string, it'll get put on chain by tellor exactly as you have cidEncoded above, without any further encoding.

0xSpuddy commented 8 months ago

@lordshashank Ideally (to decentralize) Tellor reporters could download the file and generate CIDs locally, so we're looking into the challenges with that. I wanted to ask you because you might know best already: any recommended open source repo for using python to generate a CID from files? (found this one: https://pypi.org/project/py-ipfs-cid/) What are the risks associated with downloading odd files from IPFS?

lordshashank commented 8 months ago

I guess the repo you gave would work. I use this go repo https://github.com/tech-greedy/generate-car as is more robust and would be deploying my implentation of this only for api returning cid if thats not an issue.

Also about risks, not sure of that never looked on that side of things, being dev have successfully done the flow easily though.

0xSpuddy commented 8 months ago

Commenting again because I want to make sure I understand this flow correctly:

lordshashank commented 8 months ago

All correct, just one thing, lets not put constraint on URL to be IPFS Gateway URL, it can be any custom URL from where file can be downloaded.

0xSpuddy commented 8 months ago

PR for adding the FilecoinCID query type https://github.com/tellor-io/dataSpecs/pull/146/files

0xSpuddy commented 8 months ago

closed with pr #146