Commit Graph

62 Commits

Author SHA1 Message Date
Daniel Karzel
daa572e5bf
Move recovery commands in dedicated module
Less clutter in the folder structure.
2021-05-07 16:21:02 +10:00
Daniel Karzel
4deb96a3c5
ASB manual recovery commands
Adds `cancel`, `refund`, `punish`, `redeem` and `safely-abort` commands to the ASB that can be used to trigger the specific scenario for the swap by ID.
2021-05-07 16:19:11 +10:00
Thomas Eizinger
1820139786
Use dprint for formatting Cargo.toml files
Invoking cargo tomlfmt on all files is a PITA and as we can see from
the CI scripts, it is often forgotten to as new crates are added to
the workspace.

Using dprint for toml files fixes this.

Unfortunately, we can't use dprint for Rust code yet because there
hasn't been a release of rustfmt in quite a while but we are already
using features from a newer rustfmt via rustup.
2021-04-29 17:35:02 +10:00
Thomas Eizinger
101483118a
Always display log output in CI 2021-04-26 18:12:58 +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
dependabot[bot]
df8bca54d9
Bump dprint/check from v1.2 to v1.3
Bumps [dprint/check](https://github.com/dprint/check) from v1.2 to v1.3.
- [Release notes](https://github.com/dprint/check/releases)
- [Commits](https://github.com/dprint/check/compare/v1.2...73e06d86562a052a5fa32b01e1350a7b8de99966)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-20 01:16:13 +00: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
dependabot[bot]
e730590085
Bump dprint/check from v1 to v1.2
Bumps [dprint/check](https://github.com/dprint/check) from v1 to v1.2.
- [Release notes](https://github.com/dprint/check/releases)
- [Commits](https://github.com/dprint/check/compare/v1...58765d19636462e70cd83fe4de8dfc16e7d6f5d2)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-05 09:10:08 +00:00
Daniel Karzel
084fc618b4 Test Alice refunds if restarted and Bob refunded 2021-04-01 17:47:01 +11:00
Daniel Karzel
2135a6e53e
Alice resumes swaps 2021-04-01 16:09:13 +11:00
Thomas Eizinger
c5827f84ca
Refactor recursive function to loop
This should get rid of the ever-growing stack size issue.
2021-03-29 12:15:48 +11:00
bors[bot]
36b92c9f1f
Merge #380
380: Simplify CI workflow r=thomaseizinger a=thomaseizinger

Some patches extracted out of https://github.com/comit-network/xmr-btc-swap/pull/371.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-03-25 08:10:58 +00:00
Thomas Eizinger
453b8e3ae7
Remove unnecessary TARGET env variable
unknown-linux-gnu is the default for ubuntu, we don't need to
specify this.
2021-03-25 15:19:09 +11:00
Thomas Eizinger
1d3c780912
Allow more than two concurrent tests
There is no reason to limit this, all the docker tests are outside
of the lib.
2021-03-25 15:19:08 +11:00
Thomas Eizinger
8767af8dd3
Simplify matrix for test job 2021-03-25 15:19:08 +11:00
Thomas Eizinger
8bc41ecff4
Improve docs of CI workflow 2021-03-25 11:12:00 +11:00
Thomas Eizinger
febc68c780
Enforce consistent formatting of Markdown files 2021-03-25 11:11:57 +11:00
Thomas Eizinger
638a169a04
Buffer transfer proof if we are not connected to Bob
The request-response behaviour that is used for sending the transfer
proof actually has a functionality for buffering a message if we
are currently not connected. However, the request-response behaviour
also emits a dial attempt and **drops** all buffered messages if this
dial attempt fails. For us, the dial attempt will very likely always
fail because Bob is very likely behind NAT and we have to wait for
him to reconnect to us.

To mitigate this, we build our own buffer within the EventLoop and
send transfer proofs as soon as we are connected again.

Resolves #348.
2021-03-24 15:17:54 +11:00
Daniel Karzel
d85c0ce57c Re-introduce punish test 2021-03-16 18:34:00 +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
Daniel Karzel
58c33f8468 Add asb to release including ARM build 2021-03-15 09:58:18 +11:00
Daniel Karzel
196557b377 Rename binary to swap 2021-03-05 16:14:21 +11:00
Thomas Eizinger
52433f7412
Use Rust cache action 2021-03-04 18:02:20 +11:00
rishflab
e9b56934e8 Add windows to release and build workflow 2021-03-02 15:09:12 +11:00
Daniel Karzel
fe3d6f1fef Rename nectar to asb (automated swap backend) 2021-02-22 10:24:11 +11:00
Thomas Eizinger
fb45ff66eb
Update rust-toolchain to new toml syntax
This allows us to completely skip the "Install Rust" step in CI
because the rust-toolchain file completely describes what we need.
The first invocation of cargo will simply install all the required
components.

Additionally, we make all caches dependant on the version of Rust
that we require.
2021-02-18 13:16:05 +11:00
Thomas Eizinger
8072f4d7ee
Only install tomlfmt if we don't have ~/.cargo/bin cached 2021-02-18 13:15:30 +11:00
Thomas Eizinger
a3b5c13b52
Upgrade to actions/cache@v2.1.4
Usually, we can follow the rolling major tag (@v2) of actions.
However the recent release (2.1.4) is not yet included. See
https://github.com/actions/cache/issues/528 for more details.

We do want to depend on 2.1.4 because it contains a fix that allows
us to use the cache action MacOS. v2 also features better compression
and allows for multiple paths to be specified.
2021-02-17 14:50:44 +11:00
Thomas Eizinger
f1b097877b
Split build_test into build and test
Building binaries and building tests results in different artifacts
inside the `target` directory. If we use distinct caches for these
commands, the caches are more useful because less code has to be
re-built.
2021-02-17 14:46:12 +11:00
Thomas Eizinger
e57c005920
Remove unused matrix entry 2021-02-17 14:43:53 +11:00
Thomas Eizinger
acbc0f5551
Upload nectar binary in addition to swap_cli 2021-02-17 14:42:15 +11:00
Thomas Eizinger
3c7880f771
Fix path to CLI for artifact upload
The name was recently changed but the workflow wasn't adapted.
2021-02-17 14:40:34 +11:00
Daniel Karzel
e353d0e89b Remove tor installation from CI 2021-02-15 10:11:41 +11:00
Franck Royer
eb39add5ff
Fix typo 2021-02-10 16:42:55 +11:00
Franck Royer
15eb9a2fe4
Remove punish test
The punish test needs re-work due to the fact that Alice runs continuously

Currently focusing on the CLI (Bob), so we can re-introduce this test
once we want to ensure that nectar (Alice) punishes.
2021-02-10 16:42:55 +11:00
Franck Royer
3bc8b58b6a
Remove Bob restart tests after communication
The test do not work without acks as we stop the event loop as soon
as a message is considered as "sent" when actually the event loop
and swarm may not have yet sent the message.

The ack allow to avoid this issue as the message was considered "sent"
only once the other party sent a response. However, the ack brings
other issue so a review needs to be done to select the appropriate
solution.
2021-02-10 16:42:55 +11:00
Franck Royer
fd9f633a77
Remove Alice restarts tests
Current focus is on CLI UX. Fair amount of change needs to happen to
cater for Alice (nectar) restart scenarios.
2021-02-10 16:42:55 +11:00
Daniel Karzel
c930ad84a4 Add --force flag for cancel and refund 2021-02-08 21:19:38 +11:00
Daniel Karzel
02f8eb7f18 Add test for cancel/refund before timelock expired 2021-02-08 21:18:37 +11:00
Daniel Karzel
c9adbde5d5 Add test for Bob's manual cancel and refund 2021-02-08 21:17:56 +11:00
Franck Royer
09e0d3b877
Run docker tests in separate GitHub tasks 2021-01-29 13:29:24 +11:00
Franck Royer
5c2f83fd5d
Remove nightly chain 2021-01-29 11:36:13 +11:00
rishflab
0b69573129
Run tests on one thread, increase T1 2021-01-29 11:36:13 +11:00
rishflab
c900d12593 Merge xmr_btc crate
Created network, storage and protocol modules. Organised
files into the modules where the belong.

xmr_btc crate moved into isolated modulein swap crate.

Remove the xmr_btc module and integrate into swap crate.

Consolidate message related code

Reorganise imports

Remove unused parent Message enum

Remove unused parent State enum

Remove unused dependencies from Cargo.toml
2021-01-08 12:34:33 +11:00
Franck Royer
058c214892
Only run 2 tests at the same time to avoid resource issue with docker 2020-12-23 09:17:59 +11:00
Franck Royer
9af8ab3028
Increase stack size to 16MB
Default is 8MB. As we start both Alice and bob in test, it is fine to
double the stack size but still assume it does not impact the
normal execution of the binary.
2020-12-21 08:13:42 +11:00
Franck Royer
2541fad40f
Report times in CI 2020-12-09 17:33:24 +11:00
rishflab
b4ac69fa9c Reduce stack size to prevent CI resource issues 2020-12-07 09:44:26 +11:00
rishflab
c91e9652aa Add alice punish test
Use reusable test init functions for happy path test

Extract tracing setup to reusable function

Move test initialization to seperate functions

Increase stack size in CI

Fix monero max finality time

Force Bob swarm polling to send message 2

Run Bob state to xmr_locked in punish test to force the sending of
message2. Previously Bob state was run until btc_locked. Although
this was the right thing to do, message2 was not being sent as the
swarm was not polled in btc_locked. Alice punish test passes.

Add info logging to executor
2020-12-04 17:23:37 +11:00