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

Bridge must not transact if account balance is less than required for handling transaction #21

Closed akolotov closed 6 years ago

akolotov commented 6 years ago

Currently there are two possible situations related to low balance on the account which is used for bridge operations:

  1. The account which is used to sign transactions to be addressed by ForeignBridge contract has low balance. So, the bridge is not able to do deposit_relay and withdraw_confirm.
  2. The account which is used to sign transactions to be addressed by HomeBridge contract has low balance. So, the bridge is not able to do withdraw_relay.

In both cases bridges hangs silently at the moment of sending transactions and does not proceed with further actions even the operation is intended to be performed in opposite direction (e.g. the bridge hangs at the moment to perform withdraw_relay, so deposit_relay cannot be performed either).

Proposal for changes

Fix the issue - the bridge should not hang if the account has low balance. It should proceed with operations in the opposite direction. It can be achieved by preventing sending transaction if such situation occurs. The error message should be appear in the bridge logs as soon as low balance issue discovered.

akolotov commented 6 years ago

Seems the bridge hangs till the request timeout exceed and crashes after that with the message:

Request eth_sendTransaction timed out
yrashk commented 6 years ago

Generally speaking, would it make sense to make an assumption that if we sent a transaction and got one confirmation, then we're good?

yrashk commented 6 years ago

Should we define the per-transaction cost in the config or infer it dynamically?

akolotov commented 6 years ago

You already have this info in the configuration file: gas * gas_limit

yrashk commented 6 years ago

True. Then I just need to multiply this by the number of transactions I want to send.

akolotov commented 6 years ago

correct

yrashk commented 6 years ago

What should we do if balance check times out?

akolotov commented 6 years ago

can we cache it and use such kind of "expected" value if we got no responce on eth.getBalance() call?

yrashk commented 6 years ago

We can.

akolotov commented 6 years ago

Addressed in https://github.com/poanetwork/parity-bridge/pull/36