Commit Graph

947 Commits

Author SHA1 Message Date
Daniel Karzel
efb51820b1
Poll block headers for latest block on each iteration
The Electrum block-header subscription did not provide us with block headers, because upon the connection being closed by a node the subscription would end.
Re-newing the the subscription upon re-connect is not easily achievable, that's why we opted for a polling mode for now, where we start a block header subscription on every update iteration, that is only used once (when the subscription is made).
2021-05-20 13:05:51 +10:00
Daniel Karzel
f2e43ea565
Let testnet setup reflect mainnet
Our test values should reflect what we test on mainnet more closely to avoid bugs that are only observed when using mainnet settings.
2021-05-20 13:05:51 +10:00
Daniel Karzel
4dd696ebe1
Fix monero-wallet-rpc startup for mainnet CLI
There is no `--mainnet` flag.
Since we cannot just pass an empty string to `.arg()` we use the `.args()` method to pass nothing for mainnet and the respective flags for stagenet and testnet.
2021-05-20 13:05:51 +10:00
Daniel Karzel
1aaffb09f9
Refactor ASB test-/mainnet default dir init 2021-05-20 13:05:51 +10:00
Daniel Karzel
cfa85e0bad
Simplify ASB initial setup signature 2021-05-20 13:05:51 +10:00
Daniel Karzel
7f8af7926d
ASB config may specify finality confirmations
By default the finality confirmations of the network's `env::Config` will be applied and no finality confirmations will be persisted on disk in the config file.
It is however possible to set finality confirmations in the config file for bitcoin and monero for power users at their own risk.
If set the defaults will be overwritten with the parameter from the config file upon startup.
2021-05-20 13:05:51 +10:00
Daniel Karzel
af60d3bb54
Network check upon spot price request 2021-05-20 13:03:29 +10:00
Daniel Karzel
02974811ad
Activate mainnet for the ASB
To run the ASB on testnet, one actively has to provide the `--testnet` flag.
Mainnet and testnet data and config are separated into sub-folders, i.e. `{data/config-dir}/asb/testnet` and `{data-dir}/asb/mainnet`.
The initial setup is also per network. If (default) config for the network cannot be found the initial setup is triggered.
Startup includes network check to ensure the bitcoin/monero network in config file is the same as the one in the `env::Config`.

Note: Wallet initialization is done with the network set in the `env::Config`, the network saved in the config file is just to indicate what network the config file is for.
2021-05-20 12:58:39 +10:00
Daniel Karzel
9ac5b635d7
Introduce own de-/serializable monero::Network 2021-05-20 12:58:30 +10:00
Daniel Karzel
69cf12620d
Activate mainnet for the CLI
This includes testing CLI commandline args
Clap's `default_value_with` actually did not work on `Subcommand`s because the parent's flags were not picked up.
This was fixed by changing parameters dependent on testnet/mainnet to options.
This problem should have been detected by tests, that's why the command line parameter tests were finally (re-)added.

Thanks to @rishflab for some pre-work for this.
2021-05-20 12:57:58 +10:00
dependabot[bot]
6c206c7067
Bump libp2p from 0.37.1 to 0.38.0
Bumps [libp2p](https://github.com/libp2p/rust-libp2p) from 0.37.1 to 0.38.0.
- [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.37.1...v0.38.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-18 06:33:38 +00:00
Thomas Eizinger
a3f436104f
Use tokio-tar from crates.io 2021-05-18 12:52:17 +10:00
Thomas Eizinger
75c5db53b2
Remove tokio-tar from workspace in favor of git dependency
Fixes #315.
Fixes #227.
2021-05-17 11:04:20 +10:00
Daniel Karzel
1cdc23de32
Explicitly specify monero-wallet-rpc deamon port
In order to allow people to plug into public nodes / be more flexible with their own setup we now enforce specifying the monero daemon port to be used by the `monero-wallet-rpc`.
2021-05-14 09:50:52 +10:00
Daniel Karzel
343badbb4b
Remove duplication and cleanup
In the past we had problems with flags/parameter changes several times, where on instance was changed, buy another one was missed. This should mitigate this problem.
This patch introduces structs for all duplicated parameters and uses flatten to only have one point for changes.

Additionally removes all mentions of `alice` from the commands / variables. This code is on an application level and should not be concerned with swap protocol roles.
2021-05-14 09:50:50 +10:00
Daniel Karzel
4e1f3f82bd
Remove param from names
Did not add any value, more readable with just bitcoin and monero.
2021-05-14 09:50:49 +10:00
Daniel Karzel
657ac1e2e4
Bitcoin parameters that can be reused
Get rid of parameter duplication.
2021-05-14 09:50:47 +10:00
Daniel Karzel
a489564857
Remove unused Electrum HTTP default URL 2021-05-14 09:50:44 +10:00
Philipp Hoenisch
493545d07f
Improve logging for Swap Cli. 2021-05-12 16:31:32 +10:00
Philipp Hoenisch
4f45a26a83
Move check for max_giveable into the function. 2021-05-12 16:31:32 +10:00
Philipp Hoenisch
7fc5a47619
Add checks to max_giveable amount.
We need to check two things:
- balance to be higher than dust amount (546).
- balance to be higher than min-relay fee.

Additionally, the tx_builder might fail if not enough funds are in the wallet to pay for the overall transaction fees.
2021-05-12 16:31:32 +10:00
Philipp Hoenisch
26e0383e17
Apply suggestions from code review
Co-authored-by: Daniel Karzel <daniel.karzel@coblox.tech>
2021-05-11 16:06:44 +10:00
Philipp Hoenisch
fc0cceb180
Toggle json logs using commandline flag. 2021-05-11 15:28:25 +10:00
Philipp Hoenisch
316f95c65b
Always log whole causality chain for errors. 2021-05-11 15:27:53 +10:00
Philipp Hoenisch
c011e95062
Improve logging by adding details as fields instead of into the msg. 2021-05-11 15:27:53 +10:00
Philipp Hoenisch
1706b36800
Log exchange rate at each state. 2021-05-11 15:27:49 +10:00
bors[bot]
227c383d76
Merge #481
481: Min buy amount r=da-kami a=da-kami



Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-05-11 04:08:59 +00:00
Daniel Karzel
652aae9590
Introduce a minimum buy amount
Introduces a minimum buy Bitcoin amount similar to the maximum amount already present.
For the CLI the minimum amount is enforced by waiting until at least the minimum is available as max-giveable amount.
2021-05-11 12:03:02 +10:00
Daniel Karzel
6d3cf0af91
Include too low balance into Alice's error 2021-05-11 12:03:02 +10:00
Daniel Karzel
1d62f4916c
Move max_buy and ask_spread into config
Max-buy and spread is not something that one would configure on every run.
More convenient to keep this in the config.

The max-buy Bitcoin value was adapted to `0.02` which is more reasonable for mainnet.
Activated feature `serde-float` to serialize the spread (Decimal) as float instead of string.

```
...

[maker]
max_buy_btc = 0.02
ask_spread = 0.02
```
2021-05-11 12:02:57 +10:00
Philipp Hoenisch
330269a1e9
Update assert_weight test to account for a range up to 8 bytes.
Weights fluctuate because of the length of the signatures. Valid ecdsa signatures can have 68, 69, 70, 71, or 72 bytes. Since most of our transactions have 2 signatures the weight can be up to 8 bytes less than the static weight (4 bytes per signature).
2021-05-11 10:50:24 +10:00
Daniel Karzel
538b25a6dd
Only create config-directory on init success
We should only create the file if the user finished the initial setup correctly.
2021-05-11 10:32:25 +10:00
bors[bot]
d96e20a5b0
Merge #479
479: Use rust_decimal in estimate_fee function. r=bonomat a=bonomat

Follow-up PR from #466 

Co-authored-by: Philipp Hoenisch <philipp@hoenisch.at>
2021-05-10 23:00:12 +00:00
Philipp Hoenisch
b5073e3052
Use rust_decimal in estimate_fee function. 2021-05-10 10:53:43 +10:00
Daniel Karzel
23d9637a4b
Work in review comments 2021-05-07 16:21:02 +10:00
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
Daniel Karzel
efcd39eeef
Add info messages to each subcommand
`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.
2021-05-07 16:12:50 +10:00
Daniel Karzel
0c616c7437
Move loading the state into the function
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.
2021-05-07 16:12:49 +10:00
Daniel Karzel
89b3d07eba
Network protocol tests for spot_price behaviour
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!
2021-05-07 15:00:29 +10:00
Daniel Karzel
03a0dc73cd
Alice's spot_price Behaviour reports back Error
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.
2021-05-07 15:00:29 +10:00
Daniel Karzel
5aac76598d
Decouple ASB/CLI Errors from Error sent over wire
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.
2021-05-07 15:00:29 +10:00
Daniel Karzel
52f648e1de
Alice's spot price logic into dedicated behaviour
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`).
2021-05-07 15:00:29 +10:00
Daniel Karzel
ea76ae5821
Return proper error to CLI for all expected scenarios
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.
2021-05-07 14:52:51 +10:00
Daniel Karzel
f6497778ed
Add resume-only mode for the ASB
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.
2021-05-07 14:52:51 +10:00
Philipp Hoenisch
0090e3b48e
Typo 2021-05-07 10:35:22 +10:00
Philipp Hoenisch
59a55dcbdd
Remove todo for cleanup note. 2021-05-07 10:24:41 +10:00
Philipp Hoenisch
e93eeb81a2
Added some proptests. 2021-05-07 10:24:41 +10:00
Philipp Hoenisch
040cce1eb6
Format all the files 2021-05-07 10:24:41 +10:00
Philipp Hoenisch
68ae47edf4
Log error message. 2021-05-07 10:24:41 +10:00
Philipp Hoenisch
aebdb063f1
Remove TODO 2021-05-07 10:24:41 +10:00
Philipp Hoenisch
9fb1a43f29
Rename variable. 2021-05-07 10:24:41 +10:00
Philipp Hoenisch
cfdbacfbb5
Add comment.
The weight of our transactions can fluctuate by +-2 wu because our transactions have 2 signatures
2021-05-07 10:24:41 +10:00
Philipp Hoenisch
e69a2c9111
Apply suggestions from code review
Co-authored-by: Daniel Karzel <daniel.karzel@coblox.tech>
2021-05-07 10:24:41 +10:00
Philipp Hoenisch
dc8dd5af28
Add relative and absolute max transaction fee. 2021-05-07 10:24:41 +10:00
Philipp Hoenisch
dc6ab0fa52
Ensure that constant weights do not go out of sync with code. 2021-05-07 10:24:41 +10:00
Philipp Hoenisch
7fe9087bc2
Pull trait-bounds up one level for easier testing. 2021-05-07 10:24:41 +10:00
Philipp Hoenisch
77f6f11a7f
Pass address/fees into State0 instead of passing in the wallet. 2021-05-07 10:24:41 +10:00
Philipp Hoenisch
14c5a4f025
Add upper bound for bitcoin fees of 100,000 satoshi.
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.
2021-05-07 10:24:41 +10:00
Philipp Hoenisch
46e0449b8e
Add config/argument to swap/asb to configure bitcoin tx fees. 2021-05-07 10:24:41 +10:00
Philipp Hoenisch
9e8b788aa9
Rename weight constants. 2021-05-07 10:24:41 +10:00
Philipp Hoenisch
ee90c228b4
Dynamically calculate fees using electrum's estimate_fee.
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.
2021-05-07 10:24:41 +10:00
Philipp Hoenisch
38540b4de5
Dynamically chose fee for TxCancel.
Bob chooses the fee for TxCancel because he is the one that cares.
2021-05-07 10:24:41 +10:00
Philipp Hoenisch
1012e39527
Dynamically chose fee for TxRefund and TxPunish.
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.
2021-05-07 10:24:41 +10:00
Philipp Hoenisch
d5c1b6693e
Dynamically chose fee for TxRedeem.
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.
2021-05-07 10:24:41 +10:00
Philipp Hoenisch
002e7b38c3
Define TX_FEE within test files only. 2021-05-07 10:24:41 +10:00
Philipp Hoenisch
1db7586632
Increase timeout sending/receiving protocol messages. 2021-05-04 15:38:55 +10:00
bors[bot]
e7785d2c83
Merge #434
434: Introduce monero-wallet crate r=thomaseizinger a=thomaseizinger

This PR:

1. ~Introduce a crate for the epee binary serialization as a serde format~: Released here: https://github.com/comit-network/monero-epee-bin-serde
2. Extends the MoneroRPC client with two binary calls
3. Introduces a `monero-wallet` crate that for now just provides functionality for choosing random key offsets. Together with the the ability to produce bulletproofs and ring signatures, this should be enough for signing Monero transactions locally.

(1) and (2) are a prerequisite for (3).

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-05-03 03:21:18 +00:00
bors[bot]
cf1c448b7c
Merge #460
460: Different default directories for CLI and ASB r=da-kami a=da-kami

Fixes #437 

Using the same default directory as data-/config-dir has caused unwanted side effects when running both applications on the same machine.
Use these directory names:
- ASB: `xmr-btc-swap-asb`
- CLI: `xmr-btc-swap-cli`

Since the functionality is now application specific the respective functions were moved into the appropriate module of the application.

Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-04-30 04:24:29 +00:00
bors[bot]
1244b30094
Merge #459
459: Use dprint for formatting Cargo.toml files r=thomaseizinger a=thomaseizinger

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.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-04-30 01:19:40 +00:00
Daniel Karzel
69f7565746
!fixup Different default directories for CLI and ASB
Using the same default directory as data-/config-dir has caused unwanted side effects when running both applications on the same machine.
Use these directory names:
- ASB: xmr-btc-swap/asb
- CLI: xmr-btc-swap/cli

Since the functionality is now application specific the respective functions were moved into the appropriate module of the application.
2021-04-30 11:03:13 +10:00
Thomas Eizinger
dd6bfd3bf4
Extend RPC client for monerod with binary requests 2021-04-30 10:28:45 +10:00
Daniel Karzel
b0ffeeab1d
Different default directories for CLI and ASB
Using the same default directory as data-/config-dir has caused unwanted side effects when running both applications on the same machine.
Use these directory names:
- ASB: xmr-btc-swap-asb
- CLI: xmr-btc-swap-cli

Since the functionality is now application specific the respective functions were moved into the appropriate module of the application.
2021-04-29 19:02:16 +10:00
Daniel Karzel
08fecb8fe3
Peer check for incoming transfer proofs
Bob validates that incoming transfer proof messages are coming from the peer-id of Alice.
Currently Bob will ignore any transfer proof message that is not coming from the counterparty peer-id associated to the current swap in execution.
Once we add support for trying to save received transfer proofs for swaps that are currently not in execution we can also adapy allowing this for different counterparty peer-ids. This requires access to the database in Bob's event loop.
2021-04-29 18:28:14 +10:00
Daniel Karzel
3c2dfa830a
Peer check for incoming encrypted signatures
Alice validates that incoming encsig messages are coming from the peer-id that is associated with the swap.
Encsig message from a peer-id different to the one associated with the swap are ignored.
2021-04-29 18:24:45 +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
Philipp Hoenisch
ea6e2f8f09
Simplify to_address_string by implying more context on the structure. 2021-04-28 16:21:31 +10:00
Philipp Hoenisch
c8e6db24f8
Derive Tor secret key from seed. 2021-04-27 16:39:32 +10:00
Philipp Hoenisch
3a5395d7a5
Optimize torut features.
OnionV2 addresses are being deprecated and will be fully phased out on 15.10.2021: https://blog.torproject.org/v2-deprecation-timeline
2021-04-27 16:39:32 +10:00
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
bors[bot]
e262345b4f
Merge #442
442: Minor cleanups towards implementing a Monero wallet for local signing r=thomaseizinger a=thomaseizinger

Extracted out of #434.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-04-27 02:16:27 +00: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
Daniel Karzel
0f11ab051e
Print peer ID on debog when starting CLI
In order to add more context to the debug logs we print Bob's peer ID.
This allows identifying peer related logs on the ASB.
2021-04-26 13:00:37 +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
e266fb07ef
Don't stutter 2021-04-26 12:45:39 +10:00
Thomas Eizinger
7adeaae12d
Be smart about how we import Config
By saying env::Config, we can save a line of code in the imports
and make it clearer, what kind of `Config` this is.
2021-04-26 12:45:39 +10:00
Thomas Eizinger
be5bf01ed4
Don't overqualify types that are already imported 2021-04-26 12:45:38 +10:00
Thomas Eizinger
325fcbdb8c
Introduce protocol::bob::behaviour to mimic structure from alice module 2021-04-26 12:45:37 +10:00
Thomas Eizinger
5b515d6fb2
Don't qualify with alice:: if we are within a module of Alice 2021-04-26 12:45:37 +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
Thomas Eizinger
6d06db3259
Use macro-based JSON-RPC client 2021-04-26 12:45:35 +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
39eea61538
Upgrade to bdk 0.6 2021-04-19 10:14:14 +10:00
COMIT Botty McBotface
43dc74cd9d Prepare release 0.5.0 2021-04-17 07:23:09 +00:00
Daniel Karzel
c1e993deb2
Json codec for quote protocol
A `RequestResponseCodec` for pull-based protocols where the response is encoded using JSON.
This was added to more properly express the behavior of the quote protocol, where the dialer
doesn't send any message and expects the listener to directly send the response.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-04-16 16:00:45 +10:00
Daniel Karzel
f70e2aa8d6
Listen on tcp and websocket transports
- Listen on both tcp and websockets as default
- Listening addresses in config as array
- Configure fallback transport using `or_transport` - if listening on a given address fails on WS, we fall back to TCP.
2021-04-16 16:00:38 +10:00
Thomas Eizinger
b417950f99
Improve error reporting of failed protocols
Instead of forwarding every error, we deliberately ignore certain
variants that are not worth being printed to the log. In particular,
this concerns "UnsupportedProtocols" and "ResponseOmission".

To make this less verbose we introduce a macro for mapping a
`RequestResponseEvent` to `{alice,bob}::OutEvent`. We use a macro
because those `OutEvent`s are different types and the only other
way of abstracting over them would be to introduce traits that we
implement on both of them.

To make the macro easier to use, we move all the `From` implementations
that convert between the protocol and the more high-level behaviour
into the actual protocol module.
2021-04-14 10:34:06 +10:00