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

Add plugin for Peerswap atomic swap based local liquidity management protocol #2496

Closed
wants to merge 32 commits into from

Conversation

remyers
Copy link
Contributor

@remyers remyers commented Nov 21, 2022

This PR implements the draft PeerSwap protocol as an Eclair Plugin and builds off of PR #2342 with a cleaner commit history after reorganization into a plug-in. This PR requires PR #2495 which makes some prerequisite changes to Eclair.

The plugin creates a SwapRegister actor at startup which will spawn swap sender actors in response to user CLI commands. The SwapRegister will also spawn swap receiver actors in response to swap requests received from peers. The SwapRegister forwards swap messages received from peers based on their swapId field to corresponding local swap actors. When a swap actor has completed, it simply stops and this triggers the SwapRegister to remove it from its map.

The Swap database check-points information about in-progress swaps after a swap maker has committed an on-chain tx or a swap taker has initiated an off-chain payment. Details about the result of the swap are added to the swap record when it completes.

Protocol implementation TODOs:

  • add CLI and/or configurable "allow-list" for swap peers and other limits for accepting swap requests
  • channels should fail proposed htlc updates that would remove liquidity needed for an active swap
  • add or adjust timeouts and timeout behavior to ensure safe operation of the protocol
  • re-enable the logic to check for acceptable premium values (see PR #151)

PeerSwap specification suggestions/questions to discuss:

  • custom byte encoded message rather than json #1
  • use 32-byte channel ids instead of short channel ids #2
  • nit: rename “OpeningTxBroadcasted” to grammatically correct “OpeningTxBroadcast” #3
  • send a signature instead of a private key for cooperative closes #4

@remyers
Copy link
Contributor Author

remyers commented Dec 7, 2022

The comment from @t-bast about making Maker/Taker actors use SupervisorStrategy.resume is addressed by d272226. This commit also adds comments to explain the choice.

The change to resume has been made safe by checking that no swap has been saved as a checkpoint to the swap db before the Maker funds the opening tx or the Taker pays the swap invoice.

Should I keep the logic from 036e7f6 that I added to handle the case where a Maker or Taker stops prematurely before recording a result?

 - remove inline text for generic responses
 - remove unused commands (timeout, forward)
@remyers
Copy link
Contributor Author

remyers commented Dec 9, 2022

Fixed to remove generic messages as per the comment from @t-bast in c2c8460.

 - reorganized because resume behavior should not need to check the swap db
 - removed monitor from tests
 - add verbose status information to debug log instead of returning as status
@t-bast
Copy link
Member

t-bast commented Dec 29, 2022

I have created the eclair-plugins repository, it would make sense to move this work over there: https://github.com/ACINQ/eclair-plugins

This fixes a test failure introduced by PR ACINQ#2490 when the Maker tries to create a Bolt11 invoice and the RouteBlinding invoice feature is enabled.
@remyers
Copy link
Contributor Author

remyers commented Jan 12, 2023

This PR is continued in the eclair-plugins repository as PR #5

@remyers remyers closed this Jan 12, 2023
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