Commit Graph

482 Commits

Author SHA1 Message Date
Franck Royer
6b4a02427a
Use global counter to name messages 2021-01-14 10:28:46 +11:00
Franck Royer
c55f3e3403
Remove Req-Res and update for single market maker use case
- Bob initiate swap with BTC Amount
- Alice acks with approx. xmr amount
- Rework terminology, make a difference between negotiations and
execution setup
- Remove request response channels in favor of one shots
- Give exact amount to Bob once assets are locked
2021-01-13 16:58:21 +11:00
Franck Royer
1e08a17bd9
Last message is also request response 2021-01-13 14:42:38 +11:00
Lucas Soriano del Pino
07270df12a Clarify diagram 2021-01-13 11:36:02 +11:00
Franck Royer
c53d54ddab
Add sequence diagram 2021-01-13 11:12:57 +11:00
bors[bot]
2790dec6dc
Merge #119
119: Remember the block-height before XMR lock for generated monero wallet r=da-kami a=da-kami

The first approach https://github.com/comit-network/xmr-btc-swap/pull/121 was using `get_transfer_by_txid` that allows extrancting the exact tx-lock 1st confirmation block height. 
But that introduced an additional error scenario, and I actually ran into that error scenario (`transaction not found`) once I ran it on `stagenet`. Might be that `get_transfer_by_txid` requires running the node in a specific way (like `txindex` on bitcoin).  
I am not sure at this stage and don't want to invest more time.

Long story short: 
I opted for just recording the height before watching for XMR locked. This means that we record a height right after sending the Bitcoin lock tx. (Because we start watching for XMR lock right after that.) 
Bob's new wallet unnecessarily scans an additional 7+ blocks (assuming inclusion in the next Bitcoin block and one confirmation for Monero lock) every time which is a matter of milliseconds. Not worth optimising this further at this stage. This solution is more resilient as well, because it does not add another error scenario.

Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-01-12 02:20:41 +00:00
Daniel Karzel
af45206fde Remember the block-height before XMR lock for generated monero wallet restore height
Speeds up wallet creation, because only the blocks after the recorded height will be scanned.
2021-01-12 13:18:49 +11:00
bors[bot]
ca6ba78862
Merge #123
123: Small fixes after testnet usage r=da-kami a=D4nte



Co-authored-by: Franck Royer <franck@coblox.tech>
2021-01-11 04:25:26 +00:00
bors[bot]
485220929e
Merge #127
127: Deterministic peer id for alice and bob r=da-kami a=da-kami

The first commit introduces a seed file similar to Nectar. Note, that the parameter --database was changed to --data-dir where the database is stored in the sub-folder database inside that data directory. This is breaking change, run commands will have to be adapted.
I opted for keeping the structure of generating an overall seed and then deriving the network seed from it (as in Nectar, where we use the seed for wallet creation as well). I feel this is cleaner than just using the seed for the network only.

The second commit applies the deterministic peer id to Bob as well. We don't have to do this because in the current setup Bob can have a new identity every time. I would still harmonize this to avoid confusion in the future. I don't see a reason why Bob's setup should be different from Alice here.

Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-01-11 03:07:11 +00:00
Daniel Karzel
bfc388d264 Enable tracing in monero-harness 2021-01-11 12:55:19 +11:00
Daniel Karzel
664958939d Create network::Seed from swap::Seed instead of abstracting over byte array 2021-01-11 12:03:29 +11:00
Daniel Karzel
f18d01dfaf Deterministic peer id from seed for bob 2021-01-11 12:03:29 +11:00
Daniel Karzel
0a21040e08 Deterministic peer id from seed for alice
This includes the introduction of the --data-dir parameter instead of the --database.
Both the seed file and the database are stored in the data-dir, the database in sub-folder `database`.
2021-01-11 12:00:48 +11:00
Franck Royer
6ffc66867c
Typo
Co-authored-by: Daniel Karzel <daniel.karzel@coblox.tech>
2021-01-11 11:39:21 +11:00
Franck Royer
047f990d05
Improve error reporting on signature verification 2021-01-11 11:39:18 +11:00
Franck Royer
ef906876a0
Increase timelocks on testnet
To allow time for stagenet Monero transaction to be mined.
2021-01-11 11:35:52 +11:00
Franck Royer
17356eaff9
Do not guard waiting for encrypted signature with arbitrary timeout
We already select waiting for this message with the cancellation expiry,
 we do not need add another guard that tries to guess how long it would
 for the Monero transaction to be finalised.
2021-01-11 11:35:52 +11:00
Franck Royer
95ecb02e7a
Small changes to make debugging easier and tests 2021-01-11 11:35:51 +11:00
Franck Royer
9d8f8b0a1f
P2p socket should be listening for external connections 2021-01-11 11:35:51 +11:00
rishflab
64ba8d6a87
Merge pull request #125 from comit-network/reorganise-modules-2
Merge xmr_btc crate
2021-01-10 10:07:24 +11:00
rishflab
1c644cb377 Rename message behaviours 2021-01-09 11:47:23 +11:00
rishflab
5d7d72c826 Remove unused import 2021-01-09 10:10:48 +11:00
rishflab
387a4da2f6 Make modules private 2021-01-08 12:34:36 +11:00
rishflab
a3e896684c Delete leftover xmr_btc crate 2021-01-08 12:34:36 +11:00
rishflab
dcea54dbf1 Move protocol parent states into appropriate module 2021-01-08 12:34:36 +11:00
rishflab
f64eede5d8 Move monero ser/deser to monero module 2021-01-08 12:34:36 +11:00
rishflab
e7c00d742e Re-export bitcoin and monero types 2021-01-08 12:34:36 +11:00
rishflab
c900d12593 Merge xmr_btc crate
Created network, storage and protocol modules. Organised
files into the modules where the belong.

xmr_btc crate moved into isolated modulein swap crate.

Remove the xmr_btc module and integrate into swap crate.

Consolidate message related code

Reorganise imports

Remove unused parent Message enum

Remove unused parent State enum

Remove unused dependencies from Cargo.toml
2021-01-08 12:34:33 +11:00
bors[bot]
a0d859147a
Merge #124
124: Cleanup unused config param that was accidentally introduced r=da-kami a=da-kami



Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-01-07 23:04:31 +00:00
Daniel Karzel
487b880371 Cleanup unused config param that was accidentally introduced 2021-01-07 12:23:29 +11:00
bors[bot]
903469f62a
Merge #118
118: Add minimum monero confirmations to config use it for Bob r=da-kami a=da-kami

After discussion with @bonomat about enforced `10` confirmations until a tx is spendable on Monero I gave it a try with only `1` confirmation on regtest happy-path-test and `5` for `stagenet` and did not encounter problems. Both swaps passed without problems so I am proposing to merge these changes. 

One additional change crept in: Changed the average blocktime for `stagenet` to `4` mins, because the blocktime fluctuates a lot. See: https://monero-stagenet.exan.tech/

Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-01-06 06:19:47 +00:00
Daniel Karzel
e031681369 Add minimum monero confirmations to config use it for Bob 2021-01-06 17:17:37 +11:00
bors[bot]
184f179044
Merge #115
115: Monero wallet network, Testnet r=da-kami a=da-kami

Add network for monero and switch application to run on Bitcoin `testnet3` and Monero `stagenet`.

Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-01-05 03:42:51 +00:00
Daniel Karzel
c6bc45e7a0 Wait for bitcoin tx finality before locking XMR 2021-01-05 14:31:10 +11:00
Daniel Karzel
30dd15774e Log Bitcoin and Monero transaction IDs on info instead of debug 2021-01-05 14:11:26 +11:00
Daniel Karzel
0977d36703 Set log level to info instead of trace 2021-01-05 14:00:07 +11:00
Daniel Karzel
72aa517af8 Work in review comments 2021-01-05 11:26:00 +11:00
Daniel Karzel
8a2128e93a Correct monero-wallet-rpc parameter name 2021-01-05 11:00:15 +11:00
Daniel Karzel
4d9559fc2e Monero network settings and testnet 2021-01-04 20:30:47 +11:00
Daniel Karzel
1f7e72b230 Log bitcoin harness and monero harness 2021-01-04 20:30:46 +11:00
Franck Royer
dd10e68db4
Merge pull request #113 from comit-network/clippy 2021-01-04 10:10:19 +11:00
bors[bot]
97eb24a26c
Merge #114
114: Type timelock and block height r=D4nte a=D4nte

To ensure no mistake is made (and none were!)

Co-authored-by: Franck Royer <franck@coblox.tech>
2021-01-03 21:41:55 +00:00
Franck Royer
bcbc54b569
Type timelock and block height
To ensure no mistake is made (and none were!)
2021-01-04 08:40:53 +11:00
Franck Royer
81cbc24c46
Use action to name trait 2020-12-23 15:40:56 +11:00
Franck Royer
e1e8533862
Embed state mod in database mod
The `Swap` struct is now database specific, no need to have a 20 lines
 module.
2020-12-23 15:30:23 +11:00
Franck Royer
59708c57e6
Move Alice and Bob db states in separate modules 2020-12-23 15:26:08 +11:00
Franck Royer
b410de01df
Move state.rs under database module
The types in state are only used for the database
2020-12-23 15:20:24 +11:00
Franck Royer
8c7964bfee
Rename storage.rs to database.rs to reduce terminology variants 2020-12-23 15:17:27 +11:00
Franck Royer
5ed18469e4
Move db state conversion with db type definition
Those conversion are specific to the database and should be defined with
in the database module.
2020-12-23 15:11:09 +11:00
Franck Royer
2a778f5644
Remove overzealous clippy overrides
We have overridden a number of clippy warnings such as
"large enum variant".

Considering that we have a number of issues
 with the stack size in CI, it is more prudent to follow clippy's advice
 and box larger items so that the enum does not take larger space.

Do note that an instance of the enum always takes as much space as its
largest variant.
2020-12-23 15:06:43 +11:00