-
Notifications
You must be signed in to change notification settings - Fork 94
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(orders): fix cancel order race condition using time-based cache #2232
Conversation
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.
took a quick look and tried the fix on the electrum connections branch (since it exemplifies the issue 1000x for some reason).
I fear though that nodes don't receive messages at the same time and we have some node getting the message AFTER (because some other node received the cancellation late enough that it's still in its gossibpub cache) the cancellation cache timed out and it would consider it a new order creation.
can't we enforce in-order-delivery somehow on p2p layer? or at leas t only causal delivery.
Received this message from @cipig
Will look into it after fixing the review comments |
About this #2232 (comment) , only reason for delay is holding the orderbook lock for some time, I can move the new recently cancelled map to |
How is this PR related with those logs 🤔 |
I can see that Edit: the log |
Done here 14f7f34 |
@onur-ozkan @mariocynicys all issues raised in review comments should have been fixed. Please give this another look when you have the time. |
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.
Last notes from my side:
Sorry about more confusion I am about to create @mariocynicys @onur-ozkan but I will move recently cancelled map back to orderbook struct and handle it in both |
…dermatchContext`" This reverts commit 14f7f34.
Reverted the moving of recently cancelled to it's own lock here e0e5d41 and fixed this #2232 (comment) here cdfd809. |
Now |
I understand why, will fix it. The below claim komodo-defi-framework/mm2src/mm2_main/src/lp_ordermatch.rs Lines 380 to 381 in 860544f
|
…r_expired_entries` function
…ellation_received_before_creation`
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.
Final notes from my side, LGTM other than these notes:
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.
Last points, LGTM otherwise :)
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
* 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)
* 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)
* 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)
This PR addresses the issue where cancelled orders can sometimes remain in the orderbook due to P2P message caching and out-of-order message delivery.
Changes:
maker_order_cancelled_p2p_notify
to a location where it was previously missing, this needs careful review. Old PR that added the maker order deletion without notifying Fix orders "leak" due to race condition. #1178 and the reason for the old PR order leakage #1173 (comment)The solution works as follows:
This approach provides a simple fix for the immediate issue while avoiding major changes to the P2P layer or gossipsub protocol. It prevents cancelled orders from reappearing in the orderbook due to delayed or out-of-order message delivery.
Next steps:
potentially fixes #1726