Commit Graph

1053 Commits

Author SHA1 Message Date
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
Thomas Eizinger
cde3f0f74a
Remove connection handling from swap execution
The swap should not be concerned with connection handling. This is
the responsibility of the overall application.

All but the execution-setup NetworkBehaviour are `request-response`
behaviours. These have built-in functionality to automatically emit
a dial attempt in case we are not connected at the time we want to
send a message. We remove all of the manual dialling code from the
swap in favor of this behaviour.

Additionally, we make sure to establish a connection as soon as the
EventLoop gets started. In case we ever loose the connection to Alice,
we try to re-establish it.
2021-03-24 15:17:54 +11:00
Thomas Eizinger
804b34f6b0
Listen on all swarm events instead of just behaviour events 2021-03-24 11:39:41 +11:00
Thomas Eizinger
2200fce3f3
Pass Swarm into EventLoop
This reduces the amount of arguments we need to pass into the eventloop
at the expense of slightly more setup of the swarm.
2021-03-24 11:39:41 +11:00
Thomas Eizinger
2c9ab4f6eb
Improve code structure and error messages for running swaps
The quote message was repeated and we should set the overall
failure into a context to know what went wrong.
2021-03-24 11:39:41 +11:00
Thomas Eizinger
0c0a322a8f
Rename module to better represent what it contains
This module provides an implementation of the RequestResponseCodec
using a cbor serialization.
2021-03-24 11:39:40 +11:00
Thomas Eizinger
1de0b39b32
Unify encrypted-signature protocol to a single one 2021-03-24 11:39:40 +11:00
Thomas Eizinger
9979cc9f1f
Unify transfer-proof protocol to a single one
Previously, we had two implementations of this protocol. To reduce
code size, we make Alice and Bob use the same implementation.
2021-03-24 11:39:40 +11:00
Thomas Eizinger
9d0b9abde0
Introduce helper function for mapping RequestResponseEvent
Decomposing a RequestResponseEvent is quite verbose. We can introduce
a helper function that does the matching for us and delegates to
specific `From` implementations for the protocol specific bits.
2021-03-24 11:39:39 +11:00
Thomas Eizinger
73f30320a6
Seed should neither be Clone nor Copy
It is better to not copy around secret data within our process to
make heartbleed-like attacks harder.
2021-03-24 11:39:39 +11:00
bors[bot]
5860d511c9
Merge #365
365: Bump tokio-util from 0.6.4 to 0.6.5 r=thomaseizinger a=dependabot[bot]

Bumps [tokio-util](https://github.com/tokio-rs/tokio) from 0.6.4 to 0.6.5.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/tokio-rs/tokio/releases">tokio-util's releases</a>.</em></p>
<blockquote>
<h2>tokio-util-0.6.5</h2>
<h3>Fixed</h3>
<ul>
<li>util: annotate time module as requiring <code>time</code> feature (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3606">#3606</a>)</li>
</ul>
<p><a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3606">#3606</a>: <a href="https://github-redirect.dependabot.com/tokio-rs/tokio/pull/3606">tokio-rs/tokio#3606</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="b1310ad14d"><code>b1310ad</code></a> chore: prepare tokio-util v0.6.5 (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3622">#3622</a>)</li>
<li><a href="dcac336dc7"><code>dcac336</code></a> chore: prepare Tokio v1.4.0 (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3621">#3621</a>)</li>
<li><a href="c39d9867bb"><code>c39d986</code></a> runtime: add Handle::block_on (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3569">#3569</a>)</li>
<li><a href="e4f76688a0"><code>e4f7668</code></a> runtime: fix memory leak/growth when creating many runtimes (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3564">#3564</a>)</li>
<li><a href="e6103d6661"><code>e6103d6</code></a> docs: add link to PollSender (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3613">#3613</a>)</li>
<li><a href="cc90a5c679"><code>cc90a5c</code></a> chore: mention fix for building docs in contributing guide (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3618">#3618</a>)</li>
<li><a href="f107c4f49b"><code>f107c4f</code></a> timer: fix double newline in module docs (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3617">#3617</a>)</li>
<li><a href="e6a9167bb7"><code>e6a9167</code></a> runtime: avoid unnecessary polling of block_on future (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3582">#3582</a>)</li>
<li><a href="345b29ca11"><code>345b29c</code></a> sync: improve Mutex FIFO explanation (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3615">#3615</a>)</li>
<li><a href="b75d02a2b6"><code>b75d02a</code></a> macros: introduce biased argument for select! (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3603">#3603</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/tokio-rs/tokio/compare/tokio-util-0.6.4...tokio-util-0.6.5">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=tokio-util&package-manager=cargo&previous-version=0.6.4&new-version=0.6.5)](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-23 22:18:41 +00:00
bors[bot]
da0a656c1c
Merge #356
356: Bump serde from 1.0.124 to 1.0.125 r=thomaseizinger a=dependabot[bot]

Bumps [serde](https://github.com/serde-rs/serde) from 1.0.124 to 1.0.125.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/serde-rs/serde/releases">serde's releases</a>.</em></p>
<blockquote>
<h2>v1.0.125</h2>
<ul>
<li>Improve performance of serializing <code>Ipv4Addr</code> (<a href="https://github-redirect.dependabot.com/serde-rs/serde/issues/2001">#2001</a>, thanks <a href="https://github.com/saethlin"><code>@​saethlin</code></a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="e9270e59f0"><code>e9270e5</code></a> Release 1.0.125</li>
<li><a href="72060b779a"><code>72060b7</code></a> Extend test_format_u8 to include u8::MAX</li>
<li><a href="1bb23ad9d1"><code>1bb23ad</code></a> Remove format_u8 when not used by Ipv4Addr impl</li>
<li><a href="9be4c9654a"><code>9be4c96</code></a> Merge pull request 2001 from saethlin/optimize-ipaddr</li>
<li><a href="4114e90bac"><code>4114e90</code></a> Fix off-by-one mistake, explain the offset</li>
<li><a href="8bb07b0743"><code>8bb07b0</code></a> skip UTF8 checking and initialize with b'.'</li>
<li><a href="ba8c1d63c8"><code>ba8c1d6</code></a> use the algorithm from itoa</li>
<li><a href="857a805993"><code>857a805</code></a> Faster Ipv4 serialization prototype</li>
<li>See full diff in <a href="https://github.com/serde-rs/serde/compare/v1.0.124...v1.0.125">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=serde&package-manager=cargo&previous-version=1.0.124&new-version=1.0.125)](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-23 08:17:35 +00:00
dependabot[bot]
9e3bc6cf56
Bump tokio-util from 0.6.4 to 0.6.5
Bumps [tokio-util](https://github.com/tokio-rs/tokio) from 0.6.4 to 0.6.5.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-util-0.6.4...tokio-util-0.6.5)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-23 07:53:14 +00:00
bors[bot]
2b6e9fec4f
Merge #355
355: Bump anyhow from 1.0.38 to 1.0.39 r=thomaseizinger a=dependabot[bot]

Bumps [anyhow](https://github.com/dtolnay/anyhow) from 1.0.38 to 1.0.39.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/dtolnay/anyhow/releases">anyhow's releases</a>.</em></p>
<blockquote>
<h2>1.0.39</h2>
<ul>
<li>
<p>Add an opt-in implementation of <a href="https://docs.rs/anyhow/1.0.39/anyhow/struct.Error.html#method.backtrace"><code>Error::backtrace</code></a> on stable compilers based on the <code>backtrace</code> crate (<a href="https://github-redirect.dependabot.com/dtolnay/anyhow/issues/143">#143</a>)</p>
<pre lang="toml"><code>[dependencies]
anyhow = { version = &quot;1.0&quot;, features = [&quot;backtrace&quot;] }
</code></pre>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="8599c7b532"><code>8599c7b</code></a> Release 1.0.39</li>
<li><a href="d65af362cc"><code>d65af36</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/dtolnay/anyhow/issues/143">#143</a> from dtolnay/backtrace</li>
<li><a href="0ba6408b5e"><code>0ba6408</code></a> Add stable backtrace feature</li>
<li><a href="7e85baecce"><code>7e85bae</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/dtolnay/anyhow/issues/142">#142</a> from dtolnay/backtrace</li>
<li><a href="a476ec40ce"><code>a476ec4</code></a> Indicate a doc_cfg on the Error backtrace() method</li>
<li><a href="fea4d8a8f6"><code>fea4d8a</code></a> Eliminate some needlessly cfg'd Backtrace imports</li>
<li><a href="1631007931"><code>1631007</code></a> Ignore new missing_panics_doc pedantic clippy lint</li>
<li><a href="36265418da"><code>3626541</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/dtolnay/anyhow/issues/137">#137</a> from dtolnay/cast</li>
<li><a href="3fdef75780"><code>3fdef75</code></a> Revert &quot;Show turbofish optional&quot;</li>
<li><a href="4e776b8b52"><code>4e776b8</code></a> Force turbofish on all calls of .cast::&lt;U&gt;()</li>
<li>Additional commits viewable in <a href="https://github.com/dtolnay/anyhow/compare/1.0.38...1.0.39">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=anyhow&package-manager=cargo&previous-version=1.0.38&new-version=1.0.39)](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-23 07:36:40 +00:00
bors[bot]
8eb04a5c8f
Merge #357
357: Bump tokio from 1.3.0 to 1.4.0 r=thomaseizinger a=dependabot[bot]

Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.3.0 to 1.4.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/tokio-rs/tokio/releases">tokio's releases</a>.</em></p>
<blockquote>
<h2>Tokio v1.4.0</h2>
<h3>Added</h3>
<ul>
<li>macros: introduce biased argument for <code>select!</code> (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3603">#3603</a>)</li>
<li>runtime: add <code>Handle::block_on</code> (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3569">#3569</a>)</li>
</ul>
<h3>Fixed</h3>
<ul>
<li>runtime: avoid unnecessary polling of <code>block_on</code> future (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3582">#3582</a>)</li>
<li>runtime: fix memory leak/growth when creating many runtimes (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3564">#3564</a>)</li>
<li>runtime: mark <code>EnterGuard</code> with <code>must_use</code> (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3609">#3609</a>)</li>
</ul>
<h3>Documented</h3>
<ul>
<li>chore: mention fix for building docs in contributing guide (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3618">#3618</a>)</li>
<li>doc: add link to <code>PollSender</code> (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3613">#3613</a>)</li>
<li>doc: alias sleep to delay (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3604">#3604</a>)</li>
<li>sync: improve <code>Mutex</code> FIFO explanation (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3615">#3615</a>)</li>
<li>timer: fix double newline in module docs (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3617">#3617</a>)</li>
</ul>
<p><a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3564">#3564</a>: <a href="https://github-redirect.dependabot.com/tokio-rs/tokio/pull/3564">tokio-rs/tokio#3564</a>
<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3613">#3613</a>: <a href="https://github-redirect.dependabot.com/tokio-rs/tokio/pull/3613">tokio-rs/tokio#3613</a>
<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3618">#3618</a>: <a href="https://github-redirect.dependabot.com/tokio-rs/tokio/pull/3618">tokio-rs/tokio#3618</a>
<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3617">#3617</a>: <a href="https://github-redirect.dependabot.com/tokio-rs/tokio/pull/3617">tokio-rs/tokio#3617</a>
<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3582">#3582</a>: <a href="https://github-redirect.dependabot.com/tokio-rs/tokio/pull/3582">tokio-rs/tokio#3582</a>
<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3615">#3615</a>: <a href="https://github-redirect.dependabot.com/tokio-rs/tokio/pull/3615">tokio-rs/tokio#3615</a>
<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3603">#3603</a>: <a href="https://github-redirect.dependabot.com/tokio-rs/tokio/pull/3603">tokio-rs/tokio#3603</a>
<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3609">#3609</a>: <a href="https://github-redirect.dependabot.com/tokio-rs/tokio/pull/3609">tokio-rs/tokio#3609</a>
<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3604">#3604</a>: <a href="https://github-redirect.dependabot.com/tokio-rs/tokio/pull/3604">tokio-rs/tokio#3604</a>
<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3569">#3569</a>: <a href="https://github-redirect.dependabot.com/tokio-rs/tokio/pull/3569">tokio-rs/tokio#3569</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="dcac336dc7"><code>dcac336</code></a> chore: prepare Tokio v1.4.0 (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3621">#3621</a>)</li>
<li><a href="c39d9867bb"><code>c39d986</code></a> runtime: add Handle::block_on (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3569">#3569</a>)</li>
<li><a href="e4f76688a0"><code>e4f7668</code></a> runtime: fix memory leak/growth when creating many runtimes (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3564">#3564</a>)</li>
<li><a href="e6103d6661"><code>e6103d6</code></a> docs: add link to PollSender (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3613">#3613</a>)</li>
<li><a href="cc90a5c679"><code>cc90a5c</code></a> chore: mention fix for building docs in contributing guide (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3618">#3618</a>)</li>
<li><a href="f107c4f49b"><code>f107c4f</code></a> timer: fix double newline in module docs (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3617">#3617</a>)</li>
<li><a href="e6a9167bb7"><code>e6a9167</code></a> runtime: avoid unnecessary polling of block_on future (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3582">#3582</a>)</li>
<li><a href="345b29ca11"><code>345b29c</code></a> sync: improve Mutex FIFO explanation (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3615">#3615</a>)</li>
<li><a href="b75d02a2b6"><code>b75d02a</code></a> macros: introduce biased argument for select! (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3603">#3603</a>)</li>
<li><a href="a1b4bdee61"><code>a1b4bde</code></a> runtime: mark EnterGuard with must_use (<a href="https://github-redirect.dependabot.com/tokio-rs/tokio/issues/3609">#3609</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/tokio-rs/tokio/compare/tokio-1.3.0...tokio-1.4.0">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=tokio&package-manager=cargo&previous-version=1.3.0&new-version=1.4.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>
2021-03-23 06:50:38 +00:00
dependabot[bot]
1dc5b0b7e6
Bump anyhow from 1.0.38 to 1.0.39
Bumps [anyhow](https://github.com/dtolnay/anyhow) from 1.0.38 to 1.0.39.
- [Release notes](https://github.com/dtolnay/anyhow/releases)
- [Commits](https://github.com/dtolnay/anyhow/compare/1.0.38...1.0.39)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-23 03:55:12 +00:00
dependabot[bot]
56f8f675c7
Bump serde from 1.0.124 to 1.0.125
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.124 to 1.0.125.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.124...v1.0.125)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-23 03:55:06 +00:00
dependabot[bot]
bb685eed01
Bump tokio from 1.3.0 to 1.4.0
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.3.0 to 1.4.0.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.3.0...tokio-1.4.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-23 03:55:01 +00:00
bors[bot]
968502827a
Merge #339
339: Bump dependency versions r=thomaseizinger a=thomaseizinger

Otherwise it will take a long time for dependabot to update all of
these.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-03-23 00:09:49 +00:00
bors[bot]
097197783c
Merge #351
351: Show the actual BTC amount and fee to be swapped r=da-kami a=da-kami

We got user feedback, that it is confusing that the amount "found" in the wallet does not match the amount actually being swapped, thus with this PR we explicitly display the amount swapped and fees.

Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-03-22 23:42:31 +00:00
bors[bot]
189a13c063
Merge #319
319: Alice sweeps refunded funds into default wallet r=da-kami a=da-kami

Alice's refund scenario starts with generating the temporary wallet
from keys to claim the XMR which results in Alice' unloading the wallet.
Alice then loads her original wallet to be able to handle more swaps.
Since Alice is in the role of the long running daemon handling concurrent
swaps, the operation to close, claim and re-open her default wallet must
be atomic.
This PR adds an additional step, that sweeps all the refunded XMR back into
the default wallet. In order to ensure that this is possible, Alice has to
ensure that the locked XMR got enough confirmations.
These changes allow us to assert Alice's balance after refunding.

Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-03-22 05:12:49 +00:00
Daniel Karzel
62079fc342 Punish scenario falls back to refund or fails
If we enter a punish scenario we can be sure the punish timelock is expired.
Thus, we must be able to punish unless Bob published the refund transaction.
There is no benefit in racing punish against refund here, because we cannot recover from a punish tx failure anyway.

The logic was changed to:
Try to broadcast punish tx and await finality.
  If either punish broadcasting of finality fails, try to fetch the refund transaction.
    If it is available extract Bob's Monero key part and transition to refund.
    If refund tx is not available fail without a status update.

Note that we do not distinguish different errors upon failure of punish, because
we cannot recover anyway. If we fail to retrieve Bob's refund tx, we just exit without
a status update so punish can be retried by resuming the swap.
2021-03-22 16:10:01 +11:00
Thomas Eizinger
a228349d8b
Bump dependency versions
Otherwise it will take a long time for dependabot to update all of
these.
2021-03-22 14:48:39 +11:00
Daniel Karzel
668d34080d Show the actual BTC amount and fee to be swapped 2021-03-19 17:40:14 +11:00
bors[bot]
113a29839f
Merge #325
325: Misc cleanup r=thomaseizinger a=thomaseizinger

Miscellaneous cleanups of the `swap`, `state` and `steps` modules.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-03-18 21:57:21 +00:00
Thomas Eizinger
f49f8977d3
Remove dead code 2021-03-18 18:09:30 +11:00
Daniel Karzel
396c4177a6 Alice sweeps refunded funds into default wallet
Since Alice's refund scenario starts with generating the temporary wallet
from keys to claim the XMR which results in Alice' unloading the wallet.
Alice then loads her original wallet to be able to handle more swaps.
Since Alice is in the role of the long running daemon handling concurrent
swaps, the operation to close, claim and re-open her default wallet must
be atomic.
This PR adds an additional step, that sweeps all the refunded XMR back into
the default wallet. In order to ensure that this is possible, Alice has to
ensure that the locked XMR got enough confirmations.
These changes allow us to assert Alice's balance after refunding.
2021-03-18 17:59:48 +11:00
Thomas Eizinger
16dfea035b
Simplify code within BobState::XmrLockProofReceived
To achieve this, we decompose `watch_for_locked_xmr` into two parts:

1. A non-self-consuming function to construct a `WatchRequest`
2. A state transition that can now consume `self` again because
it is only called once within the whole select! expression.

Ideally, we would move more logic onto this state transition (like
comparing the actual amounts and fail the transition if it is not
valid). Doing so would have an unfortunate side-effect: We would
always wait for the full confirmations before checking whether or
not we actually receive enough XMR.

This allows us to have state transitions that consume self.
2021-03-18 15:45:58 +11:00
Thomas Eizinger
338f4b82e5
Introduce dedicated bob::State6 for cancelling 2021-03-18 15:45:57 +11:00
Thomas Eizinger
c32ef92cf5
Simplify code within BobState::EncSigSent 2021-03-18 15:45:57 +11:00
Thomas Eizinger
09e2d5b5d7
Simplify code within BobState::XmrLocked
By reducing the number of local variables, we can greatly simplify
this piece of code.
2021-03-18 15:45:57 +11:00
Thomas Eizinger
776a50137d
Use tokio::select macro instead of function
This is slightly less verbose and therefore hopefully easier to read.
2021-03-18 15:45:56 +11:00
Thomas Eizinger
b1affe3ecf
Insert latest state and call run_until only once
Instead of calling this function in all the branches, we can simply
make the whole match statement evaluate to the new state and perform
this functionality at the very end.
2021-03-18 15:45:56 +11:00
Thomas Eizinger
0d8962762a
Use early return to reduce one level of indentation 2021-03-18 15:45:55 +11:00
Thomas Eizinger
05849505b1
Inline wait_for_bitcoin_refund
This function is essentially a single select! statement and can
easily be inlined into the swap state machine.
2021-03-18 15:45:39 +11:00
Thomas Eizinger
8c9285f1f9
Inline step function because it has been reduced to a single statement 2021-03-18 15:45:36 +11:00
Thomas Eizinger
afb7e816a1
Don't wait for confirmations again
We only call this function within `CancelTimelockExpired`. There is
no need to check the confirmations again.
2021-03-18 15:44:37 +11:00
Thomas Eizinger
c92f2dbc77
Move more domain knowledge onto the TxCancel type 2021-03-18 15:44:37 +11:00
Thomas Eizinger
75aec95b0c
Introduce monero::TransferRequest
This allows us to move critical crypto logic onto `State3` which
holds all the necessary data which consequently allows us to get
rid of `lock_xmr` altogether by inlining it into the swap function.
The reduced indirection improves readability.
2021-03-18 15:44:36 +11:00
Thomas Eizinger
d682433ec9
Move EventLoopHandle next to its impl block
This struct is not that important so it can move further down.
2021-03-18 15:44:36 +11:00
Thomas Eizinger
e77f1729b4
Move extract_monero_private_key onto TxRefund
This functionality is domain-specific to the refund transaction.
Move it onto there.
2021-03-18 15:44:36 +11:00
Thomas Eizinger
a1e065b4e7
Simplify racing cancel timelock against learning enc-sig 2021-03-18 15:44:36 +11:00
Thomas Eizinger
575893fb51
Use domain types in fn signature instead of messages
This simplifies usage witin the swap module.
2021-03-18 15:44:35 +11:00
Thomas Eizinger
64b71d0b16
Remove unnecessary pinning 2021-03-18 15:44:31 +11:00
bors[bot]
af215d9f49
Merge #337
337: Update the preview release text r=thomaseizinger a=thomaseizinger

By default, GitHub uses the last commit message as the body text.
This can be a lot of text if the last commit was from dependabot.

Make the preview release more pleasant to look at by adding a
dedicated body.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-03-18 03:55:51 +00:00
bors[bot]
bd82ae9e98
Merge #335
335: prepare 0.3 release r=da-kami a=da-kami



Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-03-18 01:24:56 +00:00
Daniel Karzel
105e291e67 Update the application name for --version print
swap --version
xmr-btc-swap 0.3.0

asb --version
xmr-btc-asb 0.3.0
2021-03-18 12:24:10 +11:00
Thomas Eizinger
1b8f807288
Update the preview release text
By default, GitHub uses the last commit message as the body text.
This can be a lot of text if the last commit was from dependabot.

Make the preview release more pleasant to look at by adding a
dedicated body.
2021-03-18 12:09:44 +11:00
Daniel Karzel
07542d75ac prepare 0.3 release 2021-03-18 11:11:20 +11:00
bors[bot]
b035515422
Merge #328
328: Bump serde from 1.0.119 to 1.0.124 r=thomaseizinger a=dependabot[bot]

Bumps [serde](https://github.com/serde-rs/serde) from 1.0.119 to 1.0.124.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/serde-rs/serde/releases">serde's releases</a>.</em></p>
<blockquote>
<h2>v1.0.124</h2>
<ul>
<li>Fix possible panic deserializing invalid data as <code>SystemTime</code> (<a href="https://github.com/serde-rs/serde/issues/1997">#1997</a>, thanks <a href="https://github.com/cyang1"><code>@​cyang1</code></a>)</li>
</ul>
<h2>v1.0.123</h2>
<ul>
<li>Support <code>Self</code> keywords in fields of types that derive Deserialize (<a href="https://github.com/serde-rs/serde/issues/1830">#1830</a>, thanks <a href="https://github.com/taiki-e"><code>@​taiki-e</code></a>)</li>
<li>Allow floats to be deserialized from ints in tagged unions (<a href="https://github.com/serde-rs/serde/issues/1842">#1842</a>, thanks <a href="https://github.com/Timmmm"><code>@​Timmmm</code></a>)</li>
<li>Support <code>Self</code> inside fields that use serialize_with (<a href="https://github.com/serde-rs/serde/issues/1970">#1970</a>)</li>
</ul>
<h2>v1.0.122</h2>
<ul>
<li>
<p>Add IntoDeserializer impl for &amp;[u8] (<a href="https://github.com/serde-rs/serde/issues/1898">#1898</a>, thanks <a href="https://github.com/Mingun"><code>@​Mingun</code></a>)</p>
</li>
<li>
<p>Handle unrecognized numeric field keys during deserialization of a field_identifier, equivalently to string field keys (<a href="https://github.com/serde-rs/serde/issues/1914">#1914</a>, thanks <a href="https://github.com/Mingun"><code>@​Mingun</code></a>)</p>
</li>
<li>
<p>Add attribute to override default deserialization failure expectation message (<a href="https://github.com/serde-rs/serde/issues/1916">#1916</a>, thanks <a href="https://github.com/Mingun"><code>@​Mingun</code></a>)</p>
<pre lang="rust"><code>#[derive(Deserialize)]
#[serde(untagged, expecting = &quot;single version or array of versions&quot;)]
struct VersionSpec {
    One(Version),
    Many(Vec&lt;Version&gt;),
}
</code></pre>
</li>
<li>
<p>Improve <code>serde_test</code> handling of map entries and error message construction (<a href="https://github.com/serde-rs/serde/issues/1918">#1918</a>, thanks <a href="https://github.com/Mingun"><code>@​Mingun</code></a>)</p>
</li>
<li>
<p>Produce more accurate location information on test failures from <code>serde_test</code> crate (<a href="https://github.com/serde-rs/serde/issues/1920">#1920</a>, thanks <a href="https://github.com/Mingun"><code>@​Mingun</code></a>)</p>
</li>
<li>
<p>Improve diagnostic on failure to parse a <code>rename_all</code> attribute (<a href="https://github.com/serde-rs/serde/issues/1960">#1960</a>, <a href="https://github.com/serde-rs/serde/issues/1961">#1961</a>)</p>
</li>
<li>
<p>Eliminate unnecessary trait bounds on some value Deserializer impls (<a href="https://github.com/serde-rs/serde/issues/1963">#1963</a>)</p>
</li>
</ul>
<h2>v1.0.121</h2>
<ul>
<li>Support borrowed data during deserialization of a field identifier (<a href="https://github.com/serde-rs/serde/issues/1917">#1917</a>, thanks <a href="https://github.com/Mingun"><code>@​Mingun</code></a>)</li>
<li>Fix panic when deserializing <code>Duration</code> with nanoseconds that cause the seconds counter to overflow (<a href="https://github.com/serde-rs/serde/issues/1958">#1958</a>, thanks <a href="https://github.com/jonasbb"><code>@​jonasbb</code></a>)</li>
</ul>
<h2>v1.0.120</h2>
<ul>
<li>Fix deserialization of ignored fields containing 128-bit integer (<a href="https://github.com/serde-rs/serde/issues/1955">#1955</a>, thanks <a href="https://github.com/TheJokr"><code>@​TheJokr</code></a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="5a8dcac2ed"><code>5a8dcac</code></a> Release 1.0.124</li>
<li><a href="697b082e90"><code>697b082</code></a> Touch up PR 1997</li>
<li><a href="d91075c8d5"><code>d91075c</code></a> Merge pull request <a href="https://github.com/serde-rs/serde/issues/1997">#1997</a> from cyang1/systemtime-panics</li>
<li><a href="4118cec731"><code>4118cec</code></a> Prevent various panics when deserializing malformed SystemTime</li>
<li><a href="c261015325"><code>c261015</code></a> Ignore incorrect suggestion from manual_map lint</li>
<li><a href="6b5e5a83d0"><code>6b5e5a8</code></a> Ignore let_underscore_drop pedantic clippy lint</li>
<li><a href="bc6b2b1dee"><code>bc6b2b1</code></a> Make json5 description capitalization consistent with other links</li>
<li><a href="beb21cb640"><code>beb21cb</code></a> Ignore new missing_panics_doc pedantic clippy lint</li>
<li><a href="7cfebbcd72"><code>7cfebbc</code></a> Merge pull request <a href="https://github.com/serde-rs/serde/issues/1974">#1974</a> from Mingun/new-internally-tagged-tests</li>
<li><a href="b60c03ec3f"><code>b60c03e</code></a> Extend test_internally_tagged_newtype_variant_containing_unit_struct to cover...</li>
<li>Additional commits viewable in <a href="https://github.com/serde-rs/serde/compare/v1.0.119...v1.0.124">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=serde&package-manager=cargo&previous-version=1.0.119&new-version=1.0.124)](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-17 21:15:12 +00:00