omni/poa-bridge

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

Closed this issue · 10 comments

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.

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

Request eth_sendTransaction timed out

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

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

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

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

correct

What should we do if balance check times out?

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

We can.

Addressed in #36