Commit Graph

63 Commits (247a993b55fa1323b1eec357aa5e77c79338c1bd)

Author SHA1 Message Date
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 2c6bb8fa19 Remove redundant attribute 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 154b3edcf9 Split SendReceive into seperate traits 4 years ago
rishflab 6b7193b974 Fix clippy warnings 4 years ago
rishflab a759f39b1d Fix module ambiguity in tests 4 years ago
rishflab 36ed3a0b8b Rename ImportOutput to reflect purpose 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 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