Commit Graph

493 Commits

Author SHA1 Message Date
Franck Royer
b4e2e11dde
Remove unnecessary fields 2021-02-15 16:20:34 +11:00
Franck Royer
d6effb7d39
Remove unnecessary pub qualifiers 2021-02-15 16:20:34 +11:00
Franck Royer
b8a84aa34b
Avoid possible mix up between timelocks
Introduce new type to ensure no mix up happens when ordering the fields
in function calls.
2021-02-15 16:20:31 +11:00
Franck Royer
9a321a4f09
Move transaction types in dedicated modules
To allow the related timelock to be defined with the
transaction that uses it. This will allow the access to the
timelock's struct inner field with defining `From` impl.
2021-02-15 16:10:40 +11:00
Franck Royer
65e0e5b731
Use Remote handle to access ongoing swaps on Alice 2021-02-15 15:00:47 +11:00
bors[bot]
a0753e24dc
Merge #189
189: The first message is more of a quote request than a swap request r=D4nte a=D4nte



Co-authored-by: Franck Royer <franck@coblox.tech>
2021-02-15 00:24:39 +00:00
Franck Royer
5d78556665
Give a more specific name to the CLI binary: swap-cli
The current binary name is very generic `cli`. `swap-cli` better
describes what this binary does.
2021-02-15 11:01:50 +11:00
Franck Royer
8fada42074
Make config argument global
The `config` argument apply to all commands. It is now optional and
needs to be passed before a command.
E.g. `cli --config ./config.toml history`
2021-02-15 11:01:50 +11:00
Franck Royer
83dcf4ba3c
Add nectar binary 2021-02-15 11:01:47 +11:00
Daniel Karzel
c166232daf Remove unnecessary mention of Tor in comment 2021-02-15 10:12:08 +11:00
Franck Royer
9ded728879
The first message is actually a quote or rate request 2021-02-12 17:05:06 +11:00
Franck Royer
ee43125bdd
Add nectar binary 2021-02-11 15:24:38 +11:00
Franck Royer
fac5b59d17
Remove unnecessary specification of the types 2021-02-11 10:34:44 +11:00
Franck Royer
7805a6d684
Move cli specific modules under cli folder
nectar will also have its own folder with a separate config.
2021-02-11 10:34:44 +11:00
Franck Royer
901c9e89c9
No evident added value of having separate Seed structs
Hence, reducing complexity of the codebase. Note that the seed will be
used by both nectar and the cli whereas the config mod will be different
so this changes helps with the next step of having a dedicated config
module for each binary.
2021-02-11 09:57:17 +11:00
Franck Royer
7d392c3086
This files contains Command and Arguments structs 2021-02-11 09:47:42 +11:00
Franck Royer
45dccb8be2
Rename the config struct Config 2021-02-11 09:38:29 +11:00
Franck Royer
eb39add5ff
Fix typo 2021-02-10 16:42:55 +11:00
Franck Royer
6e6dc320b4
Alice event loop now handles the creation of new swaps 2021-02-10 16:42:55 +11:00
Franck Royer
15eb9a2fe4
Remove punish test
The punish test needs re-work due to the fact that Alice runs continuously

Currently focusing on the CLI (Bob), so we can re-introduce this test
once we want to ensure that nectar (Alice) punishes.
2021-02-10 16:42:55 +11:00
Franck Royer
3bc8b58b6a
Remove Bob restart tests after communication
The test do not work without acks as we stop the event loop as soon
as a message is considered as "sent" when actually the event loop
and swarm may not have yet sent the message.

The ack allow to avoid this issue as the message was considered "sent"
only once the other party sent a response. However, the ack brings
other issue so a review needs to be done to select the appropriate
solution.
2021-02-10 16:42:55 +11:00
Franck Royer
fd9f633a77
Remove Alice restarts tests
Current focus is on CLI UX. Fair amount of change needs to happen to
cater for Alice (nectar) restart scenarios.
2021-02-10 16:42:55 +11:00
Franck Royer
bfc19d5628
Remove acknowledgements processing
We are aware of issues of timeouts when waiting for acknowledgements.
Also, to properly supports acks in a multiple swap context, we need to
revert to doing event processing on the behaviour so that we can link
leverage the `RequestResponse` libp2p behaviour and link the messages
requests ids to swap ids when receiving an ack or response.

Acks are usefully for specific scenarios where we queue a message on the
behaviour to be sent, save as sent in the DB but crash before the
message is actually sent. With acks we are able to resume the swap,
without ack, the swap will abort (refund).
2021-02-10 16:42:55 +11:00
Franck Royer
cc8b855117
Make it possible to clone a handle
This will be used for new swaps.
2021-02-10 16:42:54 +11:00
Franck Royer
1b2be804ed
Remove unnecessary channels
`alice::swap::run_until` will be called once the execution setup is
done. The steps before are directly handled by the event loop,
hence no channels are needed for said steps: connection established,
swap request/response & execution setup.
2021-02-10 16:42:54 +11:00
Franck Royer
f5ca5faabf
Process execution setup failure similarly to other failures
By merging it in the failure event of the root behaviour.
2021-02-10 16:42:54 +11:00
Franck Royer
4ade5df0e5
Remove unnecessary impl block 2021-02-10 16:42:54 +11:00
Franck Royer
60e0b9382c
Introduced from float API for Monero quantities 2021-02-10 16:42:54 +11:00
Franck Royer
b5b990257a
Move Behaviour in dedicated module 2021-02-10 16:42:54 +11:00
Franck Royer
87be9aeb2a
Prepare separation of event loop initialisation to swap initialisation
As for Alice, the event loop will be started with the program and will
be the one starting swaps (`run_until`) based on libp2p events (swap
request).
2021-02-10 16:42:54 +11:00
Franck Royer
530b9b2ea8
Remove possible mix up of timelocks when using State0::new 2021-02-10 16:42:53 +11:00
Franck Royer
f35ed436ce
Allow EventLoop to hold a database ready to pass to alice::Buider
The `EventLoop` will use the `Builder` interface to instantiate a
`Swap` upon receiving a `SwapRequest` and successfully doing an
execution setup.
Before this change, the `EventLoop` would have to hold the path to the
db and re-open the db everytime it wants to construct a swap.

With this change, we can open the DB once and then hold a
`Arc<Database>` in the `EventLoop` and pass it to new `Swap`s structs.
2021-02-10 16:42:53 +11:00
Franck Royer
39a46baa2c
Preemptively box cancel tx to avoid size difference in enum 2021-02-10 16:42:53 +11:00
Franck Royer
69363e43a3
Preemptively box encrypted signature to avoid size difference in enum 2021-02-10 16:42:53 +11:00
Franck Royer
fd084b764d
Move generation of keys inside State0::new
The event loop will now use this function so I want to simplify its
usage to avoid having to instantiate too many items to use it.
2021-02-10 16:42:53 +11:00
Franck Royer
788445964a
Move main.rs to cli.rs to prepare for nectar binary 2021-02-10 16:42:51 +11:00
Franck Royer
311ba74cd6
Remove sell-xmr from CLI 2021-02-10 16:41:38 +11:00
Daniel Karzel
0a0bce1552 Rename temporary wallet to blockchain monitoring wallet 2021-02-10 15:06:26 +11:00
Daniel Karzel
1e29433bd2 Open or create temporary Monero wallet upon wallet initialization 2021-02-09 16:34:50 +11:00
Daniel Karzel
dac4443bbd Add functionality to open monero wallet through rpc 2021-02-09 16:34:50 +11:00
Daniel Karzel
62605a318a Add CreateWallet trait to expose create_wallet 2021-02-09 16:34:50 +11:00
Daniel Karzel
53fcd9224c Give finding the refund tx priority over waiting for the punish transaction to be finalized.
This was introduced due to a CI run, where Bob included tx_refund, but Alice had waited until T2 had expired,
and then went for punishing Bob instead of refunding.
Weirdly, Alice's punich transaction did not fail in that scenario.
2021-02-09 12:13:43 +11:00
Daniel Karzel
86290649e7 work in review comments 2021-02-08 21:20:58 +11:00
Daniel Karzel
c930ad84a4 Add --force flag for cancel and refund 2021-02-08 21:19:38 +11:00
Daniel Karzel
02f8eb7f18 Add test for cancel/refund before timelock expired 2021-02-08 21:18:37 +11:00
Daniel Karzel
2d5d70d856 Timeout for Alice waiting for ack for sending transfer proof
If dialing Bob fails Alice waits for the acknowledgement of the transfer proof indefinitely.
The timout prevents her execution from hanging.
Added a ToDo to re-visit the ack receivers. They don't add value at the moment and should be removed.
2021-02-08 21:18:37 +11:00
Daniel Karzel
c9adbde5d5 Add test for Bob's manual cancel and refund 2021-02-08 21:17:56 +11:00
Daniel Karzel
ad2aefc2a5 Refund Command 2021-02-08 21:16:32 +11:00
Daniel Karzel
0600a7048e Cancel command 2021-02-08 21:11:39 +11:00
Franck Royer
dee8c1e335
Remove scopes 2021-02-08 09:16:31 +11:00
Franck Royer
a48823a665
Re-organise Alice state to be more coherent with the msg sequence 2021-02-08 09:16:31 +11:00
Franck Royer
eefb1b3b16
Use event_process = false for Bob
As we do not process the event, we can just implement the needed `From`
traits.
2021-02-08 09:16:31 +11:00
Franck Royer
a7b89e2fe4
Use event_process = false for Alice
As we do not process the event, we can just implement the needed `From`
traits.
2021-02-08 09:16:29 +11:00
Franck Royer
554ae6c00e
Remove Request Response types
These are actually not needed and forces us to cater for variants when
processing requests and responses.
2021-02-08 09:15:21 +11:00
Franck Royer
5a5a1c05f7
Set appropriate name to codec 2021-02-08 09:15:21 +11:00
Franck Royer
a11e894b31
Prepend all libp2p protocols with "comit" 2021-02-08 09:15:21 +11:00
Franck Royer
cfc5cb5206
Remove dead code and combine swap request & one shot codecs 2021-02-08 09:15:20 +11:00
Franck Royer
fc2d8d3861
Rename alice::Message0 to Message0
There is now only one message0
2021-02-08 09:15:20 +11:00
Franck Royer
88bf080dc0
rename alice::Message0 to Message1 2021-02-08 09:15:20 +11:00
Franck Royer
18f326ddd1
Rename bob::Message1 to Message2
As per sequence diagram.
2021-02-08 09:15:20 +11:00
Franck Royer
0d1be52966
Rename alice::Message1 to Message3
As per sequence diagram.
2021-02-08 09:15:20 +11:00
Franck Royer
e74efd38b5
Rename bob::Message2 to Message4
As per sequence diagram.
2021-02-08 09:15:20 +11:00
Franck Royer
081237bb6f
Remove unused behaviours 2021-02-08 09:15:20 +11:00
Franck Royer
ecb54958ee
Preemptively Box few messages 2021-02-08 09:15:19 +11:00
Franck Royer
3fa4ffa82c
Implement new behaviour for execution setup 2021-02-05 16:42:46 +11:00
Franck Royer
9ae050abf8
Use correct variable name 2021-02-05 16:42:33 +11:00
Franck Royer
c316ea5244
Upgrade toolchain
Needed to use libp2p-async-await
2021-02-04 15:18:33 +11:00
Franck Royer
e82383bcf6
Avoid carrying rng 2021-02-04 15:18:33 +11:00
Philipp Hoenisch
25bf5df122
Merge pull request #172 from comit-network/dead-code
Remove dead code
2021-02-04 13:55:02 +11:00
Philipp Hoenisch
8743527df9
Remove dead code 2021-02-03 14:26:36 +11:00
Daniel Karzel
b27363e386 Use correct default data directory 2021-02-02 20:36:58 +11:00
Daniel Karzel
5cb4f3c99d rename configuration to config 2021-01-29 17:31:18 +11:00
Daniel Karzel
89b3775e05 Rename config to execution_params 2021-01-29 17:27:50 +11:00
Daniel Karzel
802dc61e7e Configuration for RPC urls and Bitcoin wallet name 2021-01-29 17:21:19 +11:00
Franck Royer
f1c07fbb6d
Remove incorrect todo 2021-01-29 16:13:25 +11:00
Franck Royer
c25d5ff07e
Improve network logging 2021-01-29 16:13:25 +11:00
Franck Royer
f9f17b0e23
Do not consider transfer proof sent until it's ack'd 2021-01-29 15:41:50 +11:00
Franck Royer
b968c98805
remove unnecessary logs 2021-01-29 15:41:50 +11:00
Franck Royer
cc76b201b5
Do not consider encrypted signature sent until it's ack'd 2021-01-29 15:41:50 +11:00
Franck Royer
5af3532cbf
Fix log messages 2021-01-29 15:41:50 +11:00
Franck Royer
108cc1e6cc
Use trait instead of passing struct 2021-01-29 15:41:49 +11:00
Franck Royer
704a8e7b01
Add swap id to tracing context 2021-01-29 13:29:24 +11:00
Franck Royer
b8a9356d1b
Change expiries depending on the test goal 2021-01-29 13:29:24 +11:00
Franck Royer
49b8d19e41
test: Log state on failure 2021-01-29 11:36:13 +11:00
rishflab
0b69573129
Run tests on one thread, increase T1 2021-01-29 11:36:13 +11:00
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.
2021-01-29 11:36:13 +11:00
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
2021-01-29 11:36:10 +11:00
Franck Royer
2073e88683
Remove wrapping if ReadOneError when unnecessary 2021-01-27 14:33:43 +11:00
Franck Royer
2929a8f101
Use the correct protocol support 2021-01-27 14:27:59 +11:00
Franck Royer
b62ef9c2d9
Harmonizing naming 2021-01-27 14:25:45 +11:00
Franck Royer
8fd2620b83
Improve names for messages 4 and 5 2021-01-27 14:16:31 +11:00
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.
2021-01-22 17:19:20 +11:00
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.
2021-01-22 17:19:20 +11:00
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
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