fix(legacy_swap): check for existing maker/taker payment before timeout#2283
fix(legacy_swap): check for existing maker/taker payment before timeout#2283
Conversation
Move payment existence check before timeout validation and skip timeout if payment is already sent, as we should proceed to waiting for maker to spend the taker payment.
laruh
left a comment
There was a problem hiding this comment.
Thanks for the fix!
Changes are well-structured and code in general is good to me, I have non mandatory suggestion
|
So this actually fixes the situation (for taker case): |
not sure if i understood the question, but taker can only refund if he removes the TakerPaymentTransactionFailed event from his swap JSON and replaces it with a TakerPaymentSent event and also adds the correct txid and txhash from that particular swap to the event... like this this was the situation from before this change... |
|
I am trying to work out how taker came to situation that he actually sent taker payment but did not log any event about this (to memorise this, it's not clear from the issue description) |
That's the big question, indeed. I first thought the electrums returned a timeout, but sent the tx anyway. But that's not the case, else we would have an error from electrum there in the event and not simply |
if the process is killed after this line https://github.com/KomodoPlatform/komodo-defi-framework/blob/f401497aee55ee8152f96955bd40dd147b8ab88f/mm2src/mm2_main/src/lp_swap/taker_swap.rs#L1581 but before the swap event is written, this could happen. |
mariocynicys
left a comment
There was a problem hiding this comment.
tiny notes. LGTM otherwise
|
@mariocynicys @laruh please review the refactor next week. |
| &self.unique_swap_data()[..], | ||
| ); | ||
|
|
||
| let time_lock = match std::env::var("USE_TEST_LOCKTIME") { |
There was a problem hiding this comment.
Should we not allow this test locktime only if enabled by a cfg feature?
(I guess we tend to make all test code cfg enabled)
There was a problem hiding this comment.
Removed USE_TEST_LOCKTIME occurrences in swaps code completely, and from the whole codebase. Took me some time to make the tests work again but this should make the legacy swap code cleaner. We should look into removing all other env vars in swaps code when we have the time.
|
I added a note why the swap failed on send taker payment and manual swap file editing was required. (PS. I guess, there may be similar issues in other swap steps due to the event not saved) LGTM |
laruh
left a comment
There was a problem hiding this comment.
LGTM!
I have last non blocking suggestion
* dev: (35 commits) fix(crypto): allow non bip39 mnemonics storage (GLEECBTC#2312) fix(legacy_swap): check for existing maker/taker payment before timeout (GLEECBTC#2283) feat(tendermint): validators RPC (GLEECBTC#2310) chore(CI): validate Cargo lock file (GLEECBTC#2309) test(P2P): add test for peer time sync validation (GLEECBTC#2304) fix mm2_p2p dev build (GLEECBTC#2311) update Cargo.lock (GLEECBTC#2308) chore(CI): unlock wasm-pack version (GLEECBTC#2307) add `wasm` feature on WASM for timed-map (GLEECBTC#2306) replace broken rpc link (GLEECBTC#2305) chore(eth-websocket): remove some unnecessary wrappers (GLEECBTC#2291) improvement(CI): switch to proper rust caching (GLEECBTC#2303) fix(wasm): add test-ext-api feature to mm2_main and mm2_bin_lib tomls (GLEECBTC#2295) chore(ci): Update docker build for wasm (GLEECBTC#2294) chore(p2p): follow-up nits (GLEECBTC#2302) feat(p2p): ensure time synchronization in the network (GLEECBTC#2255) bump libp2p (GLEECBTC#2296) chore(adex-cli): use "Komodo DeFi Framework" name in adex_cli (GLEECBTC#2290) chore(ctx): replace gstuff constructible with oncelock (GLEECBTC#2267) don't rely on core (GLEECBTC#2289) ...
…ut (#2283) This commit moves payment existence check in maker_payment/send_taker_payment before timeout validation and skips timeout if payment is already sent, as the taker swap should proceed to waiting for maker to spend the taker payment.
…ut (#2283) This commit moves payment existence check in maker_payment/send_taker_payment before timeout validation and skips timeout if payment is already sent, as the taker swap should proceed to waiting for maker to spend the taker payment.
…ut (#2283) This commit moves payment existence check in maker_payment/send_taker_payment before timeout validation and skips timeout if payment is already sent, as the taker swap should proceed to waiting for maker to spend the taker payment.
This PR moves payment existence check in
maker_payment/send_taker_paymentbefore timeout validation and skips timeout if payment is already sent, as the taker swap should proceed to waiting for maker to spend the taker payment.Should fix #2136 , but we are still not aware why the electrum request doesn't timeout.