Commit Graph

91 Commits

Author SHA1 Message Date
Franck Royer
75e7fedfed Implemented Alice transition from Negotiated to BtcLocked 2020-11-27 09:34:35 +11:00
Franck Royer
c4cd64d134 Implemented Alice transition from Started to Negotiated 2020-11-27 09:34:35 +11:00
Franck Royer
0fe5131a8a Fix import format 2020-11-27 09:34:35 +11:00
rishflab
ae94b170fd Cleanup
Move state machine executors into seperate files

Remove check for ack message from Alice. Seems like a bad idea to
rely on an acknowledgement message instead of looking at the
blockchain.

Fix warnings
2020-11-27 09:34:35 +11:00
rishflab
ff7daf16f3 WIP: Test simplified swap execution 2020-11-27 09:21:21 +11:00
rishflab
dd07e2f882 Add Alice execution path
Consolidate and simplify swap execution. Generators are no longer
needed. Consolidate recovery and swap data structures. The
recursive calls can be replaced with a loop if returning prior to
completion is desired for testing purposes.

Fill out alice abort path

Move state machine executors into seperate files

Not compiling due to recursion/async issues

Fix async recursion compilation errors

Fix Bob swap execution

Remove check for ack message from Alice. Seems like a bad idea to
rely on an acknowledgement message instead of looking at the
blockchain.

Fix Bob abort

Fix warnings

Xmr lock complete

Add TxCancel submit to XmrLocked

Bob swap completed

Remove alice
2020-11-27 09:21:21 +11:00
Lucas Soriano del Pino
483c819e17 Correctly re-export types from bitcoin and monero modules 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
f5ff50157e Some more fixes and comments after testing Alice's recovery 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
bea99185ed Use correct default values for monerod_url*
*`monerod_url` is an incorrect name as it's actually a
`monero_wallet_rpc_url`. This is fixed in another branch.
2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
5930af3587 Move some things around in recover module 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
33b36c98fa Configure binary tracing level for xmr_btc and monero_harness 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
5dede0f361 Add more logging to recovery
Also, remove redundant timelock check.
2020-11-12 13:49:07 +11:00
rishflab
11a7963081 Fix bugs 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
f0d90130ad Add recovery command 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
09773dd15b Re-introduce history command 2020-11-12 13:49:07 +11:00
rishflab
0f1a77fa21 Fix Alice's btc redeem recovery path 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
6db40dce2a Implement swap recover function for Bob 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
28225f8643 Implement swap recover function for Alice
This introduces a lot of duplication between the binary and the
library, but it's okay because this module should only be a temporary
measure until we allow recovery to be handled by the original state
machine.

Also, fix a bug in `xmr_btc::alice::action_generator` caused by the
incorrect assumption that Alice's ability to punish Bob could be
determined before the cancel transaction hits the blockchain.
2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
b989e94322 Remove stale TODO 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
33a111d879 Move Swap state out of storage 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
ac2cfd7f65 Print swap history on --history flag 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
ecbfed9c11 Add Database API to fetch all swaps 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
f9cfc2abe3 Remove generics from Database 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
02075c2a1d Support saving multiple swaps
By replacing `LAST_STATE_KEY` with a swap ID passed as an argument to
inserting and reading from the database.
2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
934ddb366a Save state for Alice at specific points in the swap 2020-11-12 13:49:07 +11:00
rishflab
ea08778b2f Save state for Bob at specific points in the swap 2020-11-12 13:49:07 +11:00
rishflab
a44303f839 Add monerod to config
Fixed rebase issues
2020-11-03 16:08:46 +11:00
rishflab
7afd316210 Construct tor transport for Bob 2020-11-03 15:13:25 +11:00
rishflab
3b008c38a6 Remove redundant code and stale comments 2020-11-03 15:13:25 +11:00
rishflab
249f273d1b Remove stale comments 2020-11-03 15:13:25 +11:00
rishflab
5971ef1f28 Fix clippy warnings 2020-11-03 15:13:23 +11:00
rishflab
796d0b3439 Extract transport creation and remove tor conditional compile
The numerous tor conditional compile flags were removed by
extracting transport creation to the main statement. A tor
transport is created if Alice specifies a tor port using the CLI.
2020-11-03 15:12:52 +11:00
rishflab
0ca511bf8a Remove hardcoded configuration
The hardcoded configuration was replaced with CLI
configuration options. CLI based config was chosen
over a config file as it does not access and clutter
the user's file system. By CLI options depend on whether
the program is run in Alice or Bob mode.
2020-11-03 15:08:10 +11:00
Lucas Soriano del Pino
7fa7641feb Clean up some logs and comments 2020-10-30 15:51:46 +11:00
Tobin C. Harding
4d4acde476 Bubble up an event when Bob receives message 3 response
Before this patch Bob is not sending message 3. This is because we are not
polling Bob's swarm correctly. To fix it we can just mimic the other NB's and
bubble up an event when Bob receives message 3 response from Alice, this way we
can `await` upon this event which triggers polling, making Bob's swarm send the
message.
2020-10-30 14:07:15 +11:00
Lucas Soriano del Pino
a37f43a1ba wip: Provide enough funds to both parties
Also use cosntant backoff retry strategy as opposed to exponential
backoff. This is in case retrying several times quickly causes the
retry intervals to become large enough that the test is very slow
and/or the Bitcoin lock transaction expires.

The current problem occurs on the last message i.e. Bob sending
tx_redeem_encsig to Alice. The action is yielded for Bob to do it, but
Alice appears to never receive it (unconfirmed claim, requires more
logging).
2020-10-30 14:07:15 +11:00
Lucas Soriano del Pino
eb6bbe6180 wip: Fix bug where bob was sending two amount request 2020-10-30 14:05:45 +11:00
Lucas Soriano del Pino
9f32cd988e wip: Use same timelock value for refund and punish 2020-10-30 14:05:45 +11:00
Lucas Soriano del Pino
ae87c10cae wip: fixed message0 2020-10-30 14:05:45 +11:00
Tobin C. Harding
119f2a7c54 Add error logging to request_response 2020-10-30 14:05:45 +11:00
Tobin C. Harding
b8ab4b4eee wip: add env filter 2020-10-30 14:05:45 +11:00
Tobin C. Harding
3e2f0b74a2 Do not trace events meant for other NBs 2020-10-30 14:05:45 +11:00
Tobin C. Harding
c464555f5e Enable trace output 2020-10-30 14:04:27 +11:00
Tobin C. Harding
39f86154ce Use serde_cbor instead of serde_json
We have serde trait implementations that use `serde_cbor` which is a superset of
josn. We cannot use `serder_json` to ser/deser these objects.
2020-10-30 14:04:27 +11:00
Tobin C. Harding
2bd4977fe4 Increase read buffer size
Our messages are quite big, increase the read buffer to 1 megabyte to
accommodate them.
2020-10-30 14:04:27 +11:00
Lucas Soriano del Pino
9384b0cf3c [WIP] Swap app e2e test 2020-10-30 14:04:27 +11:00
Lucas Soriano del Pino
9e30bd5151 Generate addresses as late as possible 2020-10-30 14:04:27 +11:00
Lucas Soriano del Pino
3f43581da7 Implement traits Receive{BitcoinRedeemEncsig, TransferProof}
Unfortunately, I had to put the wrap the swarm in Alice's `Network`
struct in an `Arc<Mutex<T>>` in order to be able to use `backoff` to
control the retry mechanism. This is because the stream of events
cannot be turned into a `SharedFuture` (unlike Bob's).

It would be good to find an alternative solution.
2020-10-30 14:03:27 +11:00
Lucas Soriano del Pino
a4e4c27bee Execute Bob's on-chain protocol after handshake
Co-authored-by: Tobin C. Harding <tobin@coblox.tech>
2020-10-30 14:03:27 +11:00
Lucas Soriano del Pino
4ee82a5a2a Execute Alice's on-chain protocol after handshake
Co-authored-by: Tobin C. Harding <tobin@coblox.tech>
2020-10-30 14:00:39 +11:00