Skip to content

fix(legacy-swap): taker failed spend maker payment marked as failed#2199

Merged
shamardy merged 31 commits intodevfrom
taker-failed-swaps-marked-successful
Oct 4, 2024
Merged

fix(legacy-swap): taker failed spend maker payment marked as failed#2199
shamardy merged 31 commits intodevfrom
taker-failed-swaps-marked-successful

Conversation

@laruh
Copy link
Copy Markdown

@laruh laruh commented Aug 26, 2024

related to #2175 (comment)

To fix issue where taker doesnt wait for maker payment spend tx was confirmed we added two new events:

  • "MakerPaymentSpendConfirmed": successful event, which goes after "MakerPaymentSpent"
    Note: MakerPaymentSpent event means that broadcasted tx taker spends maker payment just wasn't reverted
  • "MakerPaymentSpendConfirmFailed": error event, means that taker spend maker payment transaction confirmation was failed.

@laruh
Copy link
Copy Markdown
Author

laruh commented Aug 28, 2024

Second problem solving approach

If we wouldn't like to do changes in legacy taker swap events/logic and increase backward incompatibility risks, there is an alternative. We can add maker payment spend confirmation right after send_taker_spends_maker_payment in spend_maker_payment taker swap operation.

https://github.com/KomodoPlatform/komodo-defi-framework/blob/5c47ef0f53fce5eb83afc727a5b685a663279f40/mm2src/mm2_main/src/lp_swap/taker_swap.rs#L1787-L1812

If confirmation failed, then also return swap finish command and MakerPaymentSpendFailed event

                return Ok((Some(TakerSwapCommand::Finish), vec![
                    TakerSwapEvent::MakerPaymentSpendFailed(ERRL!("{}", err.get_plain_text_format()).into()),
                ]));

MakerPaymentSpendFailed is not actually correct event in the case of failed maker payment spend confirmation, but in this way we dont do changes in Taker commands and events logic.

In comparison, Maker has taker payment spend confirmation events in MakerSwapEvent:
https://github.com/KomodoPlatform/komodo-defi-framework/blob/5c47ef0f53fce5eb83afc727a5b685a663279f40/mm2src/mm2_main/src/lp_swap/maker_swap.rs#L1646-L1648

@laruh
Copy link
Copy Markdown
Author

laruh commented Aug 30, 2024

Solved with second approach in this pr #2206

UPD: opened again as we decided to test both approaches #2206 (comment)

one problem with adding confirmation to SpendMakerPayment step is that GUI will not have the tx hash to show to user until tx is confirmed, users like to check tx on chain while it's awaiting confirmations

This pr approach could be preferable

@laruh laruh closed this Aug 30, 2024
@laruh laruh reopened this Sep 5, 2024
@shamardy
Copy link
Copy Markdown
Collaborator

shamardy commented Sep 6, 2024

@laruh this is still draft, should I review it? I want to check it so that I can close the other PR if there are no problems with the approach here.

@laruh
Copy link
Copy Markdown
Author

laruh commented Sep 8, 2024

@laruh this is still draft, should I review it? I want to check it so that I can close the other PR if there are no problems with the approach here.

Its almost r2r, I just wanted to fix these notes #2206 (review) in other approach and cherry pick commit to this branch, as both branches would have the same review notes. (already fixed this b2446b9, just confirmation number is left)

@laruh laruh marked this pull request as ready for review September 8, 2024 02:07
@laruh laruh removed the in progress label Sep 8, 2024
@laruh laruh force-pushed the taker-failed-swaps-marked-successful branch from cd75bd0 to aed8d4c Compare September 27, 2024 09:16
@laruh laruh force-pushed the taker-failed-swaps-marked-successful branch from d2fd10f to 5ce137f Compare September 29, 2024 12:20
dimxy
dimxy previously approved these changes Oct 3, 2024
Copy link
Copy Markdown
Collaborator

@dimxy dimxy left a comment

Choose a reason for hiding this comment

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

LGTM

shamardy
shamardy previously approved these changes Oct 4, 2024
Copy link
Copy Markdown
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

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

LGTM but for one nit!

Please open docs issue and add To Test comment to the PR opening comment.

@shamardy shamardy requested a review from cipig October 4, 2024 08:54
@shamardy
Copy link
Copy Markdown
Collaborator

shamardy commented Oct 4, 2024

@cipig you tested this #2206 but we opted for a new event instead and implemented in this PR. Can you please check if the issue is resolved here?

@laruh
Copy link
Copy Markdown
Author

laruh commented Oct 4, 2024

Please open docs issue and add To Test comment to the PR opening comment.

GLEECBTC/komodo-docs-mdx#351

@shamardy shamardy merged commit 359cb5c into dev Oct 4, 2024
@shamardy shamardy deleted the taker-failed-swaps-marked-successful branch October 4, 2024 10:56
dimxy pushed a commit that referenced this pull request Oct 4, 2024
* dev:
  fix(orders): fix cancel order race condition using time-based cache (#2232)
  fix(legacy-swap): taker failed spend maker payment marked as failed (#2199)
  chore(adex-cli): deprecate adex-cli (#2234)
  feat(new-RPC): connection healthcheck implementation for peers  (#2194)
  fix(proxy-signature): add message lifetime overflows (#2233)
  feat(CI): handle remote files in a safer way (#2217)
  chore(doc): update issue address in README (#2227)
  fix(merge): remove duplicated db_root function (#2229)
  feat(wallets): add `get_wallet_names` rpc (#2202)
  chore(tests): don't use `.wait()` and use `block_on` instead (#2220)
  fix(native-rpc): remove escaped response body (#2219)
  fix(clippy): fix coins mod clippy warnings in wasm (#2224)
  feat(core): handling CTRL-C signal with graceful shutdown (#2213)
  docs(README): fix typos (#2212)
  remove the non-sense arguments (#2216)
  fix(db): stop creating the all-zeroes dir on KDF start (#2218)
dimxy pushed a commit that referenced this pull request Oct 4, 2024
* dev:
  fix(orders): fix cancel order race condition using time-based cache (#2232)
  fix(legacy-swap): taker failed spend maker payment marked as failed (#2199)
  chore(adex-cli): deprecate adex-cli (#2234)
  feat(new-RPC): connection healthcheck implementation for peers  (#2194)
  fix(proxy-signature): add message lifetime overflows (#2233)
  feat(CI): handle remote files in a safer way (#2217)
  chore(doc): update issue address in README (#2227)
  fix(merge): remove duplicated db_root function (#2229)
  feat(wallets): add `get_wallet_names` rpc (#2202)
  chore(tests): don't use `.wait()` and use `block_on` instead (#2220)
  fix(native-rpc): remove escaped response body (#2219)
  fix(clippy): fix coins mod clippy warnings in wasm (#2224)
  feat(core): handling CTRL-C signal with graceful shutdown (#2213)
  docs(README): fix typos (#2212)
  remove the non-sense arguments (#2216)
  fix(db): stop creating the all-zeroes dir on KDF start (#2218)
dimxy pushed a commit that referenced this pull request Oct 17, 2024
* dev:
  fix(cosmos): fix tx broadcasting error (#2238)
  chore(solana): remove solana implementation (#2239)
  chore(cli): remove leftover subcommands from help message (#2235)
  fix(orders): fix cancel order race condition using time-based cache (#2232)
  fix(legacy-swap): taker failed spend maker payment marked as failed (#2199)
  chore(adex-cli): deprecate adex-cli (#2234)
  feat(new-RPC): connection healthcheck implementation for peers  (#2194)
  fix(proxy-signature): add message lifetime overflows (#2233)
  feat(CI): handle remote files in a safer way (#2217)
  chore(doc): update issue address in README (#2227)
  fix(merge): remove duplicated db_root function (#2229)
  feat(wallets): add `get_wallet_names` rpc (#2202)
  chore(tests): don't use `.wait()` and use `block_on` instead (#2220)
  fix(native-rpc): remove escaped response body (#2219)
  fix(clippy): fix coins mod clippy warnings in wasm (#2224)
  feat(core): handling CTRL-C signal with graceful shutdown (#2213)
  docs(README): fix typos (#2212)
  remove the non-sense arguments (#2216)
  fix(db): stop creating the all-zeroes dir on KDF start (#2218)
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.

4 participants