Domain Wrapping - Oracle design

Links

Overview

  •  

Misc. Requirements

Issue

Summary

Decision

Issue

Summary

Decision

Token wrapping and Domain wrapping oracle code should run in the same process

A single process should monitor both the ERC20 and ERC721 contracts and execute both token and domain wrap/unwrap.

 

Log events and exceptions

All events and errors should be logged. Because there will be limited validation, these logs will be the primary way for oracle node operators to troubleshoot issues.

 

V1 History

The initial implementation calls get_actions against V1 history.

 

Setting gasPrice and gasLimit

Use same process as token wrapping

 

Functionality

Wrap

  • Wrap creates a FIO Domain NFT on the Ethereum chain.

Functionality

 

Functionality

 

Oracle Initialization

Same as FIO Token wrapping

Alice calls wrapdomain inside the fio.oracle contract on FIO chain

Example: Calling wrapdomain using Cryptonym:

TBD: Need screenshot

fio.oracle contract actions

fio.oracle contract actions:

TBD: @Casey Gardiner update with Domain wrapping info:

  • 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 FIO/BP fees

  • Increase Alices RAM by 512.

  • Send successful response to Alice

Oracle monitors get_actions API on V1 History node

Process is same as with Token Wrapping except it is monitoring for wrapdomain

Oracle validates the FIO chain wraptokens transaction.

See “Exception handling” below

Oracle executes wrap on fio.erc721 contract on Ethereum chain

  • See:

{ "account": "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B", "tokenURI": "https://127.0.0.1/info.json"}", "obtid": "dfe50aad8e2271f84f87b8e603776d7e7970c636bb899c8993c08e9e2d21c106" }

fio.erc20 contract actions for pre-consensus calls to wrap function

fio.erc721 contract actions:

TBD: Need to update with erc721 information. The below information is copied from the token wrapping document @Adam Androulidakis

  • See:

  • When the initial oracles call wrap:

  • There will be three different transaction IDs by the erc20 contract (two wrap transactions and one wrap/mint transaction) generated from three different Oracles. How does this information make it back to Alice who called wraptokens on the FIO chain? Should the oracle surface an Event? If so, what is listening to that event? Do we assume that the user is using an app that is able to listen to the erc20 events? All of this kind of assumes there is an App that the user is using to wrap tokens… @Pawel Mastalerz

    • Same thing for unwrap

    • Decision: Log all events and errors. No further action required. The expectation is that Alice will NOT be monitoring the status of the various Ethereum transaction IDs. Alice will only be monitoring her account to see if WFIO appears. If not, she will raise a support issue.

fio.erc721 contract actions for final consensus call to wrap function

Example of three oracles calling wrapdomain:

TBD: Need to update with erc721 information @Adam Androulidakis

Using these oracle, we call the wrap function on FIO token contract using web3.js like below. instance.wrap[accounts[5], 10000, "99e20de9bb9f178f3ff1328c089925daff1d5dcb1da7dceaad7fc5126a08eaf5". {from: accounts[1]}); instance.wrap[accounts[5], 10000, "99e20de9bb9f178f3ff1328c089925daff1d5dcb1da7dceaad7fc5126a08eaf5". {from: accounts[2]}); instance.wrap[accounts[5], 10000, "99e20de9bb9f178f3ff1328c089925daff1d5dcb1da7dceaad7fc5126a08eaf5". {from: accounts[3]});
  • When the last oracle calls wrap, the transaction is executed

 

Exception handling

Error condition

Trigger

Oracle Action

Error condition

Trigger

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 logs error and does no further processing of the transaction.

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 logs error and does no further processing of the transaction.

 

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:

Functionality

 

Functionality

 

Oracle Initialization

Same as Token wrapping

Alice (dApp) executes unwrap on Ethereum chain


unwrap(tokenID, fio_address);
TBD: Need screenshot of contract call

fio.erc721 contract actions for valid unwrap transaction

fio.erc721 contract actions

  • Alice provides token ID and the FIO Address for the oracle to send the domain as parameters to unwrap action

  • Alice is paying gas fee for the unwrap

  • Transaction executed:

    • NFT is burned?

    • unwrapped event emitted:
      emit unwrapped(fioaddress, tokenID);

Oracle monitors unwrapped event for transfers

fioContract.getPastEvents('unwrapped',{ // filter: {id: 1}, fromBlock: lastBlockNumber, toBlock: 'latest' }

Oracle validates unwrap transaction

  • See Exception handling below

Oracle executes upwrapdomain on fio.oracle contract on FIO chain

  • Call the FIO unwrapdomain action with FIO Domain, ETH transaction ID, fio address

fio.oracle contract actions for calls to upwrapdomain function

fio.oracle contract Actions:

TBD: need to update with unwrapdomain info @Casey Gardiner

  • 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 success/fail response to the oracle

Exception handling

Error condition

Trigger

Oracle Action

Error condition

Trigger

Oracle Action

Invalid FIO Address

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

Oracle logs error and does no further processing of the transaction.