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

Update order replacement protos to include old order id #1664

Merged
merged 2 commits into from
Jun 10, 2024

Conversation

chenyaoy
Copy link
Contributor

@chenyaoy chenyaoy commented Jun 10, 2024

Changelist

Vault replaces orders and generates a brand new order ID for each replacement order so the order replacement proto needs to include the old order ID that we want to remove, along with the new order.

proto check-bc-breaking CI step failing is okay because these messages are not currently sent or consumed

Test Plan

[Describe how this PR was tested (if applicable)]

Author/Reviewer Checklist

  • If this PR has changes that result in a different app state given the same prior state and transaction list, manually add the state-breaking label.
  • If the PR has breaking postgres changes to the indexer add the indexer-postgres-breaking label.
  • If this PR isn't state-breaking but has changes that modify behavior in PrepareProposal or ProcessProposal, manually add the label proposal-breaking.
  • If this PR is one of many that implement a specific feature, manually label them all feature:[feature-name].
  • If you wish to for mergify-bot to automatically create a PR to backport your change to a release branch, manually add the label backport/[branch-name].
  • Manually add any of the following labels: refactor, chore, bug.

Summary by CodeRabbit

  • New Features
    • Enhanced order replacement functionality by adding support for oldOrderId in order events and off-chain updates. This allows users to track the original order ID during replacements.

Copy link
Contributor

coderabbitai bot commented Jun 10, 2024

Walkthrough

The recent updates to the dydxprotocol indexer package involve adding a new field, oldOrderId, to both StatefulOrderEventV1_LongTermOrderReplacementV1 and OrderReplaceV1 interfaces. These changes are reflected in the corresponding encoding, decoding, and initialization functions, ensuring seamless handling of the new field. The related protobuf files have also been updated to include the old_order_id field in the respective messages.

Changes

File Path Change Summary
indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/events/... Added oldOrderId to StatefulOrderEventV1_LongTermOrderReplacementV1 interface and updated related methods.
indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/off_chain_updates/... Added oldOrderId to OrderReplaceV1 interface and updated related methods.
proto/dydxprotocol/indexer/events/events.proto Added old_order_id field to LongTermOrderReplacementV1 message.
proto/dydxprotocol/indexer/off_chain_updates/off_chain_updates.proto Added old_order_id field to OrderReplaceV1 message and updated field positions.

Poem

In the code of orders old and new,
A field emerges, clear and true.
oldOrderId now takes its place,
Ensuring history leaves no trace.
With updates swift and changes bright,
Our indexer shines in the night. 🌙✨


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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @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

@dydxwill dydxwill left a comment

Choose a reason for hiding this comment

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

These protos aren't used anywhere right?

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

Outside diff range and nitpick comments (1)
indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/events/events.ts (1)

Line range hint 75-75: Address static analysis findings regarding useless case clauses.

The static analysis tool has identified several useless case clauses in switch statements. These should be reviewed and potentially removed to clean up the code and reduce complexity.

- case "UNRECOGNIZED":
- default:
-   return FundingEventV1_Type.UNRECOGNIZED;

Also applies to: 76-76, 95-95

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5aa268e and 91014ff.

Files ignored due to path filters (2)
  • protocol/indexer/events/events.pb.go is excluded by !**/*.pb.go
  • protocol/indexer/off_chain_updates/types/off_chain_updates.pb.go is excluded by !**/*.pb.go
Files selected for processing (4)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/events/events.ts (4 hunks)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/off_chain_updates/off_chain_updates.ts (5 hunks)
  • proto/dydxprotocol/indexer/events/events.proto (1 hunks)
  • proto/dydxprotocol/indexer/off_chain_updates/off_chain_updates.proto (1 hunks)
Additional context used
Biome
indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/off_chain_updates/off_chain_updates.ts

[error] 82-82: Useless case clause. (lint/complexity/noUselessSwitchCase)

because the default clause is present:

Unsafe fix: Remove the useless case.


[error] 83-83: Useless case clause. (lint/complexity/noUselessSwitchCase)

because the default clause is present:

Unsafe fix: Remove the useless case.


[error] 99-99: Useless case clause. (lint/complexity/noUselessSwitchCase)

because the default clause is present:

Unsafe fix: Remove the useless case.


[error] 194-194: Useless case clause. (lint/complexity/noUselessSwitchCase)

because the default clause is present:

Unsafe fix: Remove the useless case.


[error] 195-195: Useless case clause. (lint/complexity/noUselessSwitchCase)

because the default clause is present:

Unsafe fix: Remove the useless case.


[error] 214-214: Useless case clause. (lint/complexity/noUselessSwitchCase)

because the default clause is present:

Unsafe fix: Remove the useless case.

indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/events/events.ts

[error] 75-75: Useless case clause. (lint/complexity/noUselessSwitchCase)

because the default clause is present:

Unsafe fix: Remove the useless case.


[error] 76-76: Useless case clause. (lint/complexity/noUselessSwitchCase)

because the default clause is present:

Unsafe fix: Remove the useless case.


[error] 95-95: Useless case clause. (lint/complexity/noUselessSwitchCase)

because the default clause is present:

Unsafe fix: Remove the useless case.

Additional comments not posted (4)
proto/dydxprotocol/indexer/off_chain_updates/off_chain_updates.proto (1)

91-98: The addition of old_order_id in OrderReplaceV1 is correctly implemented and well-positioned.

proto/dydxprotocol/indexer/events/events.proto (1)

285-288: The addition of old_order_id in LongTermOrderReplacementV1 is correctly implemented and well-positioned.

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

281-294: The addition of oldOrderId in OrderReplaceV1 and OrderReplaceV1SDKType interfaces is correctly implemented. The field is properly initialized, and the encoding/decoding functions are updated accordingly.

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

722-733: Ensure the new oldOrderId field is properly documented and integrated.

The addition of the oldOrderId field in both the TypeScript interface and its SDK type is consistent with the PR's objective to handle order replacements more effectively by tracking old order IDs. This change should help maintain the integrity of order tracking and replacement within the system.

Comment on lines +2747 to +2752
if (message.oldOrderId !== undefined) {
IndexerOrderId.encode(message.oldOrderId, writer.uint32(10).fork()).ldelim();
}

if (message.order !== undefined) {
IndexerOrder.encode(message.order, writer.uint32(10).fork()).ldelim();
IndexerOrder.encode(message.order, writer.uint32(18).fork()).ldelim();
Copy link
Contributor

Choose a reason for hiding this comment

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

Refactor encoding and decoding logic to improve clarity.

The encoding and decoding logic for the oldOrderId could be simplified or documented better to improve maintainability. Consider adding comments or refactoring for clarity.

2747  if (message.oldOrderId !== undefined) {
2748      IndexerOrderId.encode(message.oldOrderId, writer.uint32(10).fork()).ldelim();
2749  }
2750  // Encode the main order
2751  if (message.order !== undefined) {
2752      IndexerOrder.encode(message.order, writer.uint32(18).fork()).ldelim();
2768      case 1:
2769          message.oldOrderId = IndexerOrderId.decode(reader, reader.uint32());
2770          break;
2771      // Decode the main order

Also applies to: 2768-2771

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.

Suggested change
if (message.oldOrderId !== undefined) {
IndexerOrderId.encode(message.oldOrderId, writer.uint32(10).fork()).ldelim();
}
if (message.order !== undefined) {
IndexerOrder.encode(message.order, writer.uint32(10).fork()).ldelim();
IndexerOrder.encode(message.order, writer.uint32(18).fork()).ldelim();
if (message.oldOrderId !== undefined) {
IndexerOrderId.encode(message.oldOrderId, writer.uint32(10).fork()).ldelim();
}
// Encode the main order
if (message.order !== undefined) {
IndexerOrder.encode(message.order, writer.uint32(18).fork()).ldelim();
}
// ... other code ...
case 1:
message.oldOrderId = IndexerOrderId.decode(reader, reader.uint32());
break;
// Decode the main order

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 91014ff and 1522b71.

Files selected for processing (2)
  • proto/dydxprotocol/indexer/events/events.proto (1 hunks)
  • proto/dydxprotocol/indexer/off_chain_updates/off_chain_updates.proto (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • proto/dydxprotocol/indexer/events/events.proto
  • proto/dydxprotocol/indexer/off_chain_updates/off_chain_updates.proto

@chenyaoy chenyaoy merged commit 1e234eb into main Jun 10, 2024
33 of 34 checks passed
@chenyaoy chenyaoy deleted the chenyao/update-order-replacement-proto branch June 10, 2024 21:43
@chenyaoy chenyaoy mentioned this pull request Jun 21, 2024
6 tasks
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