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

Orderbook Fills protos #1446

Merged
merged 3 commits into from
May 7, 2024
Merged

Orderbook Fills protos #1446

merged 3 commits into from
May 7, 2024

Conversation

jonfung-dydx
Copy link
Contributor

@jonfung-dydx jonfung-dydx commented Apr 30, 2024

Summary by CodeRabbit

  • New Features
    • Enhanced orderbook streaming with new update types including order fills and matches.
  • Documentation
    • Improved documentation for the streamOrderbookUpdates method to clarify the types of updates streamed.
  • Refactor
    • Updated the StreamOrderbookUpdatesResponse to use the new StreamUpdate type for more detailed orderbook updates.

Copy link
Contributor

coderabbitai bot commented Apr 30, 2024

Walkthrough

The recent updates focus on enhancing the Query interface and related data structures in the dYdX protocol's codebase. These changes include introducing new types and interfaces to better manage and stream orderbook updates, covering detailed types for matches, orders, and fills. Furthermore, the documentation has been refined to provide clear descriptions of the streamed data types, ensuring improved clarity and support for developers integrating with the dYdX protocol.

Changes

File Path Change Summary
.../v4-protos/src/codegen/dydxprotocol/clob/query.ts Added new types ClobMatch, Order, StreamUpdate, etc.; updated StreamOrderbookUpdatesResponse.
proto/dydxprotocol/clob/query.proto Added imports, new message types, and updated StreamOrderbookUpdatesResponse.
protocol/streaming/grpc/grpc_streaming_manager.go Updated SendOrderbookUpdates method to use new types for orderbook updates.

Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between a622df9 and a0ee1e1.
Files ignored due to path filters (1)
  • protocol/x/clob/types/query.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
Files selected for processing (3)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/query.ts (8 hunks)
  • proto/dydxprotocol/clob/query.proto (4 hunks)
  • protocol/streaming/grpc/grpc_streaming_manager.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • proto/dydxprotocol/clob/query.proto
Additional Context Used
Path-based Instructions (2)
protocol/streaming/grpc/grpc_streaming_manager.go (1)

Pattern **/**: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/query.ts (1)

Pattern **/**: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

Additional comments not posted (4)
protocol/streaming/grpc/grpc_streaming_manager.go (1)

117-127: The changes from lines 117 to 127 introduce a new structure for streaming orderbook updates using the StreamUpdate type. Ensure that the new StreamUpdate type is fully compatible with the expected client-side handling of these messages.

indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/query.ts (3)

8-9: The addition of ClobMatch and Order entities enhances the data structure for handling orderbook updates. Ensure that these new types are integrated properly across all relevant parts of the application.


Line range hint 229-257: The changes from lines 229 to 257 in the StreamOrderbookUpdatesResponse interface add additional debugging fields. Ensure that these fields are used appropriately for debugging and are not exposed in production environments where they could lead to information leakage.
[SECURITY]


Line range hint 263-336: The introduction of StreamUpdate, StreamOrderbookUpdate, and StreamOrderbookFill interfaces from lines 263 to 336 provides a structured way to handle different types of orderbook updates. Review the usage of these interfaces to ensure they meet the system's requirements for accuracy and performance.


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Out of diff range and nitpick comments (2)
protocol/streaming/grpc/grpc_streaming_manager.go (2)

Line range hint 50-62: Ensure proper error handling in the Subscribe method. Currently, it returns a generic error without specific handling or logging. Consider adding detailed error messages and logging for better debuggability.

- return clobtypes.ErrInvalidGrpcStreamingRequest
+ return fmt.Errorf("invalid request: %w", clobtypes.ErrInvalidGrpcStreamingRequest)

Line range hint 150-160: Consider optimizing the GetUninitializedClobPairIds method by caching the results or reducing the frequency of lock acquisitions, as this could potentially be a performance bottleneck in high-throughput scenarios.

Comment on lines +117 to +127
streamUpdates := clobtypes.StreamUpdate{
UpdateMessage: &clobtypes.StreamUpdate_OrderbookUpdate{
OrderbookUpdate: &clobtypes.StreamOrderbookUpdate{
Updates: updatesToSend,
Snapshot: snapshot,
},
},
}
if err := subscription.srv.Send(
&clobtypes.StreamOrderbookUpdatesResponse{
Updates: updatesToSend,
Snapshot: snapshot,
Updates: []clobtypes.StreamUpdate{streamUpdates},
Copy link
Contributor

Choose a reason for hiding this comment

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

The implementation of sending updates in the SendOrderbookUpdates method appears correct. However, consider adding more robust error handling and logging to improve system resilience and maintainability.

- panic(err)
+ log.Errorf("Failed to unmarshal offchain updates: %v", err)
+ return err

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.

Suggested change
streamUpdates := clobtypes.StreamUpdate{
UpdateMessage: &clobtypes.StreamUpdate_OrderbookUpdate{
OrderbookUpdate: &clobtypes.StreamOrderbookUpdate{
Updates: updatesToSend,
Snapshot: snapshot,
},
},
}
if err := subscription.srv.Send(
&clobtypes.StreamOrderbookUpdatesResponse{
Updates: updatesToSend,
Snapshot: snapshot,
Updates: []clobtypes.StreamUpdate{streamUpdates},
streamUpdates := clobtypes.StreamUpdate{
UpdateMessage: &clobtypes.StreamUpdate_OrderbookUpdate{
OrderbookUpdate: &clobtypes.StreamOrderbookUpdate{
Updates: updatesToSend,
Snapshot: snapshot,
},
},
}
if err := subscription.srv.Send(
&clobtypes.StreamOrderbookUpdatesResponse{
Updates: []clobtypes.StreamUpdate{streamUpdates},
log.Errorf("Failed to unmarshal offchain updates: %v", err)
return err

@jonfung-dydx jonfung-dydx merged commit 7e87c2e into main May 7, 2024
32 of 33 checks passed
@jonfung-dydx jonfung-dydx deleted the jonfung/streamFillsV2 branch May 7, 2024 18:09
jonfung-dydx added a commit that referenced this pull request May 13, 2024
* new protos

* fix prev use case

* proto lint
@jonfung-dydx
Copy link
Contributor Author

@Mergifyio backport release/protocol/v4.1.x

Copy link
Contributor

mergify bot commented May 21, 2024

backport release/protocol/v4.1.x

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request May 21, 2024
* new protos

* fix prev use case

* proto lint

(cherry picked from commit 7e87c2e)

# Conflicts:
#	indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/query.rpc.Query.ts
#	protocol/x/clob/types/query.pb.go
jonfung-dydx added a commit that referenced this pull request May 21, 2024
Co-authored-by: Jonathan Fung <[email protected]>
Co-authored-by: Jonathan Fung <[email protected]>
@jonfung-dydx
Copy link
Contributor Author

jonfung-dydx commented May 31, 2024

@Mergifyio backport release/protocol/v5.x

Copy link
Contributor

mergify bot commented May 31, 2024

backport release/protocol/v5.0.x

❌ No backport have been created

  • Backport to branch release/protocol/v5.0.x failed

GitHub error: Branch not found

Copy link
Contributor

mergify bot commented May 31, 2024

backport release/protocol/v5.x

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request May 31, 2024
* new protos

* fix prev use case

* proto lint

(cherry picked from commit 7e87c2e)

# Conflicts:
#	indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/query.rpc.Query.ts
#	protocol/x/clob/types/query.pb.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants