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

bug: Internalize FNS logic to stage FinalizeBlock events #2399

Merged
merged 3 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StreamOrderbookFill, StreamOrderbookFillSDKType } from "./query";
import { StreamOrderbookFill, StreamOrderbookFillSDKType, StreamOrderbookUpdate, StreamOrderbookUpdateSDKType } from "./query";
import { StreamSubaccountUpdate, StreamSubaccountUpdateSDKType } from "../subaccounts/streaming";
import * as _m0 from "protobufjs/minimal";
import { DeepPartial } from "../../helpers";
Expand All @@ -7,18 +7,21 @@ import { DeepPartial } from "../../helpers";
export interface StagedFinalizeBlockEvent {
orderFill?: StreamOrderbookFill;
subaccountUpdate?: StreamSubaccountUpdate;
orderbookUpdate?: StreamOrderbookUpdate;
}
/** StagedFinalizeBlockEvent is an event staged during `FinalizeBlock`. */

export interface StagedFinalizeBlockEventSDKType {
order_fill?: StreamOrderbookFillSDKType;
subaccount_update?: StreamSubaccountUpdateSDKType;
orderbook_update?: StreamOrderbookUpdateSDKType;
}

function createBaseStagedFinalizeBlockEvent(): StagedFinalizeBlockEvent {
return {
orderFill: undefined,
subaccountUpdate: undefined
subaccountUpdate: undefined,
orderbookUpdate: undefined
};
}

Expand All @@ -32,6 +35,10 @@ export const StagedFinalizeBlockEvent = {
StreamSubaccountUpdate.encode(message.subaccountUpdate, writer.uint32(18).fork()).ldelim();
}

if (message.orderbookUpdate !== undefined) {
StreamOrderbookUpdate.encode(message.orderbookUpdate, writer.uint32(26).fork()).ldelim();
}

return writer;
},

Expand All @@ -52,6 +59,10 @@ export const StagedFinalizeBlockEvent = {
message.subaccountUpdate = StreamSubaccountUpdate.decode(reader, reader.uint32());
break;

case 3:
message.orderbookUpdate = StreamOrderbookUpdate.decode(reader, reader.uint32());
break;

default:
reader.skipType(tag & 7);
break;
Expand All @@ -65,6 +76,7 @@ export const StagedFinalizeBlockEvent = {
const message = createBaseStagedFinalizeBlockEvent();
message.orderFill = object.orderFill !== undefined && object.orderFill !== null ? StreamOrderbookFill.fromPartial(object.orderFill) : undefined;
message.subaccountUpdate = object.subaccountUpdate !== undefined && object.subaccountUpdate !== null ? StreamSubaccountUpdate.fromPartial(object.subaccountUpdate) : undefined;
message.orderbookUpdate = object.orderbookUpdate !== undefined && object.orderbookUpdate !== null ? StreamOrderbookUpdate.fromPartial(object.orderbookUpdate) : undefined;
return message;
}

Expand Down
1 change: 1 addition & 0 deletions proto/dydxprotocol/clob/streaming.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ message StagedFinalizeBlockEvent {
oneof event {
StreamOrderbookFill order_fill = 1;
dydxprotocol.subaccounts.StreamSubaccountUpdate subaccount_update = 2;
StreamOrderbookUpdate orderbook_update = 3;
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Missing handling for orderbook_update in event switches

The new StreamOrderbookUpdate orderbook_update = 3; has been added to the StagedFinalizeBlockEvent message, but the corresponding handling in switch statements is missing. Please update the following file to handle the new event type:

  • protocol/streaming/full_node_streaming_manager.go: Add a case for *clobtypes.StagedFinalizeBlockEvent_OrderbookUpdate in the switch statement handling StagedFinalizeBlockEvent.Event.
🔗 Analysis chain

LGTM! Verify related code updates.

The addition of StreamOrderbookUpdate orderbook_update = 3; to the StagedFinalizeBlockEvent message is well-structured and maintains backward compatibility. This change aligns with the PR objective of internalizing logic to stage FinalizeBlock events.

To ensure comprehensive implementation, please verify that all code handling StagedFinalizeBlockEvent has been updated to account for this new event type. Run the following script to identify potentially affected areas:

Review the output to ensure all relevant code paths have been updated to handle the new orderbook_update event type.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find usages of StagedFinalizeBlockEvent in the codebase

# Search for StagedFinalizeBlockEvent usage
echo "Searching for StagedFinalizeBlockEvent usage:"
rg --type go -A 5 "StagedFinalizeBlockEvent"

# Search for switch or if statements handling event types
echo "Searching for switch or if statements handling event types:"
rg --type go -A 10 -e "switch.*event" -e "if.*event\s*:?=\s*"

Length of output: 24292

}
}
6 changes: 3 additions & 3 deletions protocol/mocks/MemClobKeeper.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading