darkfi
darkfi copied to clipboard
feat(swapd): begin atomic swap implementation
This PR is the start of the ETH-DRK atomic swap implementation. The first "direction" to be implemented is that where ETH is the swap initiator (first-mover) and DRK is the second-mover.
what was done:
- add swap protocol traits
Initiator
andFollower
(not sure about naming yet, wanted to make it generic as it will eventually be both-ways). - implement
initiator::Swap
andfollower::Swap
which run the actual swap protocol; currently onlyinitiator::Swap
is implemented. - add the eth swap contract and bindings for it + test utils
- implement the eth-side swap handler, which calls required methods on the contract when certain events happen
- implement the eth-side event watcher, which sends events when certain contract events are emitted
- add unit test
test_initiator_swap_success
which tests the success case with an ethereumSwap
instance running with a mock no-op darkfi backend.
to do (either here on in a follow-up):
- clean up the ethereum/forge readme and documentation
- get rid of the
#[allow(dead_code)]
maybe? or can do in a follow up with CLI stuff
Hi. I'd advise to follow these recommendations for your commit messages unless you want to squash everything into one later: https://darkrenaissance.github.io/darkfi/dev/dev.html#making-life-easy-for-others
Please do not include git submodules in the repo.
Do not use tokio
. We use smol
.
Please include the licensing header in your files like it is found in our other source files.
@parazyd thanks for the feedback! do you guys squash and merge PRs? if not, i can squash all the commits before merging.
Please do not include git submodules in the repo.
this is due to using forge for building and managing the eth smart contracts, which uses git submodules for dependencies. the submodules are only required for compiling the contracts, which is done only on the test-utils
feature (used only in tests). the alternative would be to just copy-paste the contract dependencies, which i can do if needed.
Instead of async-oneshot
, in our code we use https://docs.rs/smol/latest/smol/channel/fn.bounded.html
We try to avoid adding unnecessary dependencies.
We can squash the PR, yes.
I suppose the submodule is fine then for now. We can decide later on what to do on that part.
@parazyd updated to use smol::channel::bounded
- this is ready for another look!
closing for now as this has been moved into its own repository https://codeberg.org/darkrenaissance/swapd