Commit Graph

33 Commits (a0d859147acd30731e19b84e07bfa4a99a16460a)

Author SHA1 Message Date
rishflab 9b7b44ceba Remove old refund test 4 years ago
Daniel Karzel 03b8e5f52e Upgrade CLI for mainnet test 4 years ago
Franck Royer 78674818c2
Upgrade bitcoin-harness 4 years ago
Franck Royer cfcd1e7170
Clean-up dep versions
- Use bitcoin-harness 0.2
- Use cross-curve-dleq latest master commit
4 years ago
Franck Royer 624716d8a7
Upgrade rust-bitcoin to 0.25 4 years ago
Franck Royer 765482b0aa
Implement `wait_for_transaction_finality` 4 years ago
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.
4 years ago
Philipp Hoenisch 0b9e8c145e
Update xmr-btc lib to use new monero-harness 4 years ago
Lucas Soriano del Pino 792fa351c8 Upgrade bitcoin-harness dependency
From dev-branch to master.
4 years ago
rishflab c781ee949d Move storage into application crate 4 years ago
Philipp Hoenisch 17b32fed90
Moving tor into swap 4 years ago
Tobin C. Harding 79c6c8bbef Sort Cargo.toml lines 4 years ago
Tobin C. Harding ade0e08db6 Merge branch 'master' into on-chain-protocol 4 years ago
Tobin C. Harding f8adf6d7e0 Merge branch 'on-chain-protocol' of github.com:comit-network/xmr-btc-swap into on-chain-protocol 4 years ago
Lucas Soriano del Pino 5395303a99 Test on-chain protocol happy path 4 years ago
Tobin C. Harding a0987ee2b8 Use upstream serder for dleq Proof 4 years ago
Tobin C. Harding ad0d563d93 Use Normal secp256k1::Point 4 years ago
Tobin C. Harding 3e0b40c248 Merge branch 'db' into on-chain-protocol 4 years ago
Philipp Hoenisch ae1ea08bb2
Make it work on CI 4 years ago
Philipp Hoenisch e67e940768
Split authenticated struct into unauthenticated struct to make it usage more obvious 4 years ago
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.
4 years ago
Philipp Hoenisch 295216a8ee
Add Tor feature flag and only run test if enabled 4 years ago
Philipp Hoenisch 5e19949d71
Add library to create a Tor service via Tor control port 4 years ago
Lucas Soriano del Pino 5250e16b64 Update dependency to cross-curve-dleq and ecdsa_fun 4 years ago
Lucas Soriano del Pino 04e1dca16a Fix dependency to cross-curve-dleq and ecdsa_fun 4 years ago
Lucas Soriano del Pino ba3011a9c9 Trigger refund if the publication of Monero TxLock takes too long 4 years ago
Lucas Soriano del Pino 15f7932f7f Replace monero::CheckTransfer with monero::WatchForTransfer
Instead of checking once to see if Monero's `TxLock` has been
published, the new trait should keep looking until the transaction has
been found.

The new trait also allows the caller to set an expected number of
confirmations on the transaction.

The implementation of the trait is currently part of test code, but it
should be similar to what we will eventually do for an application.
4 years ago
Lucas Soriano del Pino 5daa3ea9a8 [WIP] Generate actions for Bob's on-chain protocol
Mimics what @thomaseizinger did here [1] and here [2].

This has the advantage that the consumer has more freedom to execute
`Action`s without having to implement particular traits. The error
handling required inside this protocol-executing function is also
reduced.

As discussed with Thomas, for this approach to work well, the
trait functions such as `receive_transfer_proof` should be infallible,
and the implementer should be forced to hide IO errors behind a retry
mechanism.

All of these asynchronous calls need to be "raced" against
the abort condition (determined by the `refund_timelock`), which is
missing in the current state of the implementation.

The initial handshake of the protocol has not been included here,
because it may not be easy to integrate this approach with libp2p, but
a couple of messages still need to exchanged. I need @tcharding to
tell me if it's feasible/good to do it like this.

[1]
https://github.com/comit-network/comit-rs/blob/move-nectar-swap-to-comit/nectar/src/swap/comit/herc20_hbit.rs#L57-L184.
[2] e584d2b14f/nectar/src/swap.rs (L716-L751).
4 years ago
rishflab 697e1195cd Fix Cargo.toml fmt 4 years ago
rishflab 213034dc1f Remove unused clone from states 4 years ago
rishflab f6f4ec2bdb Fix dependencies 4 years ago
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.
4 years ago
Lucas Soriano del Pino 1f99cf001c Swap Monero for Bitcoin
Co-authored-by: rishflab <rishflab@hotmail.com>
Co-authored-by: Philipp Hoenisch <philipp@hoenisch.at>
Co-authored-by: Tobin C. Harding <tobin@coblox.tech>
4 years ago