Commit Graph

873 Commits (bc176bc4fbdee9ec4b5b904cecadb8dfa5284a9d)
 

Author SHA1 Message Date
Franck Royer 554ae6c00e
Remove Request Response types
These are actually not needed and forces us to cater for variants when
processing requests and responses.
3 years ago
Franck Royer 5a5a1c05f7
Set appropriate name to codec 3 years ago
Franck Royer a11e894b31
Prepend all libp2p protocols with "comit" 3 years ago
Franck Royer cfc5cb5206
Remove dead code and combine swap request & one shot codecs 3 years ago
Franck Royer fc2d8d3861
Rename alice::Message0 to Message0
There is now only one message0
3 years ago
Franck Royer 88bf080dc0
rename alice::Message0 to Message1 3 years ago
Franck Royer 18f326ddd1
Rename bob::Message1 to Message2
As per sequence diagram.
3 years ago
Franck Royer 0d1be52966
Rename alice::Message1 to Message3
As per sequence diagram.
3 years ago
Franck Royer e74efd38b5
Rename bob::Message2 to Message4
As per sequence diagram.
3 years ago
Franck Royer 081237bb6f
Remove unused behaviours 3 years ago
Franck Royer ecb54958ee
Preemptively Box few messages 3 years ago
Franck Royer 3fa4ffa82c
Implement new behaviour for execution setup 3 years ago
Franck Royer 9ae050abf8
Use correct variable name 3 years ago
Franck Royer c316ea5244
Upgrade toolchain
Needed to use libp2p-async-await
3 years ago
Franck Royer e82383bcf6
Avoid carrying rng 3 years ago
Philipp Hoenisch 25bf5df122
Merge pull request #172 from comit-network/dead-code
Remove dead code
3 years ago
bors[bot] f0bf294689
Merge #171
171: Use correct default data directory r=da-kami a=da-kami

Nasty copy-paster 😬

Co-authored-by: Daniel Karzel <daniel@comit.network>
3 years ago
Philipp Hoenisch 8743527df9
Remove dead code 3 years ago
Daniel Karzel b27363e386 Use correct default data directory 3 years ago
bors[bot] 5fe8f3108a
Merge #161
161: Introduce configuration file and initial setup through CLI r=da-kami a=da-kami

PRs chained on top of this one:

- [x] https://github.com/comit-network/xmr-btc-swap/pull/163 Configurable config with `--config` option on CLI (we will need this for swaps with ourselves...)
- [x] ~~https://github.com/comit-network/xmr-btc-swap/pull/165 Reset config with `--reset-config` option on CLI (this makes it easier for the user to clean up)~~
- [x] https://github.com/comit-network/xmr-btc-swap/pull/166 data-dir, in accordance to config-dir, should be pointed to the appropriate default directory using `directory-next`

Looks n' feel:

Initial startup:

```
2021-01-28T01:35:45.000205Z  INFO swap::trace: Initialized tracing with level: INFO
2021-01-28T01:35:45.001286Z  INFO swap: Database and Seed will be stored in directory: /Users/dakami/CoBloX/TEMP/swap-data-dir/alice
2021-01-28T01:35:45.003391Z  INFO swap::config::seed: Read in seed from file: /Users/dakami/CoBloX/TEMP/swap-data-dir/alice/seed.pem
2021-01-28T01:35:45.003603Z  INFO swap::config: Config file not found, running initial setup...

? Enter Bitcoind URL (including username and password if applicable) or hit return to use default (http://127.0.0.1:18332) › http://dakami:xkz4nyywpKf3BigwKIRdVijmWzaHCOmUisepQpDlsXnhpNd6uO@127.0.0.1:18332/
✔ Enter Bitcoind URL (including username and password if applicable) or hit return to use default · http://dakami:xkz4nyywpKf3BigwKIRdVijmWzaHCOmUisepQpDlsXnhpNd6uO@127.0.0.1:18332/
? Enter Bitcoind wallet name › alice
✔ Enter Bitcoind wallet name · alice
? Enter Monero Wallet RPC URL or hit enter to use default (http://127.0.0.1:38083/json_rpc) › 
✔ Enter Monero Wallet RPC URL or hit enter to use default · http://127.0.0.1:38083/json_rpc

2021-01-28T01:35:58.553401Z  INFO swap::config: Initial setup complete, config file created at /Users/dakami/Library/Application Support/xmr-btc-swap/config.toml 
2021-01-28T01:35:58.647761Z  INFO swap: Connection to Bitcoin wallet succeeded, balance: 0.00744521 BTC
2021-01-28T01:35:58.650060Z  INFO swap: Connection to Monero wallet succeeded, balance: 29.095359550000 XMR
2021-01-28T01:35:58.650258Z  INFO swap: Swap sending 0.030000000000 XMR and receiving 0.00060000 BTC started with ID e07b2cc1-3749-48fd-931a-6cbaf57b8124
2021-01-28T01:35:59.004306Z  INFO swap::protocol::alice::swap: Current state:started
```

After:
```
2021-01-28T01:36:57.881654Z  INFO swap::trace: Initialized tracing with level: INFO
2021-01-28T01:36:57.882691Z  INFO swap: Database and Seed will be stored in directory: /Users/dakami/CoBloX/TEMP/swap-data-dir/alice
2021-01-28T01:36:57.884171Z  INFO swap::config::seed: Read in seed from file: /Users/dakami/CoBloX/TEMP/swap-data-dir/alice/seed.pem
2021-01-28T01:36:57.884353Z  INFO swap::config: Using config file at default path: /Users/dakami/Library/Application Support/xmr-btc-swap/config.toml
2021-01-28T01:36:57.996153Z  INFO swap: Connection to Bitcoin wallet succeeded, balance: 0.00744521 BTC
2021-01-28T01:36:57.998648Z  INFO swap: Connection to Monero wallet succeeded, balance: 29.095359550000 XMR
2021-01-28T01:36:57.998928Z  INFO swap: Swap sending 0.030000000000 XMR and receiving 0.00060000 BTC started with ID 08dd6dc1-9460-4c0a-91ef-a05df309b6ed
2021-01-28T01:36:58.353738Z  INFO swap::protocol::alice::swap: Current state:started
```

Command:

```
run --package swap --bin swap -- 
  --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/alice 
  sell-xmr 
    --receive-btc 0.0006 
    --send-xmr 0.03
```

Co-authored-by: Daniel Karzel <daniel@comit.network>
Co-authored-by: Daniel Karzel <daniel.karzel@coblox.tech>
3 years ago
Daniel Karzel 110fc9bbd7
Merge pull request #168 from comit-network/rename-config
Rename config
3 years ago
Daniel Karzel 5cb4f3c99d rename configuration to config 3 years ago
Daniel Karzel 89b3775e05 Rename config to execution_params 3 years ago
Daniel Karzel 802dc61e7e Configuration for RPC urls and Bitcoin wallet name 3 years ago
bors[bot] 9eae0db9ac
Merge #156
156: Improve logging and network error handling r=D4nte a=D4nte



Co-authored-by: Franck Royer <franck@coblox.tech>
3 years ago
Franck Royer f1c07fbb6d
Remove incorrect todo 3 years ago
Franck Royer c25d5ff07e
Improve network logging 3 years ago
bors[bot] f84cd001b5
Merge #143
143: Upgrade to tokio 1.0 r=D4nte a=rishflab

When we were refactoring tests we realised we probably want the ability to abort a `tokio::JoinHandle` to kill the `EventLoop` to simulate a real world crash. tokio 1.0 is needed for this. It is probably about time to upgrade tokio anyway. 

In order to upgrade to tokio 1.0 the following dependencies were also upgraded in the swap crate and monero-harness-rs
* backoff
* libp2p
* request

UPDATE: This should be merged until the following dependencies are uprgraded to Tokio 1.0 or Tokio compat  is used

- [x] bitcoin-harness-rs https://github.com/coblox/bitcoin-harness-rs/pull/20

Co-authored-by: rishflab <rishflab@hotmail.com>
Co-authored-by: Franck Royer <franck@coblox.tech>
3 years ago
Franck Royer f9f17b0e23
Do not consider transfer proof sent until it's ack'd 3 years ago
Franck Royer b968c98805
remove unnecessary logs 3 years ago
Franck Royer cc76b201b5
Do not consider encrypted signature sent until it's ack'd 3 years ago
Franck Royer 5af3532cbf
Fix log messages 3 years ago
Franck Royer 108cc1e6cc
Use trait instead of passing struct 3 years ago
Franck Royer 80810e3605
Updates bors to include all docker tests 3 years ago
Franck Royer 09e0d3b877
Run docker tests in separate GitHub tasks 3 years ago
Franck Royer 704a8e7b01
Add swap id to tracing context 3 years ago
Franck Royer b8a9356d1b
Change expiries depending on the test goal 3 years ago
Franck Royer 5c2f83fd5d
Remove nightly chain 3 years ago
Franck Royer 49b8d19e41
test: Log state on failure 3 years ago
rishflab 0b69573129
Run tests on one thread, increase T1 3 years ago
rishflab 1597f5336b
Restart event loop in tests
Alice was attempting to create a new event loop using the same listen addr as the old one which was still running. This commit aborts the event loop before creating a new one.
3 years ago
rishflab 77fc5743a2
Upgrade tokio to 1.0
Upgrade bitcoin harness dependency to latest commit

Upgrade backoff to fix failing tests. The previous version of backoff had a broken version of the retry function. Upgraded to a newer comit which fixes this problem.

Upgrade hyper to 0.14 as the 0.13 was bringing in tokio 0.2.24

Upgraded bitcoin harness to version that uses tokio 1.0 and reqwest 0.11

Upgrade reqwest to 0.11. Reqwest 0.11 uses tokio 1.0

Upgrade libp2p to 0.34 in preparation for tokio 1.0 upgrade
3 years ago
bors[bot] 73f89fefda
Merge #159
159: Introduce "one shots" r=D4nte a=D4nte

Instead of Alice sending messages to Bob by replying on a `RequestResponse` channel, she just acks reception on the channel and open her own channel to send messages to Bob.

This means we do not need to carry the channel around anymore and instead carry Bob's peer id.

We take this opportunity to rename messages as per the sequence diagram.

At this stage we only touch message 4 & 5 as they are the one shots messages of the protocol.

Decoupling message 4 from message 3 (still current called 2) will allow the introduction of an await/async behaviour that handles message 1, 2, 3.

To introduce message 1, 2, 3 we will introduced the async/await behaviour using https://github.com/comit-network/rust-libp2p-async-await

First, we need to upgrade tokio and libp2p.

Please note that thanks to this change, Alice now uses Bob's peer id to send message meaning that recovery is improved (as before we could not save the channel to the db).

Co-authored-by: Franck Royer <franck@coblox.tech>
3 years ago
Franck Royer 2073e88683
Remove wrapping if `ReadOneError` when unnecessary 3 years ago
Franck Royer 2929a8f101
Use the correct protocol support 3 years ago
Franck Royer b62ef9c2d9
Harmonizing naming 3 years ago
Franck Royer 8fd2620b83
Improve names for messages 4 and 5 3 years ago
Franck Royer 33db688e3a
Bob peer id can be retrieved from the DB
This remove branches where Alice resumes from the DB but cannot contact
Bob.
3 years ago
Franck Royer a910bc2046
Box all messages in enum
The messages are very different, best to box them and save size on the
stack as an enum takes as much space on the stack than its bigger
variant.
3 years ago
Franck Royer d2a1937f51
Use `Message4` 3 years ago