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

refactor(swap): Upgrade libp2p to 0.53.2, reliable retry mechanisms #109

Merged
merged 116 commits into from
Nov 10, 2024

Conversation

binarybaron
Copy link

@binarybaron binarybaron commented Oct 10, 2024

Our libp2p version is out of date, and we need to tackle the upgrade even though it's a significant undertaking. This'll also fix some other issues.

This PR includes the following changes:

  • Breaking network protocol change: The libp2p version has been upgraded to 0.53 which includes breaking network protocol changes. ASBs and CLIs will not be able to swap if one of them is on the old version.
  • ASB: Transfer proofs will be repeatedly sent until they are acknowledged by the other party. This fixes a bug where it'd seem to Bob as if the Alice never locked the Monero. Forcing the swap to be refunded.
  • CLI: Encrypted signatures will be repeatedly sent until they are acknowledged by the other party
  • CLI+ASB: Libp2p network errors in request-response protocols are now propagated throught the event loop channels. This allows the caller to retry if an error occurs (e.g timeout)

Closes #101, #95

@binarybaron binarybaron changed the title Upgrade libp2p to 0.53.2 refactor(swap): Upgrade libp2p to 0.53.2 Oct 11, 2024
- Update libp2p dependency to 0.53.2 in Cargo.toml
- Add libp2p-swarm-derive dependency
- Update imports and usage of libp2p types and traits
- Refactor NetworkBehaviour implementations to match new API
- Update Identify and Ping behavior configurations
- Adjust event handling in network behaviors
- Fix compiler errors and warnings related to API changes
…nal cbor impl, remove custom one (See: Remove custom cbor request response implementation, replaced with one from library (See: github.com/libp2p/rust-libp2p/pull/3952)
@binarybaron

This comment was marked as outdated.

@binarybaron
Copy link
Author

@Einliterflasche I think this is reasonably distributed across the code base that it'll be possible to work on this concurrently. Feel free to push to this branch.

@binarybaron

This comment was marked as outdated.

See: libp2p/rust-libp2p#3920

This should be backwards compatible because SelectUpgrade should allow older clients to use yamux instead of mplex
@binarybaron
Copy link
Author

binarybaron commented Oct 21, 2024

* [ ]  Update `upgrade` module function calls in `swap/src/network/swap_setup.rs`:
  
  * [ ]  Replace `upgrade::read_length_prefixed` with an alternative
  * [ ]  Replace `upgrade::write_length_prefixed` with an alternative

These functions were removed in this PR. I haven't been able to figure out quite what to replace our current approach with. Probably some combination of asynchronous-codec, quick-protobuf-codec and unsigned-varint.

We should use libp2p/rust-libp2p#4787 as a starting point on how to migrate.

@binarybaron
Copy link
Author

@Einliterflasche Do you want to work on swap/src/network/swap_setup/alice.rs?

I'll work on what I described in the comment above.

@Einliterflasche
Copy link

I partially implemented swap/src/network/swap_setup/alice.rs, I'll have to check if I moved the function bodies correctly. I also fixed some of the import issues. It's down to 27 errors now, though there are two things I don't know how to fix: KeepAlive in network\swap_setup\alice.rs doesn't seem to be exported anywhere, and I commented out NetworkBehaviourEventProcess as well

- Remove connection guards and channel timeout from request handling, dial directly
- Implement retries for quote, swap setup and cooperative redeem requests. Max 60s timeout. Max interval 5s
- Make NewSwap derive Clone to support retrying requests
@binarybaron binarybaron marked this pull request as ready for review November 10, 2024 23:07
@binarybaron binarybaron changed the title refactor(swap): Upgrade libp2p to 0.53.2, harden transfer proof and encrypted signature network protocol refactor(swap): Upgrade libp2p to 0.53.2, reliable retry mechanisms Nov 10, 2024
@binarybaron binarybaron merged commit c027e51 into master Nov 10, 2024
26 of 29 checks passed
Einliterflasche pushed a commit that referenced this pull request Nov 13, 2024
…109)

Our libp2p version is out of date, and we need to tackle the upgrade even though it's a significant undertaking. This'll also fix some other [issues](#95).

- Breaking network protocol change: The libp2p version has been upgraded to 0.53 which includes breaking network protocol changes. ASBs and CLIs will not be able to swap if one of them is on the old version.
- ASB: Transfer proofs will be repeatedly sent until they are acknowledged by the other party. This fixes a bug where it'd seem to Bob as if the Alice never locked the Monero. Forcing the swap to be refunded.
- CLI: Encrypted signatures will be repeatedly sent until they are acknowledged by the other party
- CLI+ASB: Libp2p network errors in request-response protocols are now propagated throught the event loop channels. This allows the caller to retry if an error occurs (e.g timeout)

Closes #101, #95
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.

Retry sending transfer proof
3 participants