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

fix(swaps): no remote fail when sending payment #1761

Merged
merged 1 commit into from
Aug 6, 2020

Conversation

sangaman
Copy link
Collaborator

This prevents the maker from failing a swap due to a swap failed packet received from the taker if the maker has already started sending its payment. This is because the taker may still claim the payment, and the maker needs to continue monitoring its outgoing payment until it is certain that the payment cannot be claimed.

Fixes #1749.

@sangaman sangaman added bug Something isn't working swaps labels Jul 27, 2020
@sangaman sangaman requested a review from a user July 27, 2020 14:24
@sangaman sangaman self-assigned this Jul 27, 2020
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good @sangaman. As a follow-up what do you think about making the this.failDeal explicit and by default not failing the deal? At the moment it's the opposite.

@sangaman
Copy link
Collaborator Author

The changes look good @sangaman. As a follow-up what do you think about making the this.failDeal explicit and by default not failing the deal? At the moment it's the opposite.

I'll rearrange the logic in a separate PR so as to not hold this one up.

@kilrau
Copy link
Contributor

kilrau commented Jul 28, 2020

Created that follow-up issue.

@ghost
Copy link

ghost commented Jul 28, 2020

Been restarting the builds for several hours now and they seem to be failing with random errors.

@sangaman
Copy link
Collaborator Author

Been restarting the builds for several hours now and they seem to be failing with random errors.

Same for me... I'm going to dig into this to see if this change somehow breaks the security tests. Getting context deadline exceeded there (sometimes) so it could be hanging waiting for a swap to fail that doesn't fail due to this change perhaps?

@sangaman
Copy link
Collaborator Author

I'm testing a fix for the simulation tests. The tests were expecting the maker to fail due to SwapTimedOut, which is actually not desirable and what this PR is intended to fix.

@sangaman sangaman force-pushed the swaps/no-remote-fail-sendingpayment branch 2 times, most recently from d510edf to 8d689b0 Compare July 29, 2020 04:37
@sangaman
Copy link
Collaborator Author

I believe I straightened out the simulation tests. However, it appears that I had to revert the security sim test changes from c9be219. The maker should not be canceling his incoming htlc until his outgoing htlc has expired, that's what this PR is fixing.

@kilrau
Copy link
Contributor

kilrau commented Jul 29, 2020

I believe I straightened out the simulation tests. However, it appears that I had to revert the security sim test changes from c9be219. The maker should not be canceling his incoming htlc until his outgoing htlc has expired, that's what this PR is fixing.

That sounds quite right. Can you give check the simtest changes once more? @erkarl

@raladev raladev self-requested a review July 29, 2020 11:11
@sangaman sangaman force-pushed the swaps/no-remote-fail-sendingpayment branch from 8d689b0 to 94a12d4 Compare July 29, 2020 12:41
@kilrau kilrau requested a review from a user July 29, 2020 14:41
ghost
ghost previously approved these changes Jul 29, 2020
@raladev
Copy link
Contributor

raladev commented Jul 29, 2020

There is still no monitoring continuation for maker side after maker's xud restart.

Steps:

  1. place 9 sell ETH/BTC orders as a maker, fill them all by 1 order of a taker -> most of swaps failed (29/07/2020 15:33:58.510 in maker's log)
  2. monitoring messages in maker logs each 5 mins (29/07/2020 15:47:33.970 in maker's log)
  3. restart maker's xud (29/07/2020 16:01:13.444 in maker's log)
  4. wait -> No monitor messages
  5. shutdown both envs -> swap err messages in the taker's xud log after disconnecting from all peers. (29/07/2020 16:17:41.217 in taker's log)

Screenshot from 2020-07-29 19-36-15
Screenshot from 2020-07-29 19-36-27

monitor_xud_taker.log
monitor_xud_maker.log

maker's xud db - https://gofile.io/d/7GKTmK
taker's xud db - https://gofile.io/d/uqMD6s

@ghost
Copy link

ghost commented Aug 6, 2020

Also needs a rebase.

This prevents the maker from failing a swap due to a swap failed packet
received from the taker if the maker has already started sending its
payment. This is because the taker may still claim the payment, and the
maker needs to continue monitoring its outgoing payment until it is
certain that the payment cannot be claimed.

Fixes #1749.
@sangaman sangaman force-pushed the swaps/no-remote-fail-sendingpayment branch from 94a12d4 to dc7e4d2 Compare August 6, 2020 20:34
@sangaman
Copy link
Collaborator Author

sangaman commented Aug 6, 2020

There is still no monitoring continuation for maker side after maker's xud restart.

This is very helpful but after some investigation I'm pretty sure this is a separate issue from this PR and the issue it indends to fix. It's due to the fact that a connext sendpayment call can "fail" while the payment is still in limbo. It's actually somewhat related to #1794, the solution is to not fail the deal when a sendpayment calls, and to have a mechanism within swaps to monitor swaps that are still in an active status even after they've timed out and even after our attempts to send payment have failed, up until we get confirmation that all HTLCs are canceled/expired. Everything in SwapRecovery will then only be used for when xud crashes or is restarted while there are active swaps.

@sangaman sangaman merged commit 29ffcf3 into master Aug 6, 2020
@sangaman sangaman deleted the swaps/no-remote-fail-sendingpayment branch August 6, 2020 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working swaps
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Swap recovery stopped monitoring active payment
3 participants