-
Notifications
You must be signed in to change notification settings - Fork 222
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
Detect unmatched swaps #745
Comments
probably as good as can be done with current limitations. after timeleft seconds are elapsed if the aliceid didnt get any events, that swap is likely not going anywhere. |
We get What logic are you using internally? I'm assuming if
What are the current limitations? We need to make sure this is accurate. It's going to be really bad if the UI shows the swap as not matched but mm executes the trade. |
the request event is what is sent out, so you should see that. to get a trade, you need to get back at least one requested all that has to happen for a swap to commence. If there is no requested that comes back within the timelimit, the swap is not going to happen. however as soon as you are getting requested messages, you should now have requestid/quoteid and if you see a connect message that your node sent out, you are just waiting on bob to respond. in such cases, bob can respond later than the timeleft as it is considered a swap negotiation in progress. it would be best to use swapstatus(requestid, quoteid) as soon as those fields are available as internally it switches to a different process to track swaps. there is a 2 minutes time from the connect message to a swap being abandoned, you should see a "failed" message I know you want this to all be nice and simple, but the reality is that it is a messy and unpredictable process... |
What do you mean by "requested"? For a successful trade I'm not seeing a message with a Are you referring to
So in those cases, when swap negotiation is in progress, are we guaranteed to receive a failed message if something goes wrong? Or if bob misbehaves are there things we need to handle that mm won't notify us of? |
I am adding uuid to all trade related JSON, hopefully when that works it will solve all these related issues |
The uuid has helped loads with tracking the swaps, however it doesn't resolve the failed swap issue. When we place a swap we set it as "pending". On future messages we update the status. However if a swap never gets matched, we don't get new messages to allow us to update the state so it stays in our UI as "pending" forever. Can you provide concise steps on how we can handle this and correctly update failed swaps.
So if we don't have the "requested" message before
So if Is that the correct logic for accurately detecting failures? |
I think as each message comes in, extend the timeout by 2 minutes. |
Is that the logic you're using internally? We need it to be identical so there's no possibility of the UI swap state differing from the mm swap state.
So after those two minutes since |
@jl777 It seems there are a lot of heuristics needed to detect a failed swap. I think it would be better for marketmaker to emit a failed event, based on the heuristics you've mentioned, than for every app to try to imitate it and get it subtly wrong. |
other than the one edge case so far, the failed messages invariably mean the swap failed. It would be too major of a change to overhaul the entire swap negotiation and swap processing code to eliminate this one edge case. Of course, if you are able to describe to me how exactly I can do this safely, then I would be willing to try. Last time we tried to do something I felt was too dangerous, it turned out I was right. Will this time be different? |
@lukechilds since this is a p2p system, the other side is not guaranteed to follow any specific timing. The current timeouts are 2 minutes and 5 minutes depending on where in the process, but that is subject to change. I think if you had the logic of "uuid got some change" to push back the expiration it would be a very good heuristic. Then after some GUI determined amount of time if the swapstatus also says it is finished, then it is finished. if a uuid has activity of any kind, it isnt finished. |
I think there may be some misunderstandings here.
This issue is completely unrelated to the failed/completed edge case in #756. We are talking about how we can detect unmatched swaps, not failed swaps. e.g If it doesn't transition from pending to matched, we need to show the trade as failed.
Regarding the You must have some sort of internal logic that decides when a pending trade has expired and can no longer be matched. Whenever that happens if you could send a message over the socket (to our GUI not to other peers) that would instantly solve the issue, prevent the chance of the GUI going out of sync with mm and wouldn't require any changes to swap negotiation. This would be the ideal solution, but if that's not possible then we can try and replicate your behaviour as close as possible.
So if these timeouts are going to change would it be possible to maybe get the time to wait for the next message in each message? So every single message we get, we update to a new expired timestamp from that message, then if we ever hit the timestamp we know it's timed out. This would be a backwards compatible change and give you the freedom to change the timeout amounts without breaking GUIs. For example the socket message (and response from {
uuid: 923572309092387598347528734,
expires: 1523532765,
...
} after
That's not the problem, it's not about detecting when it's finished. It's detecting if it never matched. If a swap doesn't get matched it will never have a swapstatus of "finished", but that doesn't mean it's pending forever. |
Sorry, I misunderstood. |
Awesome, thanks! Ping me when it's ready to test.
Why don't you think it'll be 100%? Just need to know if there are any edge cases I should look out for. |
just a feeling I have. this sort of thing isnt 100% as we have different threads running different parts, so while one thread is thinking one thing, the other thread sees a different state. I didnt want to put locks around it as that would really increase latency and the cost is the occasional false positive |
updated with a special failed message -9999 but it might give spurious events if after other messages have come in. Not sure it will, but not sure it wont. However for the state of having issued a buy/sell and it expires, it should be pretty reliable indicator. I would set a timer after you get this event and if nothing else comes in after 10 seconds, it would seem pretty safe that nothing ever will |
Appears to be working great, thanks James!
We've already implemented a 10 min delay after a |
@artemii235 Any chance we could get a new build with these changes in? |
@lukechilds Hi, I merged changes from dev branch and waiting for CI build to pass, if everything is fine new release will be published in 30 minutes. |
@artemii235 Perfect, thanks! |
@lukechilds https://github.com/artemii235/SuperNET/releases/tag/v1.0.141 - here is new release, additional tests might be required as only BEER/ETH swap was done by CI. |
There is no event emitted on the socket for an unmatched swap. Are you able to add this?
If not, what's the correct way for us to detect it? When we place the order we get
timeleft
in the response. Aftertimeleft
seconds have passed we could check if theconnected
event has been emitted yet.Is that the correct event to check for? Would that be reliable?
The text was updated successfully, but these errors were encountered: