Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(swapd): begin atomic swap implementation #246

Closed
wants to merge 26 commits into from

Conversation

noot
Copy link

@noot noot commented Dec 18, 2023

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 and Follower (not sure about naming yet, wanted to make it generic as it will eventually be both-ways).
  • implement initiator::Swap and follower::Swap which run the actual swap protocol; currently only initiator::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 ethereum Swap 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

@parazyd
Copy link
Member

parazyd commented Dec 18, 2023

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.

@noot
Copy link
Author

noot commented Dec 18, 2023

@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.

@parazyd
Copy link
Member

parazyd commented Dec 19, 2023

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.

@noot noot marked this pull request as ready for review February 27, 2024 03:22
@noot
Copy link
Author

noot commented Feb 27, 2024

@parazyd updated to use smol::channel::bounded - this is ready for another look!

@noot
Copy link
Author

noot commented Mar 26, 2024

closing for now as this has been moved into its own repository https://codeberg.org/darkrenaissance/swapd

@noot noot closed this Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants