omni / poa-bridge

POA <-> Ethereum bridge for self transfers of POA native token to POA20 (ERC20 representation). Not supported. Use TokenBridge instead
https://github.com/poanetwork/token-bridge
GNU General Public License v3.0
80 stars 39 forks source link

gasPrice for Foreign chain transactions should be requested through gasprice.poa.network #16

Closed rstormsf closed 6 years ago

rstormsf commented 6 years ago

As an example, ICO wizard makes an API call to https://gasprice.poa.network/, get the fastest or lowest(@igorbarinov ) IF service is not available, use hardcoded value. I'd recommend using standard value from https://gasprice.poa.network/

Should be done on Rust side

https://gasprice.poa.network/

@akolotov please approve

akolotov commented 6 years ago

:) it was in my todo of issues to create for the projects.

Since personally I don't like the idea of yet another service to be requested, I thought about an oracle which will put gas price into the bridge contract. My rationales are:

My suggestion are

  1. create public fields gasPrice in both contracts HomeBridge and ForeignBridge;
  2. initialize gasPrice as part of deployment of contracts.

This will be Phase I

Later in Phase II we will:

  1. provide updateGasPrice method in both contracts to set new gasPrice with some consensus;
  2. develop a tool or the bridge subsystem which will call updateGasPrice periodically.

@rstormsf if you agree let's change the label to solidity and modify the title to reflect the idea of the changing.

akolotov commented 6 years ago

@rstormsf @igorbarinov did you discuss it? should we have a call together to discuss it?

igorbarinov commented 6 years ago

We have gasprice.poa.network on support and monitoring. It's as good as a supported onchain oracle. I'd like to stick with it with an option to hardcode gasprice if that host is not available. I suggest having 21Gwei as a hardcoded parameter.

igorbarinov commented 6 years ago

@phahulin could you create a public dashboard in site24x7 for gasprice oracle for host health and API health

@banteg thank you for the code https://github.com/banteg/gasprice

phahulin commented 6 years ago

@igorbarinov please check out this dashboard https://www.site24x7.com/public/dashboard/8s1wsTAc/g8Ipq0FBcZ91xw291jfLWVBkJ0jC5DLujR/xAyNIDrraYAkxnvoKUBHlauhy7dDGbQxteFTkHMOoiMhfYD63Eyzl6uNzRhBp6KHZIsTkfWPbhiydvLmPEfG

igorbarinov commented 6 years ago

Nice, could we have outage number? duration? disk space also will be good to know

igorbarinov commented 6 years ago

Pashi, nice dashboard! But gasprice oracle is out of sync 🙈😬

akolotov commented 6 years ago

OK. Here is my suggestion:

  1. we introduce public fields gasPrice in both contracts HomeBridge and ForeignBridge;
  2. gasPrice will be initialized as part of deployment of contracts:
    • it equals 1 gwei in HomeBridge
    • it equals 21 gwei in ForeignBridge
  3. In order to perform deposit_relay or withdraw_confirm the bridge will request http://gasprice.poa.network and if it is not available gasPrice of ForeignBridge will be requested.
  4. In order to perform withdraw_relay, gasPrice of HomeBridge will be requested.
rstormsf commented 6 years ago

Bridge should read from config.toml

gas_price_oracle_url = "https://gasprice.poa.network/"
gas_price_speed_type = "fast"

and receive this value in gwei, convert to hex value in wei for signing tx on foreign. this value could be cached only for short period of time ( 5-10min)

akolotov commented 6 years ago

Here is the recent requirements based on discussions:

  1. We do provide options in [home] and [foreign] of configuration file to allow configure a JSON source of gas price:
    gas_price_oracle_url = "https://gasprice.poa.network/"
    gas_price_speed_type = "fast"
    gas_price_update_timeout = 600
  2. We expect that the gas price oracle will return information in the following form: {"block_number":5559089,"block_time":14.824,"instant":50.0,"standard":4.0,"slow":2.0,"fast":5.0,"health":true}
  3. We add the parameter default_gas_price in [home]and[foreign]`
  4. We remove gas_price from [transactions] for deposit_relay, withdraw_confirm and withdraw_relay.

The logic is as follows:

  1. Try to get gas price from the oracle for the corresponding network. It needs to be done on regular basis with usage of gas_price_update_timeout.
  2. If the oracle is not accessible or returns incorrect information, the default gas price (default_gas_price) is used for the corresponding network.
DrPeterVanNostrand commented 6 years ago

In the JSON returned from GET https://gasprice.poa.network:

{
  "block_number": 5584026,
  "block_time": 14.307,
  "instant": 41,
  "standard": 5,
  "slow": 4,
  "fast": 6,
  "health": true
}

does anyone know what does the "health" key-value pair means? Does health: true indicate that the gas prices values returned from the API are trustworthy, while health: false indicates otherwise? If that is the case, then we should use the default gas price in the cases of:

  1. health: false
  2. request duration to gas_price_oracle_url has exceeded gas_price_update_timeout?
banteg commented 6 years ago

health: false means the node is not fully synced and the numbers are off.

DrPeterVanNostrand commented 6 years ago

Ok, cool. Thanks!