Commit Graph

1129 Commits

Author SHA1 Message Date
Thomas Eizinger
edb8851ce2
Fix env filter for asb
1. The asb didn't log any if the statements within main.rs
2. We were initializing unnecessary filters that don't make any sense
for the asb. warp and http are not used and the harness-es are for
test only.
2021-03-17 11:21:05 +11:00
bors[bot]
105d855a4a
Merge #318
318: Alice spawns swaps outside the event loop r=thomaseizinger a=da-kami

Instead of spawning the swap inside the event loop we send the swap back
to the caller to be spawned. This means we no longer need the remote handle
that was only used in the tests.
This now properly logs the swap results in production.
It also gives us more control over Alice's swap in the tests.

Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-03-17 00:17:23 +00:00
Thomas Eizinger
273cf15631
Introduce Watchable abstraction for Bitcoin wallet
We have a repeated pattern where we construct one of our
Tx{Cancel,Redeem,Punish,Refund,Lock} transactions and wait until
the status of this transaction changes. We can make this more
ergonomic by creating and implementing a `Watchable` trait that
gives access to the TxId and relevant script for this transaction.
This allows us to remove a parameter from the `watch_until_status`
function.

Additionally, there is a 2nd pattern: "Completing" one of these
transaction and waiting until they are confirmed with the configured
number of blocks for finality. We can make this more ergonomic by
returning a future from `broadcast` that callers can await in case
they want to wait for the broadcasted transaction to reach finality.
2021-03-16 19:24:32 +11:00
Thomas Eizinger
a0830f099f
Pass relevant execution params into wallet instead of via functions
The execution params don't change throughout the lifetime of the
program. They can be set in the wallet at the very beginning.
This simplifies the interface of the wallet functions.
2021-03-16 19:24:31 +11:00
Thomas Eizinger
84ea092a1b
Remove unnecessary state variables by constructing TXs on demand 2021-03-16 19:24:31 +11:00
rishflab
e5c0158597
Greatly reduce load onto the Electrum backend
We achieve our optimizations in three ways:

1. Batching calls instead of making them individually.

To get access to the batch calls, we replace all our
calls to the HTTP interface with RPC calls.

2. Never directly make network calls based on function
calls on the wallet.

Instead, inquiring about the status of a script always
just returns information based on local data. With every
call, we check when we last refreshed the local data and
do so if the data is considered to be too old. This
interval is configurable.

3. Use electrum's notification feature to get updated
with the latest blockheight.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
Co-authored-by: Rishab Sharma <rishflab@hotmail.com>
2021-03-16 19:24:31 +11:00
Thomas Eizinger
e17cbadccb
Don't add signatures to transaction unless necessary
In order to compute the cancel TxID, we don't need to add the
signatures.
2021-03-16 19:22:47 +11:00
Thomas Eizinger
6beb732e35
Eliminate build_bitcoin_punish_transaction
We reduce indirection by constructing TxPunish directly based off
`State3` and make the type itself more powerful by moving the logic
of completing it with a signature onto it.
2021-03-16 19:21:15 +11:00
Daniel Karzel
d85c0ce57c Re-introduce punish test 2021-03-16 18:34:00 +11:00
Daniel Karzel
ea05c306e0 Alice spawns swaps outside the event loop
Instead of spawning the swap inside the event loop we send the swap back
to the caller to be spawned. This means we no longer need the remote handle
that was only used in the tests.
This now properly logs the swap results in production.
It also gives us more control over Alice's swap in the tests.
2021-03-16 18:31:46 +11:00
Thomas Eizinger
dd6c66a594
Move completing of Bitcoin redeem tx onto RedeemTx
This allows us to have access to RedeemTx from within the scope
of the state transition which we are going to need for more
efficient watching of what happens to this TX on the blockchain.
2021-03-16 17:11:31 +11:00
rishflab
21429f24b2
Inline wait_for_locked_bitcoin() that is only called once
Reduce indirection.
2021-03-16 17:11:31 +11:00
rishflab
6a3e4802f1
Remove redundant reference 2021-03-16 17:11:30 +11:00
rishflab
458a8d594a
Rename fn param to correctly reflect underlying type 2021-03-16 17:11:30 +11:00
rishflab
752e5be8f3
Cleanup test logging 2021-03-16 17:11:29 +11:00
Thomas Eizinger
2704245ed5
Fix monero refresh interval
The comparison should be the MAXIMUM of the two values, not the
minimum, otherwise we always refresh at an interval of 1 second.
2021-03-16 17:10:34 +11:00
Lucas Soriano
4a4729d331
Minor fixes in README.md 2021-03-16 13:05:43 +11:00
bors[bot]
904312d1e9
Merge #313
313: Bump tracing-subscriber to 0.2.17 r=da-kami a=thomaseizinger

This release includes a bug-fix that removes an erroneous space
from our logs when running with `--debug`.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-03-15 06:01:09 +00:00
bors[bot]
a02389f8bd
Merge #314
314: Remove CLI config file in favour of parameters r=thomaseizinger a=da-kami

Fixes #282 

The CLI has sensible default values for all parameters,
thus a config file is not really an advantage but just
keeps getting in our way, so re remove it.

Trait impls on `Data` needed for structopt, see https://docs.rs/structopt/0.3.21/structopt/#default-values

Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-03-15 05:37:50 +00:00
bors[bot]
8505d76561
Merge #311
311: Add asb to release including ARM build r=da-kami a=da-kami

https://github.com/da-kami/xmr-btc-swap/releases/tag/0.3-test

The asb ARM build does neither run tests on CI not smoke test for the binary upon release because the there is no standard runner for ARM. One can configure a self-hosted one but I think that might be an overkill: https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners

I did download the produced ARM tar, unpack and test on the raspi, it works :)

Concerning openssl depdency see:

https://github.com/da-kami/xmr-btc-swap/runs/2093523365?check_suite_focus=true
https://www.reddit.com/r/rust/comments/axaq9b/opensslsys_error_when_crosscompiling_for/


Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-03-15 05:26:49 +00:00
Daniel Karzel
222724b59a Update bors config
Add armv build check to bors.
Update build and test names due to matix configuration changes.
2021-03-15 16:11:35 +11:00
Daniel Karzel
0091b6cdaf Remove CLI config file in favour of parameters
The CLI has sensible default values for all parameters,
thus a config file is not really an advantage but just
keeps getting in our way, so re remove it.
2021-03-15 15:41:46 +11:00
Daniel Karzel
442c377490 Remove openssl dependency
Upgrade tokio-tungstenite to 0.14 and use feature flag rustls-tls
to get rid of the openssl dependency.
2021-03-15 14:36:05 +11:00
Daniel Karzel
f8360fe853 .cargo/config.toml for specifying linker
To avoid code duplication we specify the linker for the specific
target armv7-unknown-linux-gnueabihf in the config.toml file as
specified here:
https://doc.rust-lang.org/cargo/reference/config.html#targettriplelinker
2021-03-15 14:36:05 +11:00
Daniel Karzel
6e09653d3f Remove target section from CI
matrix.include does not require the target section to be present because it
specifies the specific matrix combinations to be run.
2021-03-15 14:35:59 +11:00
Thomas Eizinger
a667c0ecd8
Bump tracing-subscriber to 0.2.17
This release includes a bug-fix that removes an erroneous space
from our logs when running with `--debug`.
2021-03-15 10:39:49 +11:00
Daniel Karzel
58c33f8468 Add asb to release including ARM build 2021-03-15 09:58:18 +11:00
bors[bot]
3a5d8aee42
Merge #308
308: Fix incorrect docker tag r=thomaseizinger a=rishflab



Co-authored-by: rishflab <rishflab@hotmail.com>
2021-03-12 07:45:18 +00:00
rishflab
7cb198aea1 Remove pointless todo
The container is defined in the tests module indicating it is only
suitable for these tests
2021-03-12 12:52:23 +11:00
rishflab
9f534996ee Remove unused capability to configure bitcoind docker version tag
We only use one version of this container
2021-03-12 12:50:42 +11:00
rishflab
7b1d901ea0 Fix incorrectly formatted tag 2021-03-12 11:01:52 +11:00
bors[bot]
009597ac49
Merge #306
306: Fix logging and retrying of Monero transaction watching r=thomaseizinger a=thomaseizinger

Hopefully, this should also reduce the load because I am not asking the node every second.

Related: https://github.com/comit-network/xmr-btc-swap/issues/202

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-03-11 07:50:54 +00:00
Daniel Karzel
be52892e65
Monero wallet should not know about all execution params
Instead of passing all execution params in we only make the monero_avg_block_time known to the monero wallet.
2021-03-11 17:43:01 +11:00
Thomas Eizinger
82738b111e
Refactor monero::Wallet::watch_for_transfer to not use backoff
Instead, we use a regular loop and extract everything into a function
that can be independently tested.
`backoff` would be useful to retry the actual call to the node.
2021-03-11 17:42:54 +11:00
bors[bot]
1d1ed13b65
Merge #302
302: Fixup backticks in README r=da-kami a=thomaseizinger



Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-03-11 06:12:20 +00:00
bors[bot]
b956f366b9
Merge #305
305: Disable `backoff`s `max_elapsed_time` functionality r=da-kami a=thomaseizinger

This config setting makes backoff stop retrying if we didn't get an
error within this timeframe.
For us, this results in backoff not actually doing anything.

The connection to kraken is very long-running. It might be active
for hours without failing. However, the default value for
`max_elapsed_time` is set to 15 minutes. As such, once the connection
fails any time after that, backoff doesn't actually retry the operation
but just gives up.

Fixes #303.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-03-11 05:46:02 +00:00
Thomas Eizinger
f0a2134f76
Remove unused field 2021-03-11 15:34:27 +11:00
Thomas Eizinger
7e0c44ad1d
Add avg monero block time to execution params 2021-03-11 15:01:55 +11:00
Thomas Eizinger
d560e69203
Make durations more readable by using extension methods from time 2021-03-11 14:59:57 +11:00
Thomas Eizinger
ecff1d1cbe
Remove indirection of constants
We never use these constants anywhere else, inline them.
2021-03-11 14:57:47 +11:00
Thomas Eizinger
bac0f11898
Disable backoffs max_elapsed_time functionality
This config setting makes backoff stop retrying if we didn't get an
error within this timeframe.
For us, this results in backoff not actually doing anything.

The connection to kraken is very long-running. It might be active
for hours without failing. However, the default value for
`max_elapsed_time` is set to 15 minutes. As such, once the connection
fails any time after that, backoff doesn't actually retry the operation
but just gives up.

Fixes #303.
2021-03-11 13:33:46 +11:00
Thomas Eizinger
8d8b3100ea
Fixup backticks in README 2021-03-10 14:55:36 +11:00
bors[bot]
9279877c8f
Merge #301
301: Refactor the kraken module to automatically re-connect on errors r=thomaseizinger a=thomaseizinger



Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-03-10 00:13:38 +00:00
Thomas Eizinger
9ad2160c69
Refactor the kraken module to automatically re-connect on errors
In order to be able to re-connect on certain errors, we model
connection errors separately from parsing errors. We also change
the API of the whole module to no longer forward all errors to
the subscribers but instead, only update the subscribers with
either a latest rate or a permanent failure in case we exhausted
all our options to re-connect the websocket.

To model all of this properly, we introduce to sub-modules so that
each submodule can have their own `Error` type.

Resolves #297.
2021-03-09 17:37:37 +11:00
Thomas Eizinger
c560b3b21a
Introduce RateUpdate type alias to reduce duplication 2021-03-09 15:39:08 +11:00
Thomas Eizinger
fd5b38739a
Remove constant in favor of inlining string
This removes an import and simplifies the `connect_async` call.
2021-03-09 15:39:07 +11:00
Thomas Eizinger
142e5e2d3a
Use tracing macros by fully-qualifying them 2021-03-09 15:39:03 +11:00
bors[bot]
cc131ecf60
Merge #293
293: Some friday evening goodies r=thomaseizinger a=thomaseizinger



Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-03-08 22:53:58 +00:00
Thomas Eizinger
08923a14f3
Simplify GET request for block tip height 2021-03-05 17:06:17 +11:00
Thomas Eizinger
e9d7d9299c
Simplify the GET request to the tx status URL 2021-03-05 16:56:48 +11:00