Commit Graph

49 Commits

Author SHA1 Message Date
Yurii Rashkovskii d4de1c824f
Problem: can't merge "required_signatures is static"
This is because other changes on master are in conflict.

Solution: merge and resolve conflicts

Merge remote-tracking branch 'origin/master' into required-signatures
2018-06-04 14:27:13 -07:00
Yurii Rashkovskii 9b131a2385
Merge pull request #95 from yrashk/mod-refactor
Problem: potential loss of database updates
2018-06-04 14:14:45 -07:00
Yurii Rashkovskii ae8cc1552f
Problem: slow performance and regular timeouts sending transactions
Solution: fix the maximum number of concurrent HTTP request
at a transport level.

It is set by default to 64 and there's now a new configuration
parameter (`concurrent_http_requests`) in `home` and `foreign`
sections. Previously used `concurrency` parameter from transactions
configuration has been removed.
2018-06-01 18:31:47 -07:00
Yurii Rashkovskii af81eb0d57
Problem: potential loss of database updates
chance of loss of database updates that would cause it to redo
transactions it already did.

Let's say we've got some database updates through deposit relaying:
https://github.com/poanetwork/poa-bridge/blob/master/bridge/src/bridge/mod.rs#L164-L165

Then, during relaying withdrawals, an error happened:
https://github.com/poanetwork/poa-bridge/blob/master/bridge/src/bridge/mod.rs#L171-L172

This means that we won't reach
https://github.com/poanetwork/poa-bridge/blob/master/bridge/src/bridge/mod.rs#L185-L193
to save the result.

Also, in a similar vein, if one of these streams was to end
(`Ready(None)`) we'd experience a similar loss of updates:
https://github.com/poanetwork/poa-bridge/blob/master/bridge/src/macros.rs#L5

Solution: refactor bridge into two streams, splitting responsibilities

One stream (`BridgeEventStream`) returns `BridgeChecked` and the other
(`Bridge`) writes those checks down to the database.

This way we're not accumulating chcecks before we serialize them,
risking not serializing them at all in the event of an unrelated error.

Fixes #84
2018-05-25 17:31:11 -07:00
Yurii Rashkovskii fac38d7059
Problem: can't be merged with the master without a conflict
Solution: resolve the conflict

(Merge remote-tracking branch 'origin/master' into required-signatures)
2018-05-23 22:20:19 -07:00
Peter van Nostrand aaa5bee49e Problem: no functionality exists to dynamically fetch gas-prices
Currently, gas-prices are set upon bridge startup via the
Users's config TOML file; this value remains constant for the
life of the Bridge.

Solution: create a mechanism that asynchronously queries
gas-prices from an "Oracle" service on a timed interval. This
mechanism should be a stream of gas-prices that can be polled
from the Bridge.
2018-05-23 20:42:13 -04:00
Yurii Rashkovskii 379973f315
Problem: tracking RequiredSignaturesChanged is complicated
This requires retreiving validators contract, calling
`requiredSignatures()` and carefully tracking
`RequiredSignaturesChanged` events.

Solution: use recently introduced additional parameter in
CollectedSignatures to obtain the number of required signatures.
2018-05-23 01:02:12 -07:00
Yurii Rashkovskii 8a56c5cafb
Problem: required_signatures is static
Validators' information is completely configured through validators
contracts and does not depend on `authorities.required_signatures`
parameter of bridge's configuration.

The number of validators also could be changed during run-time and
therefore `authorities.required_signatures` parameter will not reflect
the actual number of signatures required for transaction validation.

Solution: retrieve required_signatures from RequiredSignaturesChanged
event and requiredSignatures() method

Closes #74
2018-05-19 08:38:53 -07:00
Yurii Rashkovskii 40b21ddb7d
Problem: errors do not show their context
If the error like this appears in the logs:
```
INFO:bridge::bridge::withdraw_confirm: waiting for new withdraws that
should get signed
WARN:bridge: Bridge crashed with Error(Transport("Incomplete"), State {
next_error: None, backtrace: None })
Error(Transport("Incomplete"), State { next_error: None, backtrace: None
})
```
it is hard to understand which side of the bridge failed. The message
must contains type of operation (`deposit_relay`, `withdraw_confirm` or
`withdraw_relay`) and side of bridge (URL of RPC channel).

Solution: record error's top level context and print it out if recorded

Addresses #75
2018-05-08 00:48:35 -07:00
Yurii Rashkovskii fbe77d7359
Problem: bridge sends out transactions slowly
This is because it is limiting them to one at a time
per operation type. This was done so that there's no
gaps in nonces due to undelivered transactions.

Solution: allow concurrent sending of transactions

By default, 100 transactions are allowed.

Note, however, that now there's a chance that nonce
gaps may be formed under cerain circumstances.
2018-05-03 14:14:42 -07:00
Yurii Rashkovskii 935f6bdc9b
Problem: bridge crate tests failing to compile
Solution: bring them up to date
2018-05-01 10:03:42 -07:00
Yurii Rashkovskii a1269272e2
Problem: nonce reuse
Unfortunately, bridge will still reuse nonce very often.
Specifically when trying to send more than one transaction at
a time, clearly a faulty behaviour.

Solution: chain retrieving a nonce with subsequent sending
of the transaction.

However, chaining these is not enough as it'll still fail.

This is happening because bridge module is polling all its components
(deposit_relay, withdraw_confirm, withdraw_relay) sequentially,
 and some of them maybe waiting on their transactions to go through.

However, those transactions are also done as composed futures of nonce
retrieval and transaction sending. This means that it is very often
that first, these futures will go through the nonce acquisition process,
get the same values, and then submit transactions with the same nonce.

This patch makes NonceCheck future check if the transaction failed
with this specific issue of nonce reuse and effectively restarts from
the beginning in that case, repeating nonce acquisition process... until
it succeeeds.
2018-04-29 13:20:42 -07:00
Yurii Rashkovskii 94b1343594
Problem: sending unsigned transactions over API
This means that the node has to sign the transaction itself.
It might be acceptable in a localized setup, but can't be used
with untrusted setups. For example, once HTTP RPC is supported,
we can't really use infrastructure like INFURA to send transactions.

Solution: switch to signing transactions in bridge

This absolutely requires separating the accounts used by validators
and administrative tasks as this will otherwise interfere with
management of nonces.
2018-04-26 17:50:07 -07:00
Yurii Rashkovskii 618d3bcb00
Problem: bridge crashes with insufficient balance
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).

Solution: make bridge track its balance and hande insufficient

Bridge will crash with ERR_INSUFFICIENT_FUNDS (code 4) so that
supervisor can decide what should happen next. It will also log the
condition.

P.S.Make sure to run the tests with `--test-threads=1` to avoid
other test conflicting with this one. A better solution to this
issue must be devised later, however.
2018-04-04 10:42:16 +04:00
Maximilian Krüger 0246119518 remove panics. improve error handling for signature.
resolves grumble:
https://github.com/paritytech/parity-bridge/pull/114#discussion_r168406741
2018-02-15 12:49:12 +01:00
Maximilian Krüger ca7f758587 remove unnecessary `.clone()`
resolves grumble:
https://github.com/paritytech/parity-bridge/pull/114#discussion_r168406837
2018-02-15 11:18:26 +01:00
Maximilian Krüger 107141e0b7 remove unused imports 2018-02-14 12:13:11 +01:00
Maximilian Krüger 5b446b48a3 remove `use` of symbols that no longer exist 2018-02-12 16:35:36 +01:00
Maximilian Krüger 4a3b4ba1f0 remove test for function that doesn't exist anymore 2018-02-12 15:23:41 +01:00
Maximilian Krüger be18c96d31 remove conversion (web3 -> ethabi) that is no longer needed (ethereum-types) 2018-02-12 14:58:14 +01:00
Maximilian Krüger 87c57c9963 extract code dealing with signatures into module 2018-02-12 14:57:57 +01:00
Maximilian Krüger 5000043930 extract code dealing with Withdraw message
remove ignoring of messages with insufficient value
because no longer needed.

use user specified gas price on withdraw.
2018-02-09 09:44:55 +01:00
Maximilian Krüger c0d87f19c0 magic numbers -> constants 2018-02-09 09:41:46 +01:00
Maximilian Krüger 41543ca40e user explicitely specifies homeGasPrice on withdraw. resolves #112 2018-02-09 09:41:45 +01:00
debris f0dcb70cf3 remove redundant conversions between types 2018-02-07 14:58:50 +01:00
debris 5e90f850fd updated web3 to latest version and resolved build issues 2018-02-07 14:50:49 +01:00
debris cc2c3fea9b bump ethabi and ethereum-types to latest versions 2018-02-06 22:57:06 +01:00
Maximilian Krüger 73dd502b88 bridge.sol: authority -> authorityResponsibleForRelay 2018-01-26 10:00:44 +01:00
Maximilian Krüger ddc5ffcfd4 fix #87 by parsing rpc outputs with ethabi 2018-01-22 15:10:57 +01:00
Maximilian Krüger c33126b961 withdraw_relay: break long type into several lines 2018-01-22 14:35:54 +01:00
Maximilian Krüger b8fc1cd55c withdraw_relay.rs: use rustc_hex::ToHex 2018-01-19 15:11:21 +01:00
Maximilian Krüger ee786ccd2c withdraw_relay.rs: add some info level logging to ease troubleshooting 2018-01-19 14:49:54 +01:00
Maximilian Krüger 0798bf181d withdraw_relay.rs: add some docstrings 2018-01-09 13:11:02 +01:00
Maximilian Krüger d9964a8472 address grumble
https://github.com/paritytech/parity-bridge/pull/77#discussion_r160170545
2018-01-08 17:43:38 +01:00
Maximilian Krüger 171bf29ba0 withdraw_relay.rs: make withdraw_relay_payload take references as we no longer necessarily own its inputs 2018-01-08 14:26:57 +01:00
Maximilian Krüger 20bc965604 withdraw_relay.rs: fetch whether message value is sufficient and filter out insufficient 2018-01-08 14:26:19 +01:00
Maximilian Krüger d4d1b2d582 withdraw_relay.rs: add FetchMessageValueSufficient to WithdrawRelayState 2018-01-08 14:25:46 +01:00
Maximilian Krüger 24a926bdb6 withdraw_relay.rs: add message_value_sufficient_payload 2018-01-08 14:25:16 +01:00
Maximilian Krüger bd6ff44ced add comments 2018-01-08 14:16:33 +01:00
Maximilian Krüger 21bb9a6adc add docstring 2018-01-08 14:15:41 +01:00
Maximilian Krüger e71c9c53c9 withdraw_relay.rs: improve docstring 2018-01-08 14:14:39 +01:00
Maximilian Krüger 3d76ce0309 withdraw_relay.rs: improve var name and comments 2018-01-08 14:12:55 +01:00
Maximilian Krüger 5b98a06873 withdraw_relay.rs: add some docstrings 2018-01-08 11:43:55 +01:00
Maximilian Krüger def974e0e3 WithdrawRelayState::Fetch -> WithdrawRelayState::FetchMessagesSignatures 2018-01-08 11:18:26 +01:00
debris 59403966fc rename to home/foreign, closes #46 2017-10-10 11:02:58 +02:00
debris 6286a76708 timeouts 2017-08-31 17:32:34 +02:00
debris 1a2cb47124 bridge writes to backing database 2017-08-28 16:48:01 +02:00
debris 316b9ce4a0 withdraw_relay guarantees and tests 2017-08-28 12:28:21 +02:00
debris fa962565ad repo overhaul, separated binary from library, closes #10, added tests crate 2017-08-25 00:36:13 +02:00