Commit Graph

49 Commits

Author SHA1 Message Date
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
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
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
cfc5cb5206
Remove dead code and combine swap request & one shot codecs 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
0d1be52966
Rename alice::Message1 to Message3
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
e82383bcf6
Avoid carrying rng 2021-02-04 15:18:33 +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
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
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
8fd2620b83
Improve names for messages 4 and 5 2021-01-27 14:16:31 +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
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
f2a25ee49b
Move definitions out of lib.rs 2021-01-22 09:00:46 +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
Franck Royer
ae8134f04e
Replace amounts messages with swap res/req 2021-01-21 12:27:30 +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
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
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
82974412b2 Remove roles from SwapFactory name as implied by module and cleanup 2021-01-19 09:43:50 +11:00
Daniel Karzel
e56c48ee23 Remove unused type 2021-01-19 09:16:05 +11:00
Daniel Karzel
3398ef8236 Use Alice swap factory in production 2021-01-19 09:16:05 +11:00
Daniel Karzel
0c19af9090 Refactor Alice's peer-id and identity to be handled on the outside
Doing this in the behaviour is a weird indirection that is not needed.
2021-01-19 09:16:04 +11:00
Daniel Karzel
8bf467b550 Make the factory code usable in production
- Introduce Test abstraction instead of tow harnesses, move test specific data into Test
- Change the abstraction from actors to swap, because we are creating swaps, not actors
- rename actor::swap  to run, because we are running a swap
2021-01-19 09:16:04 +11:00
Daniel Karzel
b031bc5e42 Re-export run_until 2021-01-15 11:49:47 +11:00
rishflab
9cbf6e9774 Re-export event loop handles 2021-01-15 10:42:49 +11:00
rishflab
6040f2ae63 Re-export event loops 2021-01-15 10:31:25 +11:00
rishflab
e8fdf62623 Re-export swap function 2021-01-15 10:20:18 +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
rishflab
1c644cb377 Rename message behaviours 2021-01-09 11:47:23 +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