Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 21 Next »

Links

Overview

  • Oracle code will be run by designated FIO Chain BPs with access to:

    • FIO Chain: Existing FIO BPs already run FIO nodes.

    • Ethereum Chain: Local Ethereum node is preferred, but Infura or Etherscan can also be used.

  • Oracles will:

    • On the FIO Chain

      • Monitor specific account by inspecting every block and looking for FIO contract wraptokens action

      • Execute ERC20 wrap action to mint wFIO to the designated account

    • On the Ethereum Chain

      • Monitor Ethereum smart contract for inbound transfers of ERC-20 wFIO

      • Execute FIO contract unwrap action to transfer FIO to the designated account

Oracle Go Prototype

The original Oracle prototype code was written in Go and is located at: https://github.com/blockpane/fio.oracle

The FIO wrapping/unwrapping contract

The Ethereum ERC20 wrapping/unwrapping contract

Functionality

There are two main use cases that concern the Oracle, Wrap and Unwrap. These are detailed below.

Watchdog routines

In addition to wrap/unwrap, the Oracle should also have certain watchdog/monitoring routines that ensure the processes and routines executed by the Oracle healthy. For example:

  • Make sure a loop didn’t get stuck.

  • Ensure there are no blocked channels.

  • Ensure the health of the daemon itself.

Wrap

  • Wrap creates wFIO on the Ethereum chain.

  • See the following page for an overview of the Wrap use case: Wrap

Functionality

Alice (via dApp) called wraptokens inside the fio.oracle contract on FIO chain

fio.oracle contract actions:

  • Parameter Validation ( ensuring amount, token codes, pubkey and fees are all properly set )

  • Search oracle registration table (contains all registered oracles) and tally up the total number of registered oracles

  • Collect Oracle fees, sort, and find the median.

  • Send fee to all oracles.

  • Emplace wrapping details inside the oracleldgrs table.

  • Send the wrapped amount from Alice to fio.oracle contract.

  • Collect BP fees

  • Increase Alices RAM by 512.

  • Send successful response to Alice

Oracle monitors wraptokens for transfers

  • Method 1: Web socket subscription via Hyperion (similar to Solidity contract subscription).

    • Note this method requires extra setup on the Hyperion node to do streaming.

  • Method 2: Poll fio.oracle actions using V1 history node.

TBD: Both methods require a history node so we should reach out to BPs with the requirements and ask which method they prefer

Oracle validates wraptokens transaction. If exceptions are found, Oracle takes action to unwind transaction

See Exception handling below

Oracle executes wrap on Ethereum chain

wrap(ethaddress, FIO (SUF) amount, obtid);
ex. wrap(“0x00000000000”, 10000000, “0x123456789”);

fio.erc20 contract actions:

  • ethereum wallet provider (usually truffle/hd-wallet-provider) set to use oracles ethereum private key

  • wFIO recipient eth address, wFIO amount to mint (must match what was wrapped on FIO chain exactly), and the obtid of the FIO transaction are provided as parameters to wrap action

  • Transaction is executed

    • address provided receives wrapped FIO assets

    • event emitted:
      wrapped(address ethaddress, uint256 amount, uint256 obtid);

Oracle validates wrap transaction

  • Oracles monitor all wrap transactions in process to ensure consensus has been reached.

  • If a transaction is stuck in a pre-consensus state for some reason, a rollback should be triggered or a warning event should be thrown.

  • Ensure finality. Don’t end up on a fork.

    • It is common to have transactions go into a mempool, and then transaction ends up in an uncle (orphan) block. If the transaction in the uncle block has not been validated elsewhere, then it should be returned to the mempool. But, there are situations where it can disappear from the mempool.

  • How do transactions leave the memory pool?

  • Why some transactions disappear from the mempool?

  • Err on the side of waiting to make sure the block has reached finality.

  • Only process one transaction at a time to reduce complexity.

Once all Oracles have submitted wrap, the wFIO Tokens will be minted and transferred to designated Ethereum public address

TBD: Does the oracle do any kind of monitoring or validation of the overall transaction (post consensus?)

Exception handling

Error condition

Trigger

Type

fields:name

fields:value

Error message

Oracle Action

Invalid chain

Chain passed to wraptokens action is not Ethereum (Note: this restriction is not enforced in the FIO Contract to allow for wrapping chain expansion without deployment of code)

Oracle triggers unwraptokens action to send FIO back to originating address

Invalid Ethereum address

Public address passed to wraptokens action is not a valid Ethereum address (Note: this restriction is not enforced in the FIO Contract to allow for wrapping chain expansion without deployment of code)

Oracle triggers unwraptokens action to send FIO back to originating address

Unwrap

  • Unwrap converts wFIO on Ethereum chain to FIO Tokens on FIO chain.

  • See the following page for an overview of the Unwrap use case: Unwrap

Functionality

Alice (dApp) executes unwrap on Ethereum chain

unwrap(fio address, amount);
ex. unwrap(hard@edge, 100000000);

fio.erc20 contract actions:

  • Alice provides amount to unwrap and the FIO Address for the oracle to send the FIO to as parameters to unwrap action

  • Alice is paying gas fee for the unwrap

  • Transaction executed:

    • wFIO amount is burned

    • event emitted:
      unwrapped(string fioaddress, uint256 amount);

Oracle monitors unwrap event for transfers

  • Oracle subscribes to fio.erc20 events and reacts to the unwrap event

  • No consensus is required for the unwrap transaction. Any oracle can initiate the FIO unwraptokens action.

    • TBD: How do we prevent multiple oracles from simultaneously initiating unwraptokens?

Oracle validates unwrap transaction

Validation includes:

  • Has another Oracle already initiated the unwraptokens action on the FIO chain?

    • TBD: Other validations?

If exceptions are found, Oracle takes action to unwind transaction

See Exception handling below

Registered Oracles call upwraptokens inside the fio.oracle contract on FIO chain

fio.oracle contract Actions:

  • Parameter Validation ( min/max amount, fio address check )

  • Verify the actor is a registered oracle

  • Find the fio.address inside the fionames table

  • Search for previous votes of the same obt_id

    • If found

      • Search and verify actor has not voted prior

      • copy vector and push account name to list of voted oracles to the vector of votes

      • modify voters table with new vector

    • If not found

      • add actor to new vector

      • emplace new record with voters information

  • Compare number of votes with number of registered oracles

    • if number of votes equal the number of registered oracles, transfer amount from fio.oracle contract to the fio.address provided.

  • Send successful response to the oracle

Oracle validates unwraptokens transaction

  • Oracles monitor all unwraptokens transactions in process to ensure consensus has been reached.

  • If a transaction is stuck in a pre-consensus state for some reason, a rollback should be triggered or a warning event should be thrown.

Once all Oracles have submitted unwraptokens , the FIO Tokens will be transferred to designated Ethereum public address

TBD: Does the oracle do any kind of monitoring or validation of the overall transaction (post consensus?)

Exception handling

Error condition

Trigger

Type

fields:name

fields:value

Error message

Oracle Action

Invalid FIO Address

FIO Address passed in with ERC-20 is not valid or does not exist

Oracle triggers a ERC20 wrap action to send wFIO back to originating address

  • TBD: What event is being monitored for this?

  • No labels

0 Comments

You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.