452: Asb manual recovery commands r=da-kami a=da-kami
Fixes#377
Allows us to manually finish swaps if we run into error scenarios during execution.
I opted for putting all these commands under subcommand `manual-recovery` to run them e.g. (cancel):
```
./asb manual-recovery cancel [--force] --swap-id (...)
```
I combined the `cancel` and `refund` command in the same commit, because I only adapted the e2e tests once cancel and refund were implemented (cancel alone is a bit useless anyway...).
Co-authored-by: Daniel Karzel <daniel@comit.network>
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.
`asb --help` :
(...)
SUBCOMMANDS:
balance Prints the Bitcoin and Monero balance. Requires the monero-wallet-rpc to be running.
help Prints this message or the help of the given subcommand(s)
history Prints swap-id and the state of each swap ever made.
start Main command to run the ASB.
withdraw-btc Allows withdrawing BTC from the internal Bitcoin wallet.
In the production code it is a weird indirection that we load the state and then pass in the state and the database.
In the tests we have one additional load by doing it inside the command, but loading from the db is not expensive.
461: Add resume-only mode for the ASB r=da-kami a=da-kami
Fixes#378
Resume-only is a maintenance mode where no swaps are accepted but unfinished swaps are resumed.
This is achieve by ignoring incoming spot-price requests (that would lead to execution setup) in the event-loop.
- [x] Refactor `spot_price`, move Alice's decision logic into dedicated `NetworkBehaviour`
- [x] Protocol (network) level tests for the `spot_price` behaviour
Co-authored-by: Daniel Karzel <daniel@comit.network>
Each test spawns swarm for Alice and Bob that only contains the spot_price behaviours and uses a memory transport.
Tests cover happy path (i.e. expected price is returned) and error scenarios.
Implementation of `TestRate` on `LatestRate` allows testing rate fetch error and quote calculation error behaviour.
Thanks to @thomaseizinger for ramping up the test framework for comit-rs in the past!
Instead of handling all errors on the inside spot_price errors are bubbled up (as `SwapRequestDeclined`).
This allows us to test both Alice's and Bob's behaviour for all scenarios.
What goes over the wire should not be coupled to the errors being printed.
For the CLI and ASB we introduce a separate error enum that is used for logging.
When sending over the wire the errors are mapped to and from the `network::spot_price::Error`.
As part of Bob-specific spot_price code was moved from the network into bob.
Clearly separation of the network API from bob/alice.
Move Alice's spot price logic into a dedicated network behaviour that handles all the logic.
The new behaviour encapsulates the complete state necessary for spot price request decision making.
The network behaviour cannot handle asynchronous calls, thus the balance is managed inside the spot price and has to updated regularly from the outside to ensure the spot price balance check has up to date data.
At the moment the balance is updated upon an incoming quote requests.
Code that is relevant for both ASB and CLI remains in the `network::spot_price` module (e.g. `network::spot_price::Error`).
When a CLI requests a spot price have some errors that are expected, where we can provide a proper error message for the CLI:
- Balance of ASB too low
- Buy amount sent by CLI exceeds maximum buy amount accepted by ASB
- ASB is running in maintenance mode and does not accept incoming swap requests
All of these errors returns a proper error to the CLI and prints a warning in the ASB logs.
Any other unexpected error will result in closing the channel with the CLI and printing an error in the ASB logs.
Resume-only is a maintenance mode where no swaps are accepted but unfinished swaps are resumed.
This is achieve by ignoring incoming spot-price requests (that would lead to execution setup) in the event-loop.
466: Add support to dynamically chose bitcoin transaction fees. r=bonomat a=bonomat
Resolves#443 (Bitcoin only).
@da-kami /@thomaseizinger: do you know how fees work in Monero?
If not, I'll read up on it and to come up with a proper strategy.
Monero Fees will be covered in #470
Note:
The there is a hardcoded relative and absolute upper bound. I personally feel safer if this is hardcoded for now as it is too easy to get wrong.
At the time of writing, this equals roughly USD $56.
Eventually we will want to make this also configurable.
Co-authored-by: Philipp Hoenisch <philipp@hoenisch.at>
Co-authored-by: Philipp Hoenisch <philipp@coblox.tech>
Fees are hard to compute and it is too easy to get wrong and lose a lot of money. Hence, a hardcoded maximum of 100,000 satoshi for a single transaction is in place.
Electrum has an estimate-fee feature which takes as input the block you want a tx to be included.
The result is a recommendation of BTC/vbyte.
Using this recommendation and the knowledge about the size of our transactions we compute an appropriate fee.
The size of the transactions were taken from real transactions as published on bitcoin testnet.
Note: in reality these sizes might fluctuate a bit but not for much.
Alice chooses the fee for TxPunish because she is the one that cares.
Bob chooses the fee for TxRefund because he is the one that cares.
Note must be taken here because if the fee is too low (e.g. < min tx fee) then she might not be able to publish TxRedeem at all.
Alice chooses the fee for TxRedeem because she is the one that cares. Note must be taken here because if the fee is too low (e.g. < min tx fee) then she might not be able to publish TxRedeem at all.
473: Bump rust_decimal from 1.12.4 to 1.13.0 r=thomaseizinger a=dependabot[bot]
Bumps [rust_decimal](https://github.com/paupino/rust-decimal) from 1.12.4 to 1.13.0.
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a href="https://github.com/paupino/rust-decimal/commits/1.13.0">compare view</a></li>
</ul>
</details>
<br />
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=rust_decimal&package-manager=cargo&previous-version=1.12.4&new-version=1.13.0)](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>
471: Remove torut patch to custom fork. r=bonomat a=bonomat
https://github.com/teawithsand/torut/pull/10 was merged and a new version released.
Co-authored-by: Philipp Hoenisch <philipp@hoenisch.at>
464: Add short description of how to configure Tor. r=bonomat a=bonomat
@da-kami : Is this the right place to document this?
Co-authored-by: Philipp Hoenisch <philipp@hoenisch.at>
Co-authored-by: Philipp Hoenisch <philipp@coblox.tech>
468: Bump rust_decimal from 1.12.3 to 1.12.4 r=thomaseizinger a=dependabot[bot]
Bumps [rust_decimal](https://github.com/paupino/rust-decimal) from 1.12.3 to 1.12.4.
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a href="https://github.com/paupino/rust-decimal/commits">compare view</a></li>
</ul>
</details>
<br />
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=rust_decimal&package-manager=cargo&previous-version=1.12.3&new-version=1.12.4)](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>
469: Bump tracing-subscriber from 0.2.17 to 0.2.18 r=thomaseizinger a=dependabot[bot]
Bumps [tracing-subscriber](https://github.com/tokio-rs/tracing) from 0.2.17 to 0.2.18.
<details>
<summary>Commits</summary>
<ul>
<li><a href="dd49b99016"><code>dd49b99</code></a> subscriber: prepare to release 0.2.18 (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/1384">#1384</a>)</li>
<li><a href="d9e8eceafd"><code>d9e8ece</code></a> tracing: prepare to release 0.1.26 (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/1383">#1383</a>)</li>
<li><a href="8d428b25d7"><code>8d428b2</code></a> core: prepare to release v0.1.18</li>
<li><a href="848ee2d157"><code>848ee2d</code></a> docs: document span.in_scope() at top-level (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/1344">#1344</a>)</li>
<li><a href="88b176cdb5"><code>88b176c</code></a> tracing: impl <code>From\<EnteredSpan></code> for <code>Option\<Id></code> (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/1325">#1325</a>)</li>
<li><a href="ccfa2cc687"><code>ccfa2cc</code></a> core: add support for <code>Arc\<dyn Subscriber + ...></code></li>
<li><a href="f9a3f17fbb"><code>f9a3f17</code></a> tracing: add an example of <code>tracing</code> in a panic hook (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/1375">#1375</a>)</li>
<li><a href="e63d8e454b"><code>e63d8e4</code></a> core: add <code>Subscriber</code> impl for <code>Box\<dyn Subscriber + ...></code> (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/1358">#1358</a>)</li>
<li><a href="1e8446eaa0"><code>1e8446e</code></a> subscriber: support special chars in span names (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/1368">#1368</a>)</li>
<li><a href="396d9f42a5"><code>396d9f4</code></a> chore: fix cargo docs warnings (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/1362">#1362</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/tokio-rs/tracing/compare/tracing-subscriber-0.2.17...tracing-subscriber-0.2.18">compare view</a></li>
</ul>
</details>
<br />
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=tracing-subscriber&package-manager=cargo&previous-version=0.2.17&new-version=0.2.18)](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>