Commit Graph

2649 Commits (master)
 

Author SHA1 Message Date
Tobin C. Harding 3492c46e71 Verify amounts with user 4 years ago
Tobin C. Harding 05766d3146 Add swap/
Add a binary crate `swap` that implements two nodes (Alice and Bob). With this
applied we can start up a node for each role and do:

- Bob: Requests current amounts using BTC is input
- Alice: Responds with amounts
- Bob: (mock) get user input to Ok the amounts

... continue with swap (TODO)
4 years ago
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.
4 years ago
Lucas Soriano del Pino f0ecc62748 Check expiry before emitting first action 4 years ago
Lucas Soriano del Pino df4ffb65c9 Make bitcoin::WatchForRawTransaction infallible
And trigger refund if Alice's redeem transaction takes too long.
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 08be87747f Configure exponential backoff so that it never stops retrying 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
Philipp Hoenisch e2bf429fb7
Merge pull request #11 from comit-network/gpl-v3
Change license to GPLv3
4 years ago
Philipp Hoenisch 753a049952
Change license to GPLv3 4 years ago
Philipp Hoenisch 1ee060b535
Merge pull request #9 from comit-network/re-order-send-recv
Re-order send/receive
4 years ago
Tobin C. Harding fc12b0d9fd Re-order send/receive
There are no guarantees that send_message and receive_massage do not block
the flow of execution. Therefore they must be paired between Alice/Bob, one
send to one receive in the correct order.

Define Alice to call `receive_message` first, with Bob sending the message. Do
this because we are expecting Alice to be have a well known address, there is no
currently such assumption for Bob.
4 years ago
Tobin C. Harding 911ff396db
Merge pull request #3 from comit-network/readme 4 years ago
rishflab 36608657a5
Merge pull request #2 from comit-network/async-squashed
Execute Alice and Bob state machines concurrently
4 years ago
rishflab c778f4e204 Remove incorrect todo 4 years ago
rishflab 2c6bb8fa19 Remove redundant attribute 4 years ago
rishflab 51760041f0 Remove duplicated macro definitions 4 years ago
rishflab 666c121bb3 Implement transport traits with generics 4 years ago
rishflab bf576bf251 Move test functions out of lib 4 years ago
rishflab 61a8a3e428 Improve formatting of tests 4 years ago
rishflab 9f046944a5 Add context to log messages 4 years ago
rishflab 48e5eb8d6c Remove redundant type declarations 4 years ago
rishflab 154b3edcf9 Split SendReceive into seperate traits 4 years ago
rishflab 6b7193b974 Fix clippy warnings 4 years ago
rishflab 697e1195cd Fix Cargo.toml fmt 4 years ago
rishflab a759f39b1d Fix module ambiguity in tests 4 years ago
rishflab 36ed3a0b8b Rename ImportOutput to reflect purpose 4 years ago
rishflab 213034dc1f Remove unused clone from states 4 years ago
rishflab d01c05e5f5 Use intellij rust gitignore 4 years ago
rishflab 25edd90fb0 Remove empty lines between imports 4 years ago
rishflab 4e031ff9a2 Loop on blockchain call instead of delaying
Previously there was a delay making a get raw transaction call to
give some time for a transaction to be confirmed on the blockchain.
This has been replaced with a loop that waits until the call is
succesful.
4 years ago
rishflab f6f4ec2bdb Fix dependencies 4 years ago
rishflab 148e49a959 Remove redundant lifetime parameter 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
Tobin C. Harding 3d3864807d
Merge pull request #7 from comit-network/debug-ci 4 years ago
Tobin C. Harding e17575304b Add 60 sleep to workflow
There is some sort of timing issue when spinning up the monero containers on
github CI. I do not know exactly what is the cause but we have a configurable
'additional sleep time' already available for `testcontainers` that can resolve
this issue.

Use the environment variable MONERO_ADDITIONAL_SLEEP_PERIOD to tell
`testcontainers` to wait an additional 60 while bringing up the monero
container.
4 years ago
Tobin C. Harding 2064bfed5b Revert "Merge pull request #5 from comit-network/fix-ci"
This reverts commit 3b0b722d46, reversing
changes made to 93f1d960f5.
4 years ago
Tobin C. Harding bfeb460073 Fix typo 4 years ago
Tobin C. Harding 30767ec755 Move alice/bob definition comment 4 years ago
Tobin C. Harding 1f89ea122e Fix embedded image 4 years ago
Tobin C. Harding 861dcc4a56 Update README
Update the readme inline with review suggestions by doing:

- Copy 'long story short' text from blog post
- Correct the erroneous description of watching blockchains
- Fix gramar
4 years ago
Philipp Hoenisch 3b0b722d46
Merge pull request #5 from comit-network/fix-ci
Run CI tests on one thread
4 years ago
rishflab e8ffed6979 Run CI tests on one thread
This is quick and dirty fix to resolve xmr-btc-swap and
monero-harness tests failing in CI when run concurrently.
4 years ago
Tobin C. Harding 65b0e54a5f Add a README.md file
Add a readme that describes the project. Specifically

- module structure
- what we prove and do not prove
- how we test
4 years ago
Lucas Soriano 93f1d960f5
Merge pull request #1 from comit-network/actual-work
Swap Monero for Bitcoin
4 years ago
Lucas Soriano del Pino b9c202efc9 Remove redundant license 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
rishflab 818e522bd4
Initial commit 4 years ago