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

[CT-712] send fill amount updates for reverted operations in prepare check state #1240

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions protocol/x/clob/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,26 @@ func PrepareCheckState(
// For orders that are filled in the last block, send an orderbook update to the grpc streams.
if keeper.GetGrpcStreamingManager().Enabled() {
allUpdates := types.NewOffchainUpdates()
orderIdsToSend := make(map[types.OrderId]bool)

// Send an update for reverted local operations.
for _, operation := range localValidatorOperationsQueue {
if match := operation.GetMatch(); match != nil {
orderIdsToSend[match.GetMatchOrders().TakerOrderId] = true

for _, fill := range match.GetMatchOrders().Fills {
orderIdsToSend[fill.MakerOrderId] = true
}
}
}

// Send an update for orders that were proposed.
for _, orderId := range processProposerMatchesEvents.OrderIdsFilledInLastBlock {
orderIdsToSend[orderId] = true
Copy link
Contributor

Choose a reason for hiding this comment

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

just double checking when we replay the orders we will send keeper.MemClob.GetOrderbookUpdatesForOrderUpdate(ctx, orderId) during the regular place order flow right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup -

for orders in processProposerMatchesEvents.OrderIdsFilledInLastBlock, the intention is to send an update for orders that are included by BP but not in local queue.

for orders in local operations queue, the intention is to send an update for orders that are still on the book (link). replay would fail b/c the order already exists, so no updates are sent.

}

// Send update.
for orderId := range orderIdsToSend {
if _, exists := keeper.MemClob.GetOrder(ctx, orderId); exists {
orderbookUpdate := keeper.MemClob.GetOrderbookUpdatesForOrderUpdate(ctx, orderId)
allUpdates.Append(orderbookUpdate)
Expand Down
Loading