Commit Graph

724 Commits

Author SHA1 Message Date
Franck Royer
d2a1937f51
Use Message4 2021-01-22 17:19:20 +11:00
Franck Royer
124d6f1ebb
Introduced Message 4 sent by Alice to replace message 2 response 2021-01-22 17:00:40 +11:00
Franck Royer
edb93624f3
Introduce one shot code
To allow alice to be the requester for message 4.
2021-01-22 16:57:34 +11:00
Franck Royer
9a5e35c1bd
Rename bob::Message2 to Message5
As per the proposed changed in the sequence diagram.
The aim is to have a unique terminology per message instead of having
the same name for 2 consequent messages that share the same behaviour.

Note that the aim is to remove the shared `RequestResponse` behaviours.
2021-01-22 16:57:32 +11:00
bors[bot]
91fe18a796
Merge #154
154: Clean up `lib.rs` r=D4nte a=D4nte

Do not remove it just yet as there are still issues with the CI but proceed with some clean up.

Merging this now to avoid further merge conflicts.

Co-authored-by: Franck Royer <franck@coblox.tech>
2021-01-21 22:01:22 +00:00
Franck Royer
10eeecfe54
Remove dependency of main.rs on lib.rs 2021-01-22 09:00:49 +11:00
Franck Royer
f2a25ee49b
Move definitions out of lib.rs 2021-01-22 09:00:46 +11:00
Franck Royer
b88a777bae
Remove dead code 2021-01-22 08:59:09 +11:00
bors[bot]
e2170e60a7
Merge #155
155: Bob saves lock proof after received so he can resume swap r=da-kami a=da-kami

Introducing a new state was too much so I added the additional required information to the enum state rather than adding another struct. 

As discussed earlier we should cleanup the state machine (enum states vs data structs) at some point :)

Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-01-21 12:48:41 +00:00
Daniel Karzel
33a9057b1f Move run_until is_target_state comparison functions into testutils 2021-01-21 23:39:55 +11:00
Daniel Karzel
3593f5323a Bob saves lock proof after received so he can resume swap 2021-01-21 23:35:54 +11:00
bors[bot]
c5cfc2ce20
Merge #153
153: Remove newlines from import statements to avoid problems r=da-kami a=da-kami

Rust fmt automatically groups the imports (from top to bottom) as `pub use` `use crate` and `use`.
There is no need to introduce sections which cause annoyance when auto importing using the IDE.

Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-01-21 08:11:41 +00:00
Daniel Karzel
433704e48c Top to bottom pub mod then mod then pub use then use (incl. use crate and use self) 2021-01-21 19:10:51 +11:00
Daniel Karzel
44c4b5dcea Remove newlines from import statements to avoid problems
Rust fmt automatically groups the imports (from top to bottom) as `pub use` `use crate` and `use`.
There is no need to introduce sections which cause annoyance when auto importing using the IDE.
2021-01-21 19:10:51 +11:00
bors[bot]
4e858197c9
Merge #149
149: Fix Alice redeem scenario r=da-kami a=da-kami

Follow up of #144, partial fix of https://github.com/comit-network/xmr-btc-swap/issues/137

 Fix Alice redeem scenario

- Properly check the timelocks before trying to redeem
- Distinguish different failure scenarios and reactions to it.
    - if we fail to construct the redeem transaction: wait for cancel.
    - if we fail to publish the redeem transaction: wait for cancel but let the user know that restarting the application will result in retrying to publish the tx.
    - if we succeed to publish the tx but then fail when waiting for finality, print error to the user (secreat already leaked, the user has to check manually if the tx was included)



Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-01-21 06:27:38 +00:00
bors[bot]
fbfc17c489
Merge #142
142: Rename Swap amounts to Swap req/res r=D4nte a=D4nte

As per #140

Question: Do we prefer `Negotiation Request/Response` to `Swap Request/Response`?

Co-authored-by: Franck Royer <franck@coblox.tech>
2021-01-21 02:18:26 +00:00
Franck Royer
8c76abcd37
Remove TODO
This can be tackle when migrating to SQLite
2021-01-21 12:27:32 +11:00
Franck Royer
898b8bf8b0
Remove dead code 2021-01-21 12:27:32 +11:00
Franck Royer
ae8134f04e
Replace amounts messages with swap res/req 2021-01-21 12:27:30 +11:00
Daniel Karzel
6a75c840b5 Fix Alice redeem scenario
- Properly check the timelocks before trying to redeem
- Distinguish different failure scenarios and reactions to it.
    - if we fail to construct the redeem transaction: wait for cancel.
    - if we fail to publish the redeem transaction: wait for cancel but let the user know that restarting the application will result in retrying to publish the tx.
    - if we succeed to publish the tx but then fail when waiting for finality, print error to the user (secreat already leaked, the user has to check manually if the tx was included)
2021-01-21 12:13:02 +11:00
Daniel Karzel
9fa900dce8
Merge pull request #148 from comit-network/properly-wait-for-tx-finality-for-assertion-on-bitcoin-balance
Wait for Bob's refund finality
2021-01-21 12:06:12 +11:00
Daniel Karzel
8a7d746e96 Wait for Bob's refund finality
For Alice we ensure to wait for redeem/punish finality, so it should be the same for Bob.
2021-01-21 10:36:08 +11:00
bors[bot]
d6bf66c1f4
Merge #150
150: Few improvements r=D4nte a=D4nte



Co-authored-by: Franck Royer <franck@coblox.tech>
2021-01-20 11:30:35 +00:00
Franck Royer
94045b9a69
Use builder in tests 2021-01-20 21:42:35 +11:00
Franck Royer
c44b867d01
Delay the wrapping in Arc 2021-01-20 14:56:10 +11:00
Franck Royer
83b72c0a45
Make make_init_state and init_loop associated to alice::SwapFactory 2021-01-20 14:56:10 +11:00
Franck Royer
c11042ff0d
Use builder terminology instead of factory
This is not really a factory as a factory design pattern is about
producing several instances.

In the current usage, we are only interested in one swap instance. Once
the swap instance is created, the factory becomes useless. Hence, it is
more of a builder pattern.
2021-01-20 14:56:06 +11:00
Franck Royer
9148af2dbe
bob::SwapFactory should be consumed once a swap is returned 2021-01-20 14:51:37 +11:00
Franck Royer
652bfa14a9
Remove unnecessary pub qualifiers 2021-01-20 14:51:36 +11:00
Franck Royer
b21dc03ed0
alice::SwapFactory should be consumed once a swap is returned 2021-01-20 14:51:36 +11:00
Franck Royer
9b32409b8d
Remove unnecessary allow(clippy) 2021-01-20 14:51:35 +11:00
Franck Royer
9e3ef7ea24
Remove StartingBalances from release code 2021-01-20 14:51:35 +11:00
Franck Royer
181999e04f
Remove unnecessary alice qualifiers in alice::SwapFactor 2021-01-20 14:51:35 +11:00
Franck Royer
3bc76a91c6
Make init_state associated to bob::SwapFactory 2021-01-20 14:51:34 +11:00
Franck Royer
f0e6e45d56
Remove unecessary bob qualifier 2021-01-20 14:51:34 +11:00
Franck Royer
dbc633ea06
Remove unecessary connect qualifier 2021-01-20 14:51:34 +11:00
Franck Royer
e26629b593
Remove unecessary fields from bob::SwapFactory 2021-01-20 14:51:34 +11:00
Franck Royer
3c68026cfe
Move init event loop in bob::SwapFactory 2021-01-20 14:51:33 +11:00
Franck Royer
96b1b18037
Keep terminology consistent
Also avoid redundant qualifiers.
2021-01-20 14:51:33 +11:00
bors[bot]
05669c749c
Merge #147
147: Refactor prod code after test refactoring r=da-kami a=da-kami

Follow up of https://github.com/comit-network/xmr-btc-swap/pull/144

Took a bit more than expected, but this is really neat now!
The commits should be well-contained for reviewing, but 00835baa15 is quite big. 

I changed the abstraction on the way - out methods are finally named `run` and `run_until` which both take a swap - which makes way more sense I think :)

Also had to change the abstraction layers in `testutils` and introduced `Test` which specifies the swap amounts (that would usually come from the commandline and should not live in the factory as they are irrelevant for resumed swaps).

Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-01-20 02:41:27 +00:00
Daniel Karzel
28429fa9fe Revert log statement 2021-01-20 13:30:35 +11:00
Daniel Karzel
37f619dbfc Move StartingBalances into protocol module 2021-01-20 13:29:46 +11:00
Daniel Karzel
41e335fc2d Error messages instead of unreachable
Currently this code is actually not reachable, but that is semantically applied by the program's flow (the resume command includes the swap direction).
It is still preferred to have an error message rather than an unreachable statement.
2021-01-20 13:14:25 +11:00
Daniel Karzel
2dceab28a4 Derive Default 2021-01-20 10:44:24 +11:00
Daniel Karzel
acfd43ee79 Rename Test to TestContext and argument to ctx 2021-01-20 10:40:40 +11:00
Daniel Karzel
e91987e23f Fix rand import 2021-01-20 10:38:28 +11:00
Daniel Karzel
170e90ffed Rename do_run_until to _run_until_internal 2021-01-20 10:37:16 +11:00
Daniel Karzel
82974412b2 Remove roles from SwapFactory name as implied by module and cleanup 2021-01-19 09:43:50 +11:00
Daniel Karzel
75f89f3b25 Use Bob swap factory in production 2021-01-19 09:16:05 +11:00
Daniel Karzel
e56c48ee23 Remove unused type 2021-01-19 09:16:05 +11:00