Commit Graph

29 Commits

Author SHA1 Message Date
rishflab
fcec465bdb Revert "No need to send Monero transfer proof from Alice to Bob" 2020-12-01 14:52:05 +11:00
Lucas Soriano del Pino
0288e004c5 Make Alice watch for Monero lock transaction without transfer proof 2020-11-13 13:10:12 +11:00
Lucas Soriano del Pino
823add218e Remove temporary test tracing guards 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
4790d701e5 Update cross-curve-dleq dependency
Making build times considerably faster.

On my machine, after running `cargo clean`, `cargo build -p swap`
takes 2min 19s.

The updated dependency also comes with a critical fix to the `Scalar`
type, which originally wrongly assumed that secp256k1 and ed25519
scalars had the same endianness. For this reason, we now have to
reverse the bytes of recovered scalars if we are to use them on a
different chain.

Finally, there is no need to append `RUST_MIN_STACK=100000000` to
avoid stack overflows in tests and when running the binary.
2020-11-09 13:14:09 +11:00
Philipp Hoenisch
306176b3e6
PR feedback:
Removed network prefix and use the same for container and network.
Add sentence explaining prefix
2020-11-03 16:51:26 +11:00
Philipp Hoenisch
0b9e8c145e
Update xmr-btc lib to use new monero-harness 2020-11-03 16:51:26 +11:00
rishflab
c781ee949d Move storage into application crate 2020-10-26 10:32:54 +11:00
Philipp Hoenisch
c0109d12cd
Use lib to ensure ports are free 2020-10-23 11:28:58 +11:00
rishflab
03dee7a3ea Generate temp dir for db 2020-10-22 19:34:53 +11:00
rishflab
e3b68a3864 Improve database type safety
The database is now bound to a type eg. alice::State or bob::State.
The caller cannot expect to retrieve a type that is different to
the type that was stored.
2020-10-22 18:09:16 +11:00
Tobin C. Harding
97363cb05c Fix build after merge 2020-10-22 14:43:58 +11:00
Tobin C. Harding
f8adf6d7e0 Merge branch 'on-chain-protocol' of github.com:comit-network/xmr-btc-swap into on-chain-protocol 2020-10-22 14:33:16 +11:00
Lucas Soriano del Pino
5395303a99 Test on-chain protocol happy path 2020-10-22 11:50:06 +11:00
Tobin C. Harding
2a07113074 Fix buld after merge of db branch 2020-10-22 08:28:51 +11:00
Tobin C. Harding
3e0b40c248 Merge branch 'db' into on-chain-protocol 2020-10-22 08:17:54 +11:00
rishflab
39afb4196b Save and recover protocol state from disk
NOTE: This implementation saves secrets to disk! It is not
secure.

The storage API allows the caller to atomically record the state
of the protocol. The user can retrieve this recorded state and
re-commence the protocol from that point. The state is recorded
using a hard coded key, causing it to overwrite the previously
recorded state. This limitation means that this recovery
mechanism should not be used in a program that simultaneously
manages the execution of multiple swaps.

An e2e test was added to show how to save, recover and resume
protocol execution. This logic could also be integrated into the
run_until functions to automate saving but was not included at
this stage as protocol execution is currently under development.

Serialisation and deserialisation was implemented on the states
to allow the to be stored using the database. Currently the
secret's are also being stored to disk but should be recovered
from a seed or wallets.
2020-10-21 18:39:45 +11:00
Lucas Soriano del Pino
d3a7689059 Update comment about minimum stack size 2020-10-21 16:10:20 +11:00
Lucas Soriano del Pino
e5ddec76f7 Increase Rust minimum stack size in CI 2020-10-21 16:09:24 +11:00
Lucas Soriano del Pino
8b48191e1c Increase Rust minimum stack size in CI 2020-10-21 15:55:20 +11:00
Lucas Soriano del Pino
50ed74319f Simplify xmr-btc/tests Monero wallet
- Make it the same for Alice and Bob.
- Make it contain a wallet client instead of the `Monero` struct.

Also:

Remove `Container` from inside `Monero` struct. The caller of `new`
can simply ensure that `Container` is not dropped to keep the
container alive.

This makes the `Monero` struct easier to work with, as it just holds
the data necessary to create the different clients created during
`init`, and does not have any lifetime restrictions.
2020-10-20 12:18:27 +11:00
Lucas Soriano del Pino
4723626fc0 Suppress compiler noise in tests folder
By having two modules that declare and use the `harness` module we ran
into a situation where not all parts of the `harness` module were
being used by both of these other test modules. This was producing
annoying warnings.

For now this can be solved by marking the `harness` module declaration
as public. This has no real effect since modules under `/tests` cannot
be depended on elsewhere, but it satisfies the compiler. It does mean
that we will not hear about unused functions, but this change should
be temporary and it's a very minor problem given that it's just test
code.
2020-10-15 21:53:55 +11:00
rishflab
2c6bb8fa19 Remove redundant attribute 2020-10-09 11:40:00 +11:00
rishflab
bf576bf251 Move test functions out of lib 2020-10-09 11:40:00 +11:00
rishflab
61a8a3e428 Improve formatting of tests 2020-10-09 11:40:00 +11:00
rishflab
6b7193b974 Fix clippy warnings 2020-10-09 11:40:00 +11:00
rishflab
a759f39b1d Fix module ambiguity in tests 2020-10-09 11:40:00 +11:00
rishflab
25edd90fb0 Remove empty lines between imports 2020-10-09 11:40:00 +11:00
rishflab
f6f4ec2bdb Fix dependencies 2020-10-09 11:40:00 +11:00
rishflab
8754a9931b Execute Alice and Bob state machines concurrently
Previously we were testing the protocol by manually driving Alice and
Bob's state machines. This logic has now be moved to an async state
transition function that can take any possible state as input. The
state transition function is called in a loop until it returns the
desired state. This allows use to interrupt midway through the protocol
and perform refund and punish tests. This design was chosen over a
generator based implementation because the the generator based
implementation results in a impure state transition function that is
difficult to reason about and prone to bugs.

Test related code was extracted into the tests folder.

The 2b and 4b states were renamed to be consistent with the rest.

Macros were used to reduce code duplication when converting
child states to their parent states and vice versa.

Todos were added were neccessary.
2020-10-09 11:40:00 +11:00