Commit Graph

16 Commits

Author SHA1 Message Date
Alexander Kolotov 7c429798b3
Merge pull request #82 from yrashk/required-signatures
Problem: required_signatures is static
2018-07-05 12:34:20 +03:00
Yurii Rashkovskii 18802df14c
Problem: insecure RPCs are subject to MITM attacks
Solution: by default, disallow use of non-TLS RPC endpoints

For testing, there's an escape hatch of a command line
argument `--allow-insecure-rpc-endpoints` (purposefully
long) that will reduce the severity of using a non-TLS
RPC endpoint to a warning in a log file.

It was not made to be a configuration file option to reduce
the risk of this option slipping into a production configuration
file by mistake.

Closes #79
2018-06-04 14:33:32 -07:00
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 8082daa392
Problem: gas price retrieving is not tested well
Solution: extract price retrieving from GasPriceStream
and test it.
2018-05-28 10:04:15 -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 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 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 96ecfab2c6
Problem: unlocking account every time to sign a tx
On my computer, this takes approximately 0.3 seconds, which is clearly
a deal-breaker. In retrospect, this is an obvious problem because
of key derivation function use.

Solution: unlock accounts permanently.

This cut down time to sign one transaction is 0.0001 or so.
2018-04-26 17:53:38 -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
Yurii Rashkovskii 38e1cac265
Problem: intentional bridge shutdowns
It is impossible to tell whether the bridge
is being shut down intentionally or because of
an error. This is particularly important
for supervising the process, both in development
and production.

Solution: handle SIGINT and SIGTERM as a special case
and designate a separate status code (3) for intentional
shutdowns.

Also, include an example supervisor for development
mode (examples/suprevisor). Simply prepend it before
the invocation of bridge to supervise it.
2018-03-15 21:14:37 +07:00
debris 134bf5a620 fixed loading .bin files, filter topics and example gas amounts 2017-10-01 19:18:50 +02:00
debris 6286a76708 timeouts 2017-08-31 17:32:34 +02:00
debris fa962565ad repo overhaul, separated binary from library, closes #10, added tests crate 2017-08-25 00:36:13 +02:00