Commit Graph

1313 Commits

Author SHA1 Message Date
bors[bot]
22fe24f54d
Merge #400
400: Release version 0.4.0 r=da-kami a=comit-botty-mc-botface

Hi @da-kami!

This PR was created in response to a manual trigger of the release workflow here: https://github.com/comit-network/xmr-btc-swap/actions/runs/721831897.
I've updated the changelog and bumped the versions in the manifest files in this commit: 1687f84aa1.

Merging this PR will create a GitHub release and upload any assets that are created as part of the release build.

Co-authored-by: COMIT Botty McBotface <botty@coblox.tech>
Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-04-06 10:18:40 +00:00
Daniel Karzel
cf4d369b9c
Replace commit hash with old versioning scheme v0.3 2021-04-06 20:09:42 +10:00
COMIT Botty McBotface
1687f84aa1 Prepare release 0.4.0 2021-04-06 08:20:31 +00:00
dependabot[bot]
8decb67252
Bump bmrng from 0.5.0 to 0.5.1
Bumps [bmrng](https://github.com/oguzbilgener/bmrng) from 0.5.0 to 0.5.1.
- [Release notes](https://github.com/oguzbilgener/bmrng/releases)
- [Commits](https://github.com/oguzbilgener/bmrng/compare/v0.5.0...v0.5.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-06 07:48:27 +00:00
bors[bot]
32912ebd4a
Merge #394
394: Add a configurable spread to the ASB r=thomaseizinger a=thomaseizinger

Fixes #381.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-04-06 07:39:11 +00:00
bors[bot]
f0a8be6835
Merge #396
396: Remove default connection details from CLI r=thomaseizinger a=rishflab

Connecting buyers to us by default is not consistent with our vision of
a decentralised network of sellers.

Closes #395

Co-authored-by: rishflab <rishflab@hotmail.com>
2021-04-06 07:26:24 +00:00
rishflab
9b0467d43a Remove default connection details from CLI
Connecting buyers to us by default is not consistent with our vision of
a decentralised network of sellers.

Closes #395
2021-04-06 16:59:11 +10:00
bors[bot]
ce1cecb17f
Merge #398
398: Bump dprint/check from v1 to v1.2 r=thomaseizinger a=dependabot[bot]

Bumps [dprint/check](https://github.com/dprint/check) from v1 to v1.2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/dprint/check/releases">dprint/check's releases</a>.</em></p>
<blockquote>
<h2>v1.2</h2>
<p>Upgrade to support new <em>dprint.json</em> configuration file name.</p>
<h2>v1.1</h2>
<p>Upgrades to dprint 0.12.0 for support for the new <em>dprint.json</em> configuration file.</p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="58765d1963"><code>58765d1</code></a> fix: Fix version in README.md</li>
<li><a href="3951ef3848"><code>3951ef3</code></a> feat: Upgrade to dprint 0.12.0</li>
<li><a href="5a6244b61d"><code>5a6244b</code></a> chore: Update instructions.</li>
<li>See full diff in <a href="https://github.com/dprint/check/compare/v1...58765d19636462e70cd83fe4de8dfc16e7d6f5d2">compare view</a></li>
</ul>
</details>
<br />


Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-06 06:51:48 +00:00
bors[bot]
e0b859bb1e
Merge #387
387: Improve the resilience of the network layer r=thomaseizinger a=thomaseizinger

We improve the resilience in two ways:

1. Use a timeout on Bob's side for the execution-setup.
2. Use the `bmrng` library to model the communication between Alice and Bob.

See commit messages for details.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-04-06 06:20:30 +00:00
Thomas Eizinger
a99d12b9df
Add a configurable spread to the ASB
Fixes #381.
2021-04-06 16:16:58 +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
Thomas Eizinger
654cfff2a8
Make kraken module emit PriceUpdates instead of Rates 2021-04-06 16:16:56 +10:00
Thomas Eizinger
cfc530e8ab
Make ask field of Rate private 2021-04-06 16:16:53 +10:00
Thomas Eizinger
bc46d95985
Remove unnecessary Serialize implementations 2021-04-06 16:08:42 +10:00
bors[bot]
4b9513b051
Merge #391
391: asb Bitcoin withdraw and balance commands r=da-kami a=da-kami

Fixes #368

Note: Balance prints both balances - which assumes that the Monero wallet RPC is running. I think that is fine for now.

Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-04-06 05:33:52 +00:00
Daniel Karzel
0341e7c9fc
Point BDK to commit that fixes overflow error
Edge cases of UTXOs where value < fee cause the BDK's `coin_select` calculation to panic.
This issue was fixed upstream thus we point the BDK dependency against the commit of the merged fix.
2021-04-06 14:50:27 +10:00
rishflab
7df93faa4b Remove unnecessary wrapper struct 2021-04-06 11:05:36 +10:00
Daniel Karzel
04b49d7117 Add command to print Bitcoin and Monero balance 2021-04-06 09:19:43 +10:00
Daniel Karzel
96008ec130 Add command to withdraw BTC
If no amount is given the wallet will be drained.
2021-04-06 09:19:43 +10:00
Daniel Karzel
f5e81bb0ee Move seed and env_config outside Start command 2021-04-06 09:19:43 +10:00
Daniel Karzel
d9d697821e Separate bitcoin and monero wallet initialization 2021-04-06 09:19:43 +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
bors[bot]
d144405182
Merge #376
376: ASB resumes unfinished swaps after startup r=da-kami a=da-kami

Fixes #374 

- [x] Save Bob peer-id in database for Alice
- [x]  Alice: Wait for `10` Monero confirmations in `BtcRefunded` instead of `XmrLocked` (requires extending the RPC to distinguish locked / unlocked balance)
- [x] Save Alice peer-id in database for Bob ~~(+ multiaddress and remove params from resume)~~
- [ ] ~~Refactor Bob in test setup (handle event-loop in test setup similar to Alice)~~

I decided against refactoring Bob in the test setup, because eventually we might still want to add concurrent swap tests with multiple Bobs. The refactoring I had in mind would not allow such kind of tests. 
Generally, the current state of the changes already contains enough added value to open the PR :)

Follow ups out of scope

- [ ] Parametrize database with role (Alice / Bob) and remove all the (currently useless) mapping between DB and protocol types.
- [ ]  Alice: Wait for transfer proof ack before transitioning to new `XmrLocked`

Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-04-01 06:49:56 +00:00
Daniel Karzel
084fc618b4 Test Alice refunds if restarted and Bob refunded 2021-04-01 17:47:01 +11:00
Thomas Eizinger
1b2f476cae
Have --force flag only override the timelock check
It might very well be that the cancel transaction is already published.
If that is the case, there is no point in failing the command. We simply
transition to cancel and exit normally.

The reason this comes up now is because Alice now properly waits for
the cancel timelock as well and publishes the cancel transaction first.

Ultimately, she should not do that because there is no benefit to her
unless she can also publish the punish transaction.
2021-04-01 17:28:38 +11:00
Thomas Eizinger
24f444b9f7
Race sending transfer proof against cancel timelock
Sending the transfer proof might never resolve because Bob doesn't
come back online. In that case, we need to make sure we bail out
as soon as the timelock expires.
2021-04-01 17:09:18 +11:00
Thomas Eizinger
c0785ab05a
"Buffer" all requests to Alice until we are connected
We use the "precondition" feature of the `tokio::select!` macro to
avoid polling certain futures. In particular, we skip polling all
futures that - when resolved - require us to send a message to Alice.
2021-04-01 17:09:17 +11:00
Thomas Eizinger
1b0c29b424
Use bmrng to model communicaton of Alice's EventLoop with the handle
This allows us to delay the ACKing of the encrypted signature up until
the swap has actually requested it.

Similarly, it allows us to wait for the ACK of the transfer proof within
the swap before continuing.
2021-04-01 17:09:17 +11:00
Thomas Eizinger
1c47b32681
Use bmrng to model communicaton of Bob's EventLoop with the handle
bmrng is a library providing a request-response channel that allows
the receiving end of the channel to send a response back to the sender.
This allows us to more accurately implement the functions on the
`EventLoopHandle`. In particular, we now _wait_ for the ACK of specific
messages from the other party before resolving the future.

For example, when sending the encrypted signature, the async function
on the `EventLoopHandle` does not resolve until we received the ACK
from the other party.

We also delete the `Channels` abstraction in favor of directly creating
bmrng channels. This allows us to directly control the channel buffer
which we set to 1 because we don't need more than that on Bob's side.
2021-04-01 17:09:17 +11:00
Thomas Eizinger
958e5b12bc
Don't match on expired_timelocks and race it in a select in parallel
There is no point in first checking for the expired timelocks and
then constructing a `select!` that also watches for the timelock to
expiry.

We can simply only have the select! invocation to achieve the same
effect. In case the timelock is already expired, this future will
resolve immediately.

Normally, the polling order of `select!` is pseudo-random. We
configure it to be _biased_ here to make sure the futures are polled
in order.
2021-04-01 17:08:26 +11:00
Thomas Eizinger
dbe03ba1cf
Timeout Bob's execution-setup after 10 seconds
The execution setup is our only libp2p protocol that doesn't have
a timeout built-in. Hence, if anything fails on Alice's side, we
would wait here forever.

Wrapping the future in a timeout ensures that we fail eventually
if this protocol doesn't succeed.
2021-04-01 17:08:26 +11:00
Thomas Eizinger
5d75f1adba
Remove import line in favor of FQ macro usage 2021-04-01 17:08:26 +11:00
Thomas Eizinger
4c2e254543
Don't log subscription
This object is very verbose and not meant to be logged.
2021-04-01 17:08:25 +11:00
Thomas Eizinger
5b230bc75f
Don't import tracing macros
Typing them out is quicker than constantly adjusting imports.
2021-04-01 17:08:25 +11:00
Thomas Eizinger
90a7760124
Add some log statements to bob::cancel 2021-04-01 17:08:25 +11:00
Thomas Eizinger
3f54b39281
Make all error messages start with an uppercase letter 2021-04-01 16:12:14 +11:00
Thomas Eizinger
0ef9d97679
Remove delegation functions in favor of public fields
We don't need to hide the fields of this Behaviour as the only reason
for why this struct exists is because libp2p forces us to compose our
NetworkBehaviours into a new struct.
2021-04-01 16:12:13 +11:00
Thomas Eizinger
b1d0ae8db7
Remove dead code
No codepath constructs this event, we can delete the associated code.
2021-04-01 16:11:57 +11:00
Daniel Karzel
2135a6e53e
Alice resumes swaps 2021-04-01 16:09:13 +11:00
Daniel Karzel
b6e4fb4f9d
Improve comment 2021-04-01 16:06:49 +11:00
Daniel Karzel
d233e9914e
Avoid problems when re-ordering / changing Bob's states
Make it explicit in which states we are able NOT to cancel/refund.
2021-04-01 16:06:48 +11:00
Daniel Karzel
e6dd194f77
next_state loop always exits in final state
Otherwise we can run into scenarios where the loop never properly exits.
2021-04-01 16:06:48 +11:00
Daniel Karzel
d90496931b
Save Alice's peer-id in the db for Bob
This allows loading the seller-peer-id from the database upon resuming a swap.
Thus, the parameters `--seller-peer-id` is removed for the `resume` command.
Other than the peer-id the multi address of a seller can change and thus is
still a parameter. This parameter might become optional once we add DHT support.
2021-04-01 16:06:48 +11:00
Daniel Karzel
bc442bcad3
Await 10 confirmations of lock tx in refund
Awaiting the confirmations in an earlier state can cause trouble with resuming
swaps with short cancel expiries (test scenarios).
Since it is the responsibility of the refund state to ensure that the XMR can
be sweeped, we now ensure that the lock transaction has 10 confirmations before
refunding the XMR using generate_from_keys.
2021-04-01 16:03:38 +11:00
Daniel Karzel
1c129d58c4
Distinguish loading all swaps for alice or bob on db level 2021-04-01 16:03:28 +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
bors[bot]
102fcdc92c
Merge #393
393: Re-word changelog entry for bad readiness check of monero-wallet-rpc r=thomaseizinger a=thomaseizinger

Fix the formatting to be one line per sentence and re-word to focus on what didn't work for the user.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-04-01 03:17:39 +00:00
Thomas Eizinger
e27c153c4a
Re-word changelog entry for bad readiness check of monero-wallet-rpc 2021-04-01 11:35:42 +11:00
bors[bot]
607b3d2fdc
Merge #392
392: Bump monero from 0.11.1 to 0.11.2 r=thomaseizinger a=dependabot[bot]

Bumps [monero](https://github.com/monero-rs/monero-rs) from 0.11.1 to 0.11.2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/monero-rs/monero-rs/releases">monero's releases</a>.</em></p>
<blockquote>
<h2>0.11.2</h2>
<p><strong>Changelog</strong></p>
<ul>
<li>Fix docs.rs compilation errors, add <code>feature(doc_cfg)</code> when building on docs.rs</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="c5d6396c00"><code>c5d6396</code></a> Fix doc cfg, bump version</li>
<li>See full diff in <a href="https://github.com/monero-rs/monero-rs/compare/v0.11.1...v0.11.2">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=monero&package-manager=cargo&previous-version=0.11.1&new-version=0.11.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-03-31 23:03:01 +00:00