-
Notifications
You must be signed in to change notification settings - Fork 115
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
[Full node streaming] emit taker order status at end of matching loop #2022
Conversation
Important Review skippedAuto reviews are limited to specific labels. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe recent changes enhance the system's ability to manage and report on taker orders through the introduction of a new method, Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant FullNodeStreamingManager
participant MemClobKeeper
participant Keeper
User->>Keeper: SendTakerOrderStatus(takerOrder)
Keeper->>FullNodeStreamingManager: SendTakerOrderStatus(takerOrder)
FullNodeStreamingManager->>MemClobKeeper: SendTakerOrderStatus(takerOrder)
MemClobKeeper-->>FullNodeStreamingManager: Acknowledge order status update
FullNodeStreamingManager-->>Keeper: Confirm order status sent
Keeper-->>User: Acknowledge order status processing
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (12)
- protocol/mocks/MemClobKeeper.go (1 hunks)
- protocol/streaming/full_node_streaming_manager.go (1 hunks)
- protocol/streaming/noop_streaming_manager.go (1 hunks)
- protocol/streaming/types/interface.go (1 hunks)
- protocol/testutil/memclob/keeper.go (1 hunks)
- protocol/x/clob/keeper/keeper.go (3 hunks)
- protocol/x/clob/memclob/memclob.go (1 hunks)
- protocol/x/clob/memclob/memclob_grpc_streaming.go (1 hunks)
- protocol/x/clob/types/liquidation_order.go (1 hunks)
- protocol/x/clob/types/mem_clob_keeper.go (1 hunks)
- protocol/x/clob/types/order.go (1 hunks)
- protocol/x/clob/types/orderbook.go (1 hunks)
Additional comments not posted (14)
protocol/streaming/types/interface.go (1)
37-41
: LGTM! Verify the method usage in the codebase.The addition of the
SendTakerOrderStatus
method to theFullNodeStreamingManager
interface looks good. Ensure that all implementations of this interface have this method defined.Verification successful
Verification of
SendTakerOrderStatus
Method ImplementationThe
SendTakerOrderStatus
method has been correctly added to theFullNodeStreamingManager
interface and implemented in the following files:
protocol/streaming/full_node_streaming_manager.go
protocol/streaming/noop_streaming_manager.go
protocol/testutil/memclob/keeper.go
protocol/x/clob/keeper/keeper.go
protocol/mocks/MemClobKeeper.go
All implementations of the
FullNodeStreamingManager
interface have theSendTakerOrderStatus
method defined.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all implementations of the `FullNodeStreamingManager` interface have the `SendTakerOrderStatus` method defined. # Test: Search for the method implementation. Expect: All implementations should include the new method. rg --type go -A 5 'SendTakerOrderStatus'Length of output: 3810
protocol/streaming/noop_streaming_manager.go (1)
45-50
: LGTM! Verify the method usage in the codebase.The addition of the
SendTakerOrderStatus
method to theNoopGrpcStreamingManager
class looks good. Ensure that the empty body is intentional and does not affect the functionality.Verification successful
LGTM! The empty body of the
SendTakerOrderStatus
method in theNoopGrpcStreamingManager
is intentional and consistent with the no-op design of the manager.
NoopGrpcStreamingManager
is designed as a no-operation implementation with all methods having empty bodies.- The
Enabled
method returnsfalse
, further indicating that this manager is not intended to perform any operations.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all usages of the `SendTakerOrderStatus` method in the codebase to ensure the empty body does not affect functionality. # Test: Search for the method usage. Expect: Ensure that the empty body is intentional. rg --type go -A 5 'SendTakerOrderStatus'Length of output: 3810
Script:
#!/bin/bash # Description: Check the definition and context of NoopGrpcStreamingManager to confirm the intent of the empty SendTakerOrderStatus method. # Search for the definition of NoopGrpcStreamingManager class or struct. rg --type go -A 10 'type NoopGrpcStreamingManager struct' # Search for the usage of NoopGrpcStreamingManager in the codebase. rg --type go -A 5 'NoopGrpcStreamingManager'Length of output: 4521
protocol/x/clob/types/mem_clob_keeper.go (1)
107-110
: LGTM! Verify the method usage in the codebase.The addition of the
SendTakerOrderStatus
method to theMemClobKeeper
interface looks good. Ensure that all implementations of this interface have this method defined.protocol/x/clob/types/liquidation_order.go (1)
118-122
: LGTM!The
MustGetLiquidationOrder
method is correctly implemented to fulfill theMatchableOrder
interface.protocol/x/clob/types/order.go (1)
135-139
: LGTM!The
MustGetLiquidationOrder
method is correctly implemented to fulfill theMatchableOrder
interface by panicking as expected.protocol/x/clob/types/orderbook.go (1)
209-211
: LGTM! But verify the usage of the new method.The code changes are approved.
However, ensure that all implementations of the
MatchableOrder
interface correctly handle the newMustGetLiquidationOrder
method.Verification successful
Let's correct the regex pattern and rerun the search to verify the implementations of the
MatchableOrder
interface.
Let's search for the
MustGetLiquidationOrder
method and its implementations to ensure it is correctly handled.
The
MustGetLiquidationOrder
method is correctly implemented and used.The method has been added to the
MatchableOrder
interface and implemented for bothLiquidationOrder
andOrder
. TheOrder
implementation correctly panics, ensuring the expected behavior. The method is also being utilized in the codebase.
protocol/x/clob/types/orderbook.go
protocol/x/clob/types/liquidation_order.go
protocol/x/clob/types/order.go
protocol/x/clob/memclob/memclob_grpc_streaming.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all implementations of the `MatchableOrder` interface handle the new method. # Test: Search for the implementations of the `MatchableOrder` interface. Expect: Implementations correctly handle the new method. rg --type go -A 10 $'type MatchableOrder interface {'Length of output: 180
Script:
#!/bin/bash # Description: Verify all implementations of the `MatchableOrder` interface handle the new method. # Test: Search for the implementations of the `MatchableOrder` interface. Expect: Implementations correctly handle the new method. rg --type go -A 10 'type MatchableOrder interface \{'Length of output: 1096
Script:
#!/bin/bash # Description: Search for the `MustGetLiquidationOrder` method and its implementations in the codebase. # Test: Search for the `MustGetLiquidationOrder` method in the codebase. Expect: Implementations correctly handle the new method. rg --type go 'MustGetLiquidationOrder'Length of output: 899
protocol/x/clob/keeper/keeper.go (3)
Line range hint
270-274
:
Comment update approved.The comment update clarifies the intended recipient of the updates.
Line range hint
286-292
:
Comment update approved.The comment update clarifies the intended recipient of the updates.
302-312
: New methodSendTakerOrderStatus
approved.The method is correctly implemented and follows the pattern of the existing methods.
protocol/streaming/full_node_streaming_manager.go (1)
365-391
: New methodSendTakerOrderStatus
approved.The method is correctly implemented and follows the pattern of the existing methods. The logic for determining the
clobPairId
is clear and ensures the correctclobPairId
is used based on the type of order.protocol/mocks/MemClobKeeper.go (1)
419-422
: LGTM!The new mock function
SendTakerOrderStatus
is consistent with the pattern established by other mock functions in the class and enhances the mock functionality.protocol/x/clob/memclob/memclob.go (3)
772-775
: Correct use ofGenerateStreamTakerOrder
.The
GenerateStreamTakerOrder
function is correctly used to generate the stream taker order.
776-779
: Correct use ofSendTakerOrderStatus
.The
SendTakerOrderStatus
method ofclobKeeper
is correctly used to send the taker order status.
770-780
: EnsuregenerateOrderbookUpdates
is properly initialized.The new conditional block correctly checks if
generateOrderbookUpdates
is enabled before emitting the taker order status. Ensure thatgenerateOrderbookUpdates
is properly initialized and managed to avoid unexpected behavior.Verification successful
Ensure
generateOrderbookUpdates
is properly initialized.The
generateOrderbookUpdates
field is correctly initialized tofalse
in the constructor and managed via theSetGenerateOrderbookUpdates
method. This ensures that the conditional check forgenerateOrderbookUpdates
in thematchOrder
method will function correctly based on its current state.
MemClobPriceTimePriority
struct definesgenerateOrderbookUpdates
.- Initialized to
false
in the constructor.- Managed via
SetGenerateOrderbookUpdates
method.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the initialization and management of `generateOrderbookUpdates`. # Test: Search for the initialization and management of `generateOrderbookUpdates`. Expect: Proper initialization and management. rg --type go --context 5 'generateOrderbookUpdates'Length of output: 5632
// GenerateStreamTakerOrder returns a `StreamTakerOrder` object used in full node | ||
// streaming from a matchableOrder and a taker order status. | ||
func (m *MemClobPriceTimePriority) GenerateStreamTakerOrder( | ||
takerOrder types.MatchableOrder, | ||
takerOrderStatus types.TakerOrderStatus, | ||
) types.StreamTakerOrder { | ||
if takerOrder.IsLiquidation() { | ||
liquidationOrder := takerOrder.MustGetLiquidationOrder() | ||
streamLiquidationOrder := liquidationOrder.ToStreamLiquidationOrder() | ||
return types.StreamTakerOrder{ | ||
TakerOrder: &types.StreamTakerOrder_LiquidationOrder{ | ||
LiquidationOrder: streamLiquidationOrder, | ||
}, | ||
TakerOrderStatus: takerOrderStatus.ToStreamingTakerOrderStatus(), | ||
} | ||
} | ||
order := takerOrder.MustGetOrder() | ||
return types.StreamTakerOrder{ | ||
TakerOrder: &types.StreamTakerOrder_Order{ | ||
Order: &order, | ||
}, | ||
TakerOrderStatus: takerOrderStatus.ToStreamingTakerOrderStatus(), | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor suggestion: Simplify the nested if-else.
The nested if-else can be simplified for better readability.
func (m *MemClobPriceTimePriority) GenerateStreamTakerOrder(
takerOrder types.MatchableOrder,
takerOrderStatus types.TakerOrderStatus,
) types.StreamTakerOrder {
if takerOrder.IsLiquidation() {
liquidationOrder := takerOrder.MustGetLiquidationOrder()
streamLiquidationOrder := liquidationOrder.ToStreamLiquidationOrder()
return types.StreamTakerOrder{
TakerOrder: &types.StreamTakerOrder_LiquidationOrder{
LiquidationOrder: streamLiquidationOrder,
},
TakerOrderStatus: takerOrderStatus.ToStreamingTakerOrderStatus(),
}
}
order := takerOrder.MustGetOrder()
return types.StreamTakerOrder{
TakerOrder: &types.StreamTakerOrder_Order{
Order: &order,
},
TakerOrderStatus: takerOrderStatus.ToStreamingTakerOrderStatus(),
}
}
Committable suggestion was skipped due to low confidence.
func (f *FakeMemClobKeeper) SendTakerOrderStatus( | ||
ctx sdk.Context, | ||
takerOrder types.StreamTakerOrder, | ||
) { | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provide a mock implementation or a TODO comment.
The new method SendTakerOrderStatus
is added to the FakeMemClobKeeper
struct but its implementation is empty. Consider providing a mock implementation or adding a TODO comment to indicate future work.
+ // TODO: Implement the mock logic for SendTakerOrderStatus
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
func (f *FakeMemClobKeeper) SendTakerOrderStatus( | |
ctx sdk.Context, | |
takerOrder types.StreamTakerOrder, | |
) { | |
} | |
func (f *FakeMemClobKeeper) SendTakerOrderStatus( | |
ctx sdk.Context, | |
takerOrder types.StreamTakerOrder, | |
) { | |
// TODO: Implement the mock logic for SendTakerOrderStatus | |
} |
UpdateMessage: &clobtypes.StreamUpdate_TakerOrder{ | ||
TakerOrder: &streamTakerOrder, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for my understanding - do we need to send any fill amounts for taker orders?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should have the fill amounts in a following full node stream update if you are subscribed to the correct clob pair id!
Summary by CodeRabbit
New Features
SendTakerOrderStatus
function for better order status handling across multiple components.Bug Fixes
Documentation
Refactor