iExecBlockchainComputing / iexec-apps

Dockerfile of all iExec apps
18 stars 23 forks source link

Bounty #1 - Soccer Scores DOracle #11

Closed julienbrg closed 4 years ago

julienbrg commented 5 years ago

What you will learn

Prerequisite

App requirements

What I need to do?

An iExec DOracle needs two parts: Off-chain dockerized application, and on-chain smart contract.

1. Dockerized application (off-chain) You need to write a logic that does the following steps:

Then, push you docker image on Dockerhub, and deploy it on iExec using the SDK.

2. Smart contract (on-chain)

Going further: About Decentralized Oracles (optional read)

Programmable blockchains and smart contracts are a big deal, but they live in siloed environments and as such have very limited access to the outside world (i.e. the Internet). The iExec V3 makes it trivial for anyone to deploy his own decentralized oracle, hence allowing developers to leverage the terabytes of data available on the Web 2.0 to build a whole new range of useful and impactful dapps without compromising on the security.

The iExec DOracle uses iExec to execute the oracle logic off-chain and return certified results to the blockchain. Certification can be achieved using a combination of hardware security (TEE - Trusted Execution Environment) and on-chain consensus (iExec’s PoCo). These two mechanism provides tools to ensure results of a DOracle execution can be trusted for the on-chain settlement of off-chain events.

Documentation of the iExec platform, including details about de PoCo protocol can be found at https://docs.iex.ec.

Components of an iExec DOracle.

In order to run, an iExec DOracle needs three essential components:

  1. A dockerized application = off-chain logic that fetches the data your dapp needs.
  2. The output = The data your on-chain dapp needs.
  3. A receiving smart contract = The smart contract that will consume the output.

The app & the output

The dockerized oracle app contains the logic that will be executed and verified by the iExec platform when a call is requested. This logic can be implemented in any language and access any data as long as it can be dockerized and it follows below simple guidelines:

  1. Given a set of input parameters, multiple execution of the same app must provide the exact same results (we say it is a deterministic application).
  2. Output must be encoded in a way that makes it readable on the blockchain. Consider using the abi.encode format.
  3. The result fetched by the appEncoded results (bytes) must be written to the /iexec_out/callback.iexec file. Additionnaly the keccak256 hash of the results (bytes32) must be written to the /iexec_out/determinism.iexec file.

The iExec middleware will perform the consensus on the determinism.iexec file, and will store the callback.iexec file on Ethereum.

The receiving smart contract

The receiving smart contract will be the on-chain receiver that will consume the output. This contract can contain any logic, but it should inherit from the IexecDoracle (available on Github) which provides a routine to retrieve and verify the result of an oracle execution. The PriceOracle shows a good example of such contract.

Security considerations

The iExec framework proposes all the tools to build a secure decentralized oracle. However, simply using the iExec framework won’t prevent issues in the oracle design from threatening the security and the decentralization of the oracle. Here are some points that should be considered:

External resources (such as Web 2.0 APIs) are centralized point of failure. DOracles can forward data from such APIs to the blockchain in a trustless manner, but the data reported on-chain is still subject to manipulation by the API administrator.

If trying to report random values from an off-chain source to the blockchain, be aware that the requester of the call might be able to control the seed. You may want to use additional proof of origin or use commit reveal pattern that only accept oracle calls for which the request has been registered on-chain before the actual value was predictable. In general, providing cryptographically secure randomness to a blockchain is difficult, so don’t try it unless you really understand the different attack vectors.

Design your receiver smart contract to be trustless and censorship resistant. If only a single actor can update it then your oracle might not be properly designed. Anyone with an interest on updating a value must be able to pay for an oracle call that will provided an updated value to the blockchain which nobody can argue against.

Need help?

Again, the documentation is here: https://docs.iex.ec. Feel free to ask for more information on our Slack.

gitcoinbot commented 5 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 300.0 RLC attached to it as part of the iExecBlockchainComputing fund.

erazhu31 commented 5 years ago

HI I would to have more info about the soccer game API and match Id . are they provided ? thanks

gitcoinbot commented 5 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Workers have applied to start work.

These users each claimed they can complete the work by 12 months from now. Please review their action plans below:

1) pengiundev has applied to start work _(Funders only: approve worker | reject worker)_.

Hello, I have experience with JavaScript and I'm very interested in smart contracts and decentralized oracles. I'd love to build a DOracle! :)

Learn more on the Gitcoin Issue Details page.

gitcoinbot commented 5 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work has been started.

These users each claimed they can complete the work by 1 year, 8 months ago. Please review their action plans below:

1) pengiundev has been approved to start work.

Hello, I have experience with JavaScript and I'm very interested in smart contracts and decentralized oracles. I'd love to build a DOracle! :) 2) erazhu31 has been approved to start work.

Hi i have a working test dapp with a soccer api , i would like to have more info to finalize and submit 3) benaitis has been approved to start work.

Hello, I have experience in Javascript and Solidity. I think I would suit well to develop the off-chain dockerized application with the smart contract.

Learn more on the Gitcoin Issue Details page.

sulliwane commented 5 years ago

@erazhu31 @benaitis @pengiundev Hi all!

Thank you for your interest in learning how to build a Decentralized Oracle.

Congrats, we just approved your application.

Good news: the three of you looked motivated so we decided that anyone of you that completes the training will receive the RLC bounty :)

Let's start!

  1. Please join our Slack #tech-support channel so that you can ask your questions to the iExec tech team.
  2. Please post your Slack username in this thread (so we clearly make the link between your profiles).
  3. Make sure you read the article: How to build a Decentralized Oracle on Ethereum — A Step-by-Step Guide.

Don't forget to push your code before so we can review it.

As soon as your DOracle is working, the RLC are yours!

Reminder: That's is part of the Learn iExec & Earn RLC program.

pengiundev commented 5 years ago

My slack username is same as here - pengiundev

pengiundev commented 5 years ago

I think I'm ready - here's the repo with the code - https://github.com/pengiundev/iexecSoccerOracle I deployed the contract at 0xAf782e047A29D2F6345f39D5A071f37E477a5022 and my appId is 0x5b82314Bc4a1C42eCd186Ce5ea551fbA7BCD7305

The biggest struggle was deploying the contract and setting up parity but thankfully @Pepe from slack pointed me to the tutorial and I saw that you have an infura node set up in truffle.js. It was a pretty straightforward process otherwise.

erazhu31 commented 4 years ago

Hi App deployed here : Deployed new app at address 0xC8dEE26645D4b25DFCbA81F182D5d10eA263bc2A App Id: 0x7eDf42aD34C45fC8E73B9634C5e2fE25025040A8 Contract Adr: 0x9A18f111b24aC4973f8333F0A5535baAac4E70eF

i did a PR here https://github.com/iExecBlockchainComputing/iexec-apps/pull/17

pengiundev commented 4 years ago

I opened a pull request - #19

gitcoinbot commented 4 years ago

⚡️ A tip worth 300.00000 RLC (61.32 USD @ $0.2/RLC) has been granted to @erazhu31 for this issue from @sulliwane. ⚡️

Nice work @erazhu31! To redeem your tip, login to Gitcoin at https://gitcoin.co/explorer and select 'Claim Tip' from dropdown menu in the top right, or check your email for a link to the tip redemption page.

gitcoinbot commented 4 years ago

⚡️ A tip worth 300.00000 RLC (61.32 USD @ $0.2/RLC) has been granted to @pengiundev for this issue from @sulliwane. ⚡️

Nice work @pengiundev! To redeem your tip, login to Gitcoin at https://gitcoin.co/explorer and select 'Claim Tip' from dropdown menu in the top right, or check your email for a link to the tip redemption page.

gitcoinbot commented 4 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This Bounty has been completed.

Additional Tips for this Bounty: