Fix orders disappearing from orderbook#1046
Conversation
|
@shamardy could you please merge the |
sergeyboyko0791
left a comment
There was a problem hiding this comment.
Thanks for this fast fix!
Please answer my comments :)
| } | ||
| } | ||
|
|
||
| fn remove_protocol_info(&self) -> Self { |
There was a problem hiding this comment.
How about renaming this function to without_protocol_info or clone_without_protocol_info?
It may confuse a bit, because remove means changing itself.
| }, | ||
| }; | ||
| let order_bytes = rmp_serde::to_vec(&order).expect("Serialization should never fail"); | ||
| let order_bytes = rmp_serde::to_vec(&order.remove_protocol_info()).expect("Serialization should never fail"); |
There was a problem hiding this comment.
Correct me please if I'm wrong. I think there can be a not bad but not good case if we don't store the base/rel protocol info in a memory_db.
Let's there are three nodes in a network: our light node A, another light node B, seed node S.
Bbroadcasts a few Maker orders to the network.AandSsuccessfully sync them by process_keep_alive.Agoes offline.Bbroadcasts a new Maker order,Ssyncs it, therefore stores the order inOrdermatch::memory_dbon process_trie_delta. Note that the order is stored without protocol info since we usermp_serde::to_vec(&order.remove_protocol_info()).Aconnects to theSand requests the diff of the orderbook on process_orders_keep_alive fromSnodeSextracts the missed order without protocol info and send it toAAgenerates and broadcasts a Taker order to match theB's Maker order BUT without the protocol info.- I guess,
Bdoesn't match the Taker order since there are no base/rel protocol infos (not sure about it)
There was a problem hiding this comment.
I think it will match because in point no. 6 A will generate and broadcast a Taker order with its own protocol info and on the maker side B will check if it can match with A or not. So A doesn't use protocol info. of B in TakerRequest, A only sends its own protocol info to let B know if it's an old node when protocol info of A is None thus not matching B Segwit orders only in this case.
I will try to add a test case for the above scenario to check it but it might be tricky disconnecting and connecting A again in testing.
There was a problem hiding this comment.
Have you tried to reproduce this? If you are busy now, I can do this)
There was a problem hiding this comment.
As we discussed with @shamardy, it may be difficult to reproduce the case above, because the A node should be disconnected without restarting it.
@cipig @tonymorony could you please try to reproduce this case?
|
@sergeyboyko0791 Before this last commit aefe460, Segwit orders were not sent to the old nodes in response to I suggest removing I think this is the only viable solution as I checked if adding versions to differentiate messages from old and new nodes like here https://github.com/KomodoPlatform/atomicDEX-API/blob/aefe4600a32da0c99c890aee4bfe86f8c5279e8a/mm2src/lp_ordermatch.rs#L429 to one of As for the last commit aefe460, it has no problems except that Legacy address will be shown in the orderbook instead of Segwit if the |
I'd rather vote for this solution - to remove
It will look like a bug if orders that actually support Segwit addresses, will contain Legacy or Segwit addresses depending on whether the order was received through What do you think @tonymorony? |
|
@sergeyboyko0791 I have an idea for viewing the correct address for Segwit maker orders that we can open an issue with once this is merged so we can discuss it with @artemii235 in the future. It involves adding the |
sergeyboyko0791
left a comment
There was a problem hiding this comment.
LGTM! let's merge it into dev :)
| ) | ||
| .await; | ||
| } | ||
| maker_order_created_p2p_notify(ctx, &maker_order).await; |
There was a problem hiding this comment.
@shamardy Could you please clarify, what was the reason to remove if let Ok(Some((base, rel))) = find_pair(&ctx, &maker_order.base, &maker_order.rel).await? It opens a possibility to have an unmatchable maker order in the orderbook unless the coins are activated.
fixes #1044
This fixes pair trie to be consistent across old and new nodes preventing inconsistent behavior in keeping orders alive