Commit Graph

17 Commits

Author SHA1 Message Date
Philipp Hoenisch
632293cf91
Add support for swapping through Tor.
This PR does a few things.
* It adds a TorTransport which either dials through Tor's socks5 proxy or via clearnet.
* It enables ASB to register hidden services for each network it is listening on. We assume that we only care about different ports and re-use the same onion-address for all of them. The ASB requires to have access to Tor's control port.
* It adds support to dial through a local Tor socks5 proxy. We assume that Tor is always available on localhost.  Swap cli only requires Tor to be running so that it can send messages via Tor's socks5 proxy.
* It adds a new e2e test which swaps through Tor. For this we assume that Tor is currently running on localhost. All other tests are running via clear net.
2021-04-27 14:51:41 +10:00
Thomas Eizinger
8d76607343
Refactor monero-harness containers
1. Split up image::Monero into Monerod and MoneroWalletRpc
2. Don't use `bash` to run the internal command. Instead we disable
the entrypoint script as per https://github.com/XMRto/monero#raw-commands
3. Remove the start up delay by listening for the correct log message.
To make this more resilient, we make the log level NOT configurable and
instead always log verbosely.
2021-04-26 18:12:57 +10:00
Thomas Eizinger
0970c2bc72
Initialize reqwest clients with verbose logging 2021-04-26 18:12:56 +10:00
Thomas Eizinger
dc840e1562
Take wallet names by reference
We are always passing constants here. Make that more ergonomic.
2021-04-26 12:45:40 +10:00
Thomas Eizinger
22bdc08c83
Get rid of Bob's swap Builder
Doesn't serve any purpose. We are better of just having two
constructors.
2021-04-26 12:45:40 +10:00
Thomas Eizinger
a31d6febca
We don't need to import ourselves 2021-04-26 12:45:36 +10:00
Thomas Eizinger
881913ad9c
Re-order content of harness/mod.rs in a sane way
Most important things come first, remaining items are defined roughly
in the order they are used by the top level components.
2021-04-26 12:45:36 +10:00
dependabot[bot]
19483c5ead
Bump libp2p from 0.36.0 to 0.37.1
Bumps [libp2p](https://github.com/libp2p/rust-libp2p) from 0.36.0 to 0.37.1.
- [Release notes](https://github.com/libp2p/rust-libp2p/releases)
- [Changelog](https://github.com/libp2p/rust-libp2p/blob/master/CHANGELOG.md)
- [Commits](https://github.com/libp2p/rust-libp2p/compare/v0.36.0...v0.37.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-20 11:51:40 +10:00
Thomas Eizinger
f0f7288bb6
Introduce a redial::Behaviour
This behaviour makes Bob re-dial Alice with an exponential backoff as
soon as the connection is lost.
2021-04-14 10:07:14 +10:00
Thomas Eizinger
d4c10a1292
Introduce swarm::{alice,bob} function to construct a Swarm instance 2021-04-14 10:06:32 +10:00
Daniel Karzel
c976358c37
Multiple swaps with the same peer
- Swap-id is exchanged during execution setup. CLI (Bob) sends the swap-id to be used in his first message.
- Transfer poof and encryption signature messages include the swap-id so it can be properly associated with the correct swap.
- ASB: Encryption signatures are associated with swaps by swap-id, not peer-id.
- ASB: Transfer proofs are still associated to peer-ids (because they have to be sent to the respective peer), but the ASB can buffer multiple
- CLI: Incoming transfer proofs are checked for matching swap-id. If a transfer proof with a different swap-id than the current executing swap is received it will be ignored. We can change this to saving into the database.

Includes concurrent swap tests with the same Bob.

- One test that pauses and starts an additional swap after the transfer proof was received. Results in both swaps being redeemed after resuming the first swap.
- One test that pauses and starts an additional swap before the transfer proof is sent (just after BTC locked). Results in the second swap redeeming and the first swap being refunded (because the transfer proof on Bob's side is lost). Once we store transfer proofs that we receive during executing a different swap into the database both swaps should redeem.

Note that the monero harness was adapted to allow creating wallets with multiple outputs, which is needed for Alice.
2021-04-13 18:16:19 +10:00
Daniel Karzel
46f144ac67
Switch monero-rpc to debug in tests
To be able to see CI monero RPC errors.
2021-04-13 17:43:10 +10:00
Thomas Eizinger
3e0301a9d4
Move FixedRate into event_loop module
This is where these types are used, they can be defined in there.
2021-04-06 16:16:57 +10:00
Daniel Karzel
2135a6e53e
Alice resumes swaps 2021-04-01 16:09:13 +11:00
Daniel Karzel
183e8f02de
Wait for lock tx and send transfer proof in separate state
Sending the transfer transaction in a distinct state helps ensuring
that we do not send the Monero lock transaction twice in a restart
scenario.
Waiting for the first transaction confirmation in a separate state
helps ensuring that we send the transfer proof in a restart scenario.
2021-04-01 16:03:19 +11:00
Daniel Karzel
dfd69c9c80
Alice aborts if any timelock expired before locking XMR
Once we resume unfinished swaps upon startup we have to ensure that
it is safe for Alice to act.
If Bob has locked BTC it is only make sense for Alice to lock up the
XMR as long as no timelock has expired. Hence we abort if the BTC is
locked, but any timelock expired already.
2021-04-01 16:02:42 +11:00
Thomas Eizinger
b9d8cbeaa2
Rename testutils to harness
This allows us to bring in a dependency named `testutils`.
2021-03-30 12:59:34 +11:00