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 38 forks source link

Store gas consumption limits in the bridge contracts #18

Open akolotov opened 6 years ago

akolotov commented 6 years ago

As per the bridge deployment process it is necessary to create configuration file for every bridge instance. There is a section in the configuration file which allows to define gas consumption limits which will be used in the bridge transactions:

deposit_relay
withdraw_confirm
withdraw_relay

Since these limits are common for every bridge instance it is redundant to distribute this info among all nodes before deployment begins. Moreover these limits needs to be updated in case of gas consumption changes if the bridge contract is upgraded as per #7. In order to reduce human factor it is worth to update this automatically. Some big constant value for these parameters is not good option to have - it could cause delays in validation since limits will be too big for block validators especially in the Ethereum Foundation network.

Proposal for changes

Solidity

  1. Introduce gasLimitWithdrawRelay in the contract HomeBridge.
  2. Introduce gasLimitDepositRelay and gasLimitWithdrawConfirm field in the contract ForeignBridge.
  3. Setup this parameter as part of bridge contracts deployment process.
  4. Introduce ability to change these parameters as part of bridge contract upgrade process as soon as #7 is implemented. Events must be raised in case of gas limit changes.

Rust

  1. Change bridge/src/bridge/deploy.rs to setup gasLimitWithdrawRelay, gasLimitDepositRelay and gasLimitWithdrawConfirm as part of deployment process.
  2. Introduce new functionality in bridge/src/bridge/deposit_relay.rs, bridge/src/bridge/withdraw_confirm.rs and bridge/src/bridge/withdraw_relay.rs in order to pickup gas limits from the corresponding contract. In order to optimize number of requests made to the blockchain nodes the limits could be re-read as soon as the corresponding event received from the bridge contracts.
rstormsf commented 6 years ago

Solidity side is done