Skip to content
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

cmd/debug: add DeleteOrder command #358

Merged
merged 4 commits into from
Apr 19, 2022
Merged

cmd/debug: add DeleteOrder command #358

merged 4 commits into from
Apr 19, 2022

Conversation

positiveblue
Copy link
Contributor

Enable deleting orders in the local db using the debug cli. This can be used to clean the local db in case it gets out of sync with the server.

DANGER: if the user deletes an order from the local db and that order exists in the server, the user will get disconnected when that order matches (and won't be able to trade). The only solution then is to nuke the local db, restore the account and recreate the orders.

unblocks #357

@@ -770,7 +770,8 @@ func (s *Server) syncLocalOrderState() error {
context.Background(), orderNonce,
)
if err != nil {
return fmt.Errorf("unable to fetch order state: %v", err)
return fmt.Errorf("unable to fetch order(%v): %v",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed so the user knows which ones are the offender orders

@positiveblue positiveblue requested a review from guggero April 13, 2022 20:54
Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me. Though I wonder if updating the state to StateCanceled wouldn't also solve the issue for the user and fail a bit more gracefully if the order was ever matched?

@positiveblue
Copy link
Contributor Author

I think it would not. The problem this is is trying to solve is when the user has some orders in the local db that the server does not know about so those ones need to be deleted (the order sync fails). Updating the status to Cancel would make the client fail during the start up process too (unable to sync that order anyway).

This is just an extra debug subcommand that we can use. It would be nice to have a reconciliation process during the start ups:

  • mark up local invoices that do not exist in the server side as missing
  • fetch orders that exist in the server but not in the local db
  • overwrite local status with the one from the server for existing invoices (what we do now)

@Roasbeef
Copy link
Member

It would be nice to have a reconciliation process during the start ups:

Agreed, we do something similar today when it comes to syncing up batches, but don't do this for orders. The great part about this design is that the server can't spoof orders since they're all signed by the trader.

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🛤

Should also get some basic itest coverage on the server side as well.

@guggero guggero merged commit 5ea41c9 into master Apr 19, 2022
@guggero guggero deleted the missing-orders branch April 19, 2022 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants