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
Franck Royer
cdf2800fa5
Align clippy lints
...
Lints in `main.rs` are not used if there is a `lib.rs` file.
2020-12-23 14:33:29 +11:00
Franck Royer
ece689f5ca
There is only one binary, we should use main.rs
naming convention
2020-12-23 14:22:04 +11:00
Franck Royer
4150e75488
Replace Try_From
state conversion with From
for Bob
2020-12-23 14:12:29 +11:00
Franck Royer
5d1b10cc58
Align Bob DB states with swap states
2020-12-23 14:12:29 +11:00
Franck Royer
e541f7b83d
Replace TryFrom
with From
for Alice states
2020-12-23 14:12:29 +11:00
Franck Royer
69e1c2bb27
Align Alice DB states with swap states
2020-12-23 14:12:29 +11:00
Franck Royer
a31db63e54
Improve state names and display
2020-12-23 14:12:29 +11:00
Franck Royer
f0736d0906
Remove Refund timelock and T0/T1/T2
...
There are no refund timelock, only a cancellation timelock and punish
timelock.
Refund can be done as soon as the cancellation transaction is published.
2020-12-23 14:12:26 +11:00
Franck Royer
405e377f79
Rename EncSign
to EncSig
...
`EncSig` means "encrypted signature", the item,
not be confused with "signing", the action
2020-12-23 13:41:55 +11:00
bors[bot]
9c83ca52ad
Merge #107
...
107: Ensure that Bob can cancel correctly if T1 expired and Alice did not … r=da-kami a=da-kami
Bob has to check for the possibility to cancel in every state after he locked the BTC.
Otherwise Bob will try to perform actions that don't have any point and it might be impossible to use the `resume` command because it will always fail in trying to go on with Alice even though that might not be possible.
Co-authored-by: Daniel Karzel <daniel@comit.network>
2020-12-23 01:16:42 +00:00
Franck Royer
297b15e3ce
Remove async block when it is not needed
2020-12-23 09:17:56 +11:00
Franck Royer
e079b84500
Ensure we wait for other party to complete
...
Before we check the balances.
2020-12-23 09:17:41 +11:00
Franck Royer
1fa812b727
Separate Buy/Sell for resume command
...
To avoid confusing the user on whether person should enter a listen addr
or a connect peer id and address
2020-12-23 09:17:39 +11:00
Daniel Karzel
a692cf9299
Remove all short-codes because they don't add value at the moment
2020-12-22 18:10:13 +11:00
Daniel Karzel
c9d492d155
Only wait for xmr-lock until t1 expired
2020-12-22 17:08:17 +11:00
Daniel Karzel
83ce6f2c85
Ensure that Bob can cancel correctly if T1 expired and Alice did not move
...
Bob has to check for the possibility to cancel in every state after he locked the BTC.
Otherwise Bob will try to perform actions that don't have any point.
2020-12-22 16:27:25 +11:00
Daniel Karzel
8296490764
Merge pull request #111 from comit-network/trace-xmr-btc
...
Fix tracing subscribe filter for xmr-btc`
2020-12-22 16:17:27 +11:00
Daniel Karzel
5f8b7f2624
Fix tracing subscribe filter for xmr-btc`
2020-12-22 14:11:55 +11:00
Franck Royer
40a27a2438
Remove dead code
2020-12-22 13:50:36 +11:00
Franck Royer
df237f82cf
Fix clippy warning
2020-12-22 13:50:28 +11:00
Franck Royer
49b84d84b9
Add address at the start
...
Do not carry peer id around as we currently only expect one peer.
2020-12-22 13:47:05 +11:00
Franck Royer
1e4b115556
Separate Bob restart tests
...
To stabilize CI
2020-12-21 12:19:04 +11:00
Franck Royer
e366d3a73b
Join all futures to avoid hanging tests
2020-12-21 12:17:40 +11:00
Franck Royer
2abf65f3b6
Remove sleep that seems unnecessary
2020-12-21 10:25:36 +11:00
Franck Royer
4a4e23038b
Add logging to investigate add address race condition
2020-12-21 10:25:19 +11:00
Franck Royer
1a4bd0e2b4
Bob refunds swap after restart that requires communication
...
As Bob is dialing Alice, we now ensure that we are connected to Alice
at each step that needs communication.
If we are not connected, we proceed with dialing.
In an attempt to improve libp2p usage, we also add known address of
Alice first and only use peer_id to dial.
This ensures that we use the expected peer id.
2020-12-21 08:31:21 +11:00
Franck Royer
d9ea7ab605
Only carry the tx_lock_id instead of the full state
2020-12-21 08:19:39 +11:00
Franck Royer
edfab58246
Scope alice db
...
To better match the restart scenario
2020-12-21 08:19:39 +11:00
Franck Royer
dc96b3d1e9
Stop running first event loop after Alice restarts
2020-12-21 08:19:39 +11:00
Franck Royer
638143a10d
Replace hard coded port by dynamic available one
...
Fixes #84 .
2020-12-21 08:19:31 +11:00
Franck Royer
2212758d17
Rename refund test as it is alice specific
2020-12-21 08:13:42 +11:00
bors[bot]
3db71997d3
Merge #99
...
99: Cleanup resume_from_database functions only used in tests r=da-kami a=da-kami
Follow up of https://github.com/comit-network/xmr-btc-swap/pull/88
Co-authored-by: Daniel Karzel <daniel@comit.network>
2020-12-18 03:01:18 +00:00
bors[bot]
4f631c0c9b
Merge #98
...
98: Remove tor module r=da-kami a=da-kami
This removes the currently unused `tor module`.
Different `tokio` versions have been causing issues with the `tor` module in the past (i.e. `Cargo.lock` broken problem...). It started causing issues again when adding a dependency to `jsonrpc_client` working on https://github.com/comit-network/xmr-btc-swap/pull/97
We don't support `tor` at the moment and are no planning to add this feature initially as it is not super important to users.
The functionality can easily added again at a later point.
Co-authored-by: Daniel Karzel <daniel@comit.network>
2020-12-18 02:10:25 +00:00
bors[bot]
88c29dbce5
Merge #94
...
94: T1Expired state for Bob and check expiries in states after both locked r=da-kami a=da-kami
Co-authored-by: Daniel Karzel <daniel@comit.network>
2020-12-18 01:20:30 +00:00
Daniel Karzel
4046305474
Merge pull request #88 from comit-network/resume-swap-cli
...
Resume command and global database cl-parameter
2020-12-18 11:42:54 +11:00
Daniel Karzel
20893c1bb1
Cleanup Display for database states
2020-12-18 11:39:21 +11:00
Daniel Karzel
e6493784bf
Change pin_mut!
to select!
2020-12-18 11:37:02 +11:00
Daniel Karzel
773eebc723
Cleanup resume_from_database functions only used in tests
2020-12-18 10:50:32 +11:00
Daniel Karzel
e9681b6e2b
Work in review comments
2020-12-17 19:10:24 +11:00
Daniel Karzel
43d05935e7
Remove tor module
2020-12-17 18:50:15 +11:00
Daniel Karzel
093cbaa4b4
Introduce T1Expired state for Bob properly and check expiries in states after both locked
2020-12-17 15:17:15 +11:00
Daniel Karzel
6d03d1bbff
Resume command and global database cl-parameter
2020-12-15 21:40:52 +11:00
Franck Royer
71cf501c29
Delete bob::negotiate
...
This module was intended to contain helper functions for each step.
However, those are not needed except for the negotiate step.
A dedicated module is not needed for one function.
2020-12-15 16:53:50 +11:00
Franck Royer
19066200d1
Add a TODO to use existing helper functions
...
Helper functions already exist on the xmr-btc crate states, use them
like it is done in the bob module.
2020-12-15 16:51:23 +11:00
Franck Royer
84bec0631b
Rename alice::negotiate to steps
...
This module includes helper function for each state.
2020-12-15 16:49:38 +11:00
Franck Royer
53d13330c2
Remove dupe code
2020-12-15 16:45:06 +11:00
rishflab
9d266fc648
Add balance assertions to restart tests
2020-12-15 13:11:16 +11:00
Franck Royer
5ba830f3bf
Replace swap recover
terminology with resume
2020-12-15 11:52:00 +11:00
Franck Royer
8cc470a80e
Use -ed
terminology for cancel state
2020-12-15 11:47:05 +11:00
Daniel Karzel
b83ab71669
Split up tests into separate files to overcome CI failure
2020-12-15 11:43:28 +11:00
Daniel Karzel
7cae6a9e4d
Add Bob restart test
2020-12-15 11:43:28 +11:00
Daniel Karzel
4ec2da29a0
Modularize Bob's test setup (separate init for state, event_loop)
2020-12-15 11:43:28 +11:00
Daniel Karzel
9a930af33f
Remove duplicated restart+refund test, move tests into separate files
2020-12-15 11:43:28 +11:00
Daniel Karzel
91d4d5da25
Cleanup swap execution to not return EventLoopHandle, refactor both_refund test
2020-12-15 11:43:28 +11:00
Daniel Karzel
3692046758
Bob's recover function
2020-12-15 11:43:27 +11:00
Daniel Karzel
bf39c34ada
Alice restart and refund test if restarted before encsig learner
2020-12-15 11:43:27 +11:00
Daniel Karzel
8c929564ef
Refactor container initialization
2020-12-15 11:43:27 +11:00
rishflab
143d8bc07d
Move message0 response handler out of NB
2020-12-15 11:43:24 +11:00
Daniel Karzel
4143394767
Add recovery function for Alice
2020-12-15 11:40:40 +11:00
rishflab
4b00141c29
Fix happy path test
2020-12-15 11:40:36 +11:00
Franck Royer
7092af457a
Introduced DB for Alice & Bob
2020-12-15 11:38:36 +11:00
Franck Royer
4ce8695dfc
Align with origin/database
2020-12-15 11:29:38 +11:00
Franck Royer
1a5b9f9fa9
Update tests after rebase
2020-12-15 10:19:45 +11:00
Franck Royer
c4cdd098fd
Use from instead of try_from for Alice state conversion
2020-12-15 10:19:03 +11:00
Franck Royer
caf903acda
wip: Add test for when bob restarts
2020-12-15 10:18:48 +11:00
Franck Royer
905fc6cf35
Save Bob state during swap
2020-12-15 10:18:46 +11:00
Franck Royer
7e0a1ffe84
Remove generator for bob
2020-12-15 10:14:43 +11:00
Franck Royer
c6af5eb9ac
Introduce test where alice restarts before all communications are done
2020-12-15 10:10:43 +11:00
Franck Royer
3580b7ed2c
Add test where Alice restart after encsign is learned
2020-12-15 10:10:42 +11:00
Franck Royer
a22efaa7bc
Remove unneeded peer id argument
2020-12-15 10:10:42 +11:00
Franck Royer
9323f22009
Reorder calls
2020-12-15 10:10:42 +11:00
Franck Royer
a24d1a49b9
Remove unneeded as_ref_calls
2020-12-15 10:10:42 +11:00
Franck Royer
1c7cc7ee46
Scope futures' instanciation
2020-12-15 10:10:42 +11:00
Franck Royer
6226e5789f
Introduce test where alice restart mid-swap
2020-12-15 10:10:42 +11:00
Franck Royer
71a0832ef4
Add zero const to monero::Amount
2020-12-15 10:10:42 +11:00
Franck Royer
64b021daf4
Save Alice states in db
2020-12-15 10:10:40 +11:00
Franck Royer
238f6a989d
Extract spend key as soon as possible
2020-12-15 09:18:23 +11:00
Franck Royer
c095693a5f
Refund swap if resumed from a step that requires further communication
2020-12-15 09:17:12 +11:00
Franck Royer
11cea9ba69
Remove passing alice peer id
...
The usage of the peer id is incorrect as we do not even check it when
dialing. For now, we can ignore it.
We can then re-introduce it and use it properly at a later stage.
2020-12-15 09:15:38 +11:00
rishflab
d8d6477ee9
Remove and fix comments
2020-12-14 11:56:14 +11:00
rishflab
082f4eb005
Use unused port in refund test
2020-12-11 17:36:28 +11:00
rishflab
7af4b6980a
Test Alice refunds after Bob refund
...
Reworked Alice XmrLocked state transition handler to handle the
scenario when Alice received the encsig but Bob refunds.
Previously Alice was trying to redeem after receiving the encsig
without checking if t1 had elapsed.
2020-12-11 17:05:34 +11:00
rishflab
773390886b
Test that Bob refunds if Alice fails to act
2020-12-11 16:59:29 +11:00
rishflab
78c6a1a78f
Add Bob refund execution
2020-12-11 16:59:29 +11:00
rishflab
f806ad7231
Assert balances after punish
2020-12-11 16:59:29 +11:00
bors[bot]
9fecf7008e
Merge #61
...
61: Prepare CLI for mainnet swap r=da-kami a=da-kami
Co-authored-by: Daniel Karzel <daniel@comit.network>
2020-12-11 03:48:01 +00:00
Daniel Karzel
03b8e5f52e
Upgrade CLI for mainnet test
2020-12-11 14:46:29 +11:00
Daniel Karzel
aad7a22f81
Utility function for initializing tracing for tests
2020-12-11 13:35:47 +11:00
Franck Royer
c0478d7191
Move expiries to config
...
So they can be different for mainnet and regtest
2020-12-10 14:43:17 +11:00
Franck Royer
ef6e8fc723
Clean-up unused code
2020-12-10 14:28:54 +11:00
Franck Royer
e71bf7d8e9
Add comment regarding processing in network behaviour
2020-12-10 14:03:45 +11:00
Franck Royer
2c9fb7b1da
Rename var to match type name
2020-12-10 14:03:45 +11:00
Franck Royer
91d28682ed
Remove comments
2020-12-10 14:00:48 +11:00
Franck Royer
53aae5cf5f
Use anyhow macro as intended
2020-12-10 14:00:48 +11:00
Franck Royer
51cc44484b
Remove unneeded pub qualifiers
2020-12-10 14:00:47 +11:00