-
Notifications
You must be signed in to change notification settings - Fork 98
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(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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
but before the swap event is written, this could happen. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I have last non blocking suggestion
* dev: (35 commits) fix(crypto): allow non bip39 mnemonics storage (KomodoPlatform#2312) fix(legacy_swap): check for existing maker/taker payment before timeout (KomodoPlatform#2283) feat(tendermint): validators RPC (KomodoPlatform#2310) chore(CI): validate Cargo lock file (KomodoPlatform#2309) test(P2P): add test for peer time sync validation (KomodoPlatform#2304) fix mm2_p2p dev build (KomodoPlatform#2311) update Cargo.lock (KomodoPlatform#2308) chore(CI): unlock wasm-pack version (KomodoPlatform#2307) add `wasm` feature on WASM for timed-map (KomodoPlatform#2306) replace broken rpc link (KomodoPlatform#2305) chore(eth-websocket): remove some unnecessary wrappers (KomodoPlatform#2291) improvement(CI): switch to proper rust caching (KomodoPlatform#2303) fix(wasm): add test-ext-api feature to mm2_main and mm2_bin_lib tomls (KomodoPlatform#2295) chore(ci): Update docker build for wasm (KomodoPlatform#2294) chore(p2p): follow-up nits (KomodoPlatform#2302) feat(p2p): ensure time synchronization in the network (KomodoPlatform#2255) bump libp2p (KomodoPlatform#2296) chore(adex-cli): use "Komodo DeFi Framework" name in adex_cli (KomodoPlatform#2290) chore(ctx): replace gstuff constructible with oncelock (KomodoPlatform#2267) don't rely on core (KomodoPlatform#2289) ...
This PR 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.Should fix #2136 , but we are still not aware why the electrum request doesn't timeout.