Commit Graph

2519 Commits

Author SHA1 Message Date
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
Tobin C. Harding
be37725303 monero-harness: Use tracing 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
Philipp Hoenisch
dbd7f2b0c9
Merge pull request #27 from comit-network/tor-swap 2020-10-28 13:28:56 +11:00
Philipp Hoenisch
b8fd9a734f
Use full path imports for dependencies to reduce cfg hell 2020-10-28 11:18:14 +11:00
Tobin C. Harding
a1351e5461 Do not declare 'port' variable 2020-10-28 10:11:04 +11:00
Tobin C. Harding
464b699426 Fail if user passes in local port for non-tor usage
Local port is only used when running behind tor. Fail if user passes a local
port number when running in non-tor mode.
2020-10-28 09:46:25 +11:00
Tobin C. Harding
42d194f758 Use fully qualified path for bail 2020-10-28 09:21:37 +11:00
Tobin C. Harding
5e35904101 Use an option for the local port
We can wrap the local port in an option and pass None when we are not using Tor.
This reduces code duplication.
2020-10-28 08:41:23 +11:00
Philipp Hoenisch
7f3aa644a0
Extre CI flag to run clippy for wihtout all features enabled 2020-10-27 16:02:32 +11:00
Philipp Hoenisch
8811a0a205
Add Tor to main 2020-10-27 15:03:59 +11:00
Lucas Soriano
cf8accf30d
Merge pull request #28 from comit-network/re-work-swap-functions
Re work swap functions
2020-10-27 13:27:52 +11:00
Tobin C. Harding
b22f265cf3 Send back an empty response to Message2
Alice does not respond with anything when receiving message 2 from Bob. We don't
want to leave Bob's request/response protocol waiting so send an empty response
back.
2020-10-27 10:26:54 +11:00
Tobin C. Harding
194a19cf1d Add todos 2020-10-27 10:26:51 +11:00
Tobin C. Harding
6be5d64c1c Remove stale, ugly, type conversion 2020-10-27 10:26:46 +11:00
Lucas Soriano
4cfc603786
Merge pull request #26 from comit-network/more-on-chain-tests
Test that Alice punishes if Bob is inactive after locking bitcoin
2020-10-27 10:22:12 +11:00
Lucas Soriano
58aa2b5a2b
Merge pull request #23 from comit-network/remove-re-export
Do not re-export curve25519_dalek
2020-10-27 10:21:58 +11:00
Tobin C. Harding
8f5a989ad1 Use 'amounts' for local varibale name 2020-10-27 10:05:20 +11:00
Tobin C. Harding
b8130d23a6 Only break if Bob has requested amounts already
We don't want Bob to be able to crash us by sending an out of
order message. Only break if Bob has not requested amounts.
2020-10-27 10:02:03 +11:00
Tobin C. Harding
5da84a3d48
Merge pull request #25 from comit-network/unused-assigments
Remove allow(unused_assignments) attribute
2020-10-27 09:55:32 +11:00
Tobin C. Harding
36ba504129
Merge pull request #24 from comit-network/alice-state-3
Send Message2 from Bob to Alice
2020-10-27 09:13:45 +11:00
Lucas Soriano del Pino
24104d5d35 Test that Alice punishes if Bob is inactive after locking bitcoin 2020-10-26 16:05:30 +11:00
Lucas Soriano del Pino
ba4ae09cd1 Remove allow(unused_assignments) attribute
It looks like the compiler can ascertain that `message0` will be
initialised by the time we use it, so it doesn't need to be an
`Option` and it doesn't need to be declared as mutable.
2020-10-26 15:21:32 +11:00
Tobin C. Harding
cbccc282ef Send Message2 from Bob to Alice
In order for Alice to complete the handshake she needs to transition to state 3,
for this she needs message 2 from Bob.

Send `bob::Message2` to Alice and transition to `State3` - completing the
handshake.
2020-10-26 14:30:41 +11:00
Lucas Soriano
90f6c55290
Merge pull request #22 from comit-network/on-chain-tests
Test that both parties refund if Alice does not redeem
2020-10-26 13:47:37 +11:00
Lucas Soriano del Pino
0dd01c3a3b Do not re-export curve25519_dalek
Anything that needs to be re-exported by this crate from
`curve25519_dalek` can be re-exported from the `monero` module. In
fact, the `Scalar` type was already being re-exported.
2020-10-26 13:06:20 +11:00
Lucas Soriano del Pino
cea1af1e1a Take bitcoin_tx_lock_timeout as argument to action generators 2020-10-26 12:30:15 +11:00
Lucas Soriano del Pino
1d21ae7e7a Use pin_mut! instead of futures::pin_mut! 2020-10-26 12:30:15 +11:00
Lucas Soriano del Pino
aa2a20916e Include Bob being inactive as a reason for failure 2020-10-26 12:30:15 +11:00
Lucas Soriano del Pino
41e8c7283c Verify Bob's redeem encsig as Alice
Not doing so means that receiving an invalid encrypted signature from
Bob would make the generator produce a `RedeemBtc` action that should
not be accepted by the node (since Bob's signature would be invalid
after decrypting his encrypted signature).

It's better to fail early and let the user know what went wrong,
rather than let them hit an incomprehensible error when using their
wallet.
2020-10-26 12:30:15 +11:00
Lucas Soriano del Pino
def3399d1c Use while instead of loop 2020-10-26 12:30:15 +11:00
Lucas Soriano del Pino
c86a82b315 Rename action_generator_alice to action_generator 2020-10-26 12:30:15 +11:00
Lucas Soriano del Pino
e84c56378c Test that both parties refund if Alice does not redeem
Also:

- Move generator functions to `alice` and `bob` modules. This makes
using `tracing` a lot easier, since the context of the file name let's
us differentiate between Alice's and Bob's generator logs more
clearly.
- Accept 0 confirmations when watching for the Monero lock
transaction. This should eventually be configured by the application,
but in the tests it's making things unexpectedly slower.
2020-10-26 12:30:15 +11:00
rishflab
964640154d
Merge pull request #18 from comit-network/db-dupe-code
Improve serde implementations
2020-10-26 12:16:46 +11:00
rishflab
ec71f98252 Revert re-imports to qualified paths 2020-10-26 11:45:27 +11:00
rishflab
fea6b29da9 Test monero amount serialisation 2020-10-26 11:39:54 +11:00
rishflab
28ffe063b7 Remove stale comment 2020-10-26 11:36:46 +11:00
Franck Royer
82b092d86e Use consensus encoding for monero private key
Using consensus encoding future proof the library by using a commonly
accepted de/serialization format.
2020-10-26 11:36:46 +11:00
Franck Royer
9ea708b2a5 Remove custom implementation of bitcoin amount serde
This is unnecessary as rust-bitcoin provides it.
2020-10-26 11:36:40 +11:00
rishflab
3b14a0e4b3
Merge pull request #21 from comit-network/integrate-db
Move storage into application crate
2020-10-26 11:19:06 +11:00