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

Add insert and delete APIs to orderbook WS #2418

Merged
merged 1 commit into from
Apr 15, 2024
Merged

Conversation

luckysori
Copy link
Contributor

@luckysori luckysori commented Apr 13, 2024

@luckysori luckysori requested review from bonomat and holzeis April 13, 2024 04:38
@luckysori luckysori self-assigned this Apr 13, 2024
@luckysori luckysori force-pushed the feat/orderbook-ws-api branch from d31ad05 to 5ce995d Compare April 13, 2024 04:58
@luckysori luckysori force-pushed the feat/orderbook-ws-api branch from 5ce995d to 7c6f8ee Compare April 13, 2024 05:40
Copy link
Contributor

@bonomat bonomat left a comment

Choose a reason for hiding this comment

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

I love the feature, but I'm wondering if we have a mxiup with trader_order_id and order_id 🙈

})
.await??;

let _ = state.tx_orderbook_feed.send(Message::DeleteOrder(order_id));
Copy link
Contributor

Choose a reason for hiding this comment

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

order_id is the trader_order_id right? If so, the traders receiving the DeleteOrder msg might not know what todo with this.

The user connected to the websocket shouldn't know about the trader_order_id, so did this ever work? 🙈

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe I made a mistake. I'll test it again locally.

Copy link
Contributor

@bonomat bonomat Apr 14, 2024

Choose a reason for hiding this comment

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

No, you didn't it's been like that before. Maybe this was a reason why we saw outdated orders on the client side...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I've been thinking about it and I don't see the problem with those warnings we get on the app.

As far as I can tell, what happens is:

  1. The maker generates an order.
  2. The maker deletes the order.
  3. The app starts and connects to the coordinator's WS, getting an AllOrders message that does not include the deleted order.
  4. The WS still sends the app the corresponding DeleteOrder message from step 2.

I don't understand why the "outdated" message is delivered to the app, but I think we should demote the WARN to DEBUG because I think this is harmless.

Copy link
Contributor

Choose a reason for hiding this comment

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

I looked into it and we are actually sending the trader_order_id to all users 🙈 It's probably not an issue, but I think it wasn't meant to be used like that:

Here are we mapping the trader_order_id from the db to order.id for the orders we are returning to the users.

id: value.trader_order_id,

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand why the "outdated" message is delivered to the app, but I think we should demote the WARN to DEBUG because I think this is harmless.

Imho this happens because we are here also clinsing outdated orders here and we might have a race condition where the maker deletes an order and this is run

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked into it and we are actually sending the trader_order_id to all users 🙈 It's probably not an issue, but I think it wasn't meant to be used like that:

Here are we mapping the trader_order_id from the db to order.id for the orders we are returning to the users.

id: value.trader_order_id,

Yeah, that makes sense.

Did we ever have an order ID that wasn't the trader order ID though? I can't find another one.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, on DB level we have a different one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, but that one has only ever been used internally:

    // this id is only internally but needs to be here or diesel complains
    #[allow(dead_code)]
    pub id: i32,

@luckysori luckysori added this pull request to the merge queue Apr 15, 2024
Merged via the queue into main with commit 7579161 Apr 15, 2024
22 checks passed
@luckysori luckysori deleted the feat/orderbook-ws-api branch April 15, 2024 01:10
bonomat pushed a commit that referenced this pull request Apr 15, 2024
Add insert and delete APIs to orderbook WS
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.

2 participants