Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
feat(fullnode) Add filterOrders option to streaming subscription #2676
feat(fullnode) Add filterOrders option to streaming subscription #2676
Changes from 5 commits
05ff9f3
309f2ec
39213e7
97d08ce
457459b
e632ed4
3c71f85
1ce9ffb
0c482e4
1c24dd6
69e6d40
e6603a1
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
💡 Codebase verification
Implementation of
filter_orders
parameter appears incompleteThe
filter_orders
parameter has been added to the protocol definition and is properly passed through the interface chain, but there's no evidence of actual filtering logic implementation in the codebase. This could lead to the parameter being ineffective.protocol/streaming/full_node_streaming_manager.go
: The streaming manager accepts the parameter but doesn't appear to use it for filtering order updatesAddOrderUpdatesToCache
or related methods where updates are processed🔗 Analysis chain
Verify integration with existing streaming functionality.
The field addition looks correct, but let's verify its integration with the existing streaming system.
Run the following to check for consistent handling across the codebase:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 14812
Script:
Length of output: 2484
Script:
Length of output: 7169
Script:
Length of output: 6862
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.
Prefer making it more explicit:
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 modularity, move switch statements into a new function:
func FilterUpdates(input []clobtypes.StreamUpdate) (filteredUpdates []clobtypes.StreamUpdate)
Also makes it easier to test
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.
Any reason to use slice over a map (as a set)? Is it because the former is more efficient at smaller size?
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.
Yes, it's based on the assumption that the subaccount cardinality is low.
If I had a test that imposed significant load, I could profile both the map and slice.
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.
Why not just return error to user and fail the
Subscribe
request? Then can also removeelse
below: https://go.dev/wiki/CodeReviewComments#indent-error-flowThere 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.
Per offline discussion, let's start with the simpler implementation of doing filtering below in the loop on
subscription.updatesChannel
, with the assumption that it's acceptable overhead to add an extra boolean comparison on each iteration of the channel.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.
Prevent execution when
filterOrders
is true withoutsubaccountIds
When
filterOrders
is true but nosubaccountIds
are provided, the code logs an error but continues execution. This can lead to subscribers receiving unfiltered order updates, contrary to their request. It's advisable to return an error or terminate the subscription to prevent unintended behavior.Apply this diff to return an error when
filterOrders
is requested withoutsubaccountIds
:if filterOrders { if len(subaccountIds) == 0 { sm.logger.Error( fmt.Sprintf( "filterOrders requires subaccountIds for subscription id: %+v", subscription.subscriptionId, ), ) + return types.ErrInvalidStreamingRequest } else { filteredUpdateChannel = make(chan []clobtypes.StreamUpdate, sm.maxSubscriptionChannelSize) defer close(filteredUpdateChannel) go subscription.FilterSubaccountStreamUpdates(filteredUpdateChannel, sm.logger) } }