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

[OTE-877] deprecate OI indexer update event #2499

Merged
merged 1 commit into from
Oct 16, 2024
Merged

Conversation

affanv14
Copy link
Contributor

@affanv14 affanv14 commented Oct 16, 2024

Changelist

[Describe or list the changes made in this PR]

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
    • Introduced LiquidityTierUpsertEventV2 for enhanced liquidity tier management.
  • Deprecations
    • Marked several event interfaces as deprecated, including OpenInterestUpdateEventV1 and OpenInterestUpdate.
  • Bug Fixes
    • Improved testing framework for long-term and short-term order functionalities, enhancing coverage and robustness.
  • Tests
    • Added new test cases for order placement, cancellation, and execution scenarios in both long-term and short-term orders.
    • Updated tests in the perpetuals module for better error handling and functionality validation.

@affanv14 affanv14 requested a review from a team as a code owner October 16, 2024 15:55
Copy link

linear bot commented Oct 16, 2024

Copy link
Contributor

coderabbitai bot commented Oct 16, 2024

Walkthrough

The changes in this pull request focus on deprecating certain event interfaces and enhancing the documentation within the indexer module. Key modifications include the introduction of the LiquidityTierUpsertEventV2 interface, which adds new fields for open interest caps, while older interfaces such as OpenInterestUpdateEventV1 have been marked as deprecated. Additionally, the perpetuals module has undergone significant updates, including the removal of the SendOIUpdatesToIndexer function, which alters how open interest updates are managed. The testing framework for order functionalities has also been improved with new test cases.

Changes

File Path Change Summary
indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/events/events.ts, proto/dydxprotocol/indexer/events/events.proto Deprecated interfaces and messages updated; new LiquidityTierUpsertEventV2 interface introduced.
protocol/x/clob/e2e/long_term_orders_test.go, protocol/x/clob/e2e/short_term_orders_test.go New test cases added for order functionalities; existing tests refined for better coverage.
protocol/x/perpetuals/abci.go, protocol/x/perpetuals/abci_test.go, protocol/x/perpetuals/keeper/perpetual.go, protocol/x/perpetuals/keeper/perpetual_test.go, protocol/x/perpetuals/types/types.go Removed SendOIUpdatesToIndexer function; updated tests and methods for open interest management.

Possibly related PRs

Suggested labels

protocol, refactor, indexer

Suggested reviewers

  • jayy04

Poem

In the meadow where events do play,
Old ones fade, new ones sway.
Liquidity tiers rise and fall,
With open caps, we heed the call.
A hop, a skip, through code we dart,
Celebrating changes, a coder's art! 🐰✨


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

@affanv14 affanv14 changed the title [OTE-877] deprecate io indexer update event [OTE-877] deprecate OI indexer update event Oct 16, 2024
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: 5

🧹 Outside diff range and nitpick comments (3)
proto/dydxprotocol/indexer/events/events.proto (1)

Line range hint 553-554: Typo in Comment: Incorrect Message Name

The comment above LiquidityTierUpsertEventV2 incorrectly references LiquidationEventV2 instead of LiquidityTierUpsertEventV2. This could cause confusion for developers reading the code.

Apply this diff to correct the comment:

-// LiquidationEventV2 message contains all the information needed to update
-// the liquidity tiers. It contains all the fields from V1 along with the
-// open interest caps.
+// LiquidityTierUpsertEventV2 message contains all the information needed to update
+// the liquidity tiers. It contains all the fields from V1 along with the
+// open interest caps.
indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/events/events.ts (2)

Line range hint 1420-1424: Correct the interface name in the comment

The comment refers to LiquidationEventV2, but the interface is LiquidityTierUpsertEventV2. Update the comment to reflect the correct interface name.

Apply this diff:

- /**
-  * LiquidationEventV2 message contains all the information needed to update
+ /**
+  * LiquidityTierUpsertEventV2 message contains all the information needed to update
   * the liquidity tiers. It contains all the fields from V1 along with the
   * open interest caps.
   */

Line range hint 1452-1456: Correct the interface name in the comment

Ensure that the comment for LiquidityTierUpsertEventV2SDKType matches the interface name.

Apply this diff:

- /**
-  * LiquidationEventV2 message contains all the information needed to update
+ /**
+  * LiquidityTierUpsertEventV2SDKType message contains all the information needed to update
   * the liquidity tiers. It contains all the fields from V1 along with the
   * open interest caps.
   */
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 150513c and 32fa5be.

⛔ Files ignored due to path filters (1)
  • protocol/indexer/events/events.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (9)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/events/events.ts (1 hunks)
  • proto/dydxprotocol/indexer/events/events.proto (1 hunks)
  • protocol/x/clob/e2e/long_term_orders_test.go (0 hunks)
  • protocol/x/clob/e2e/short_term_orders_test.go (0 hunks)
  • protocol/x/perpetuals/abci.go (0 hunks)
  • protocol/x/perpetuals/abci_test.go (0 hunks)
  • protocol/x/perpetuals/keeper/perpetual.go (0 hunks)
  • protocol/x/perpetuals/keeper/perpetual_test.go (0 hunks)
  • protocol/x/perpetuals/types/types.go (0 hunks)
💤 Files with no reviewable changes (7)
  • protocol/x/clob/e2e/long_term_orders_test.go
  • protocol/x/clob/e2e/short_term_orders_test.go
  • protocol/x/perpetuals/abci.go
  • protocol/x/perpetuals/abci_test.go
  • protocol/x/perpetuals/keeper/perpetual.go
  • protocol/x/perpetuals/keeper/perpetual_test.go
  • protocol/x/perpetuals/types/types.go
🧰 Additional context used
🔇 Additional comments (4)
proto/dydxprotocol/indexer/events/events.proto (4)

537-541: Properly Deprecated OpenInterestUpdateEventV1

The OpenInterestUpdateEventV1 message is correctly marked as deprecated using the option deprecated = true; statement within the message. This appropriately signals to users that this message should no longer be used and helps maintain backward compatibility.


545-549: Properly Deprecated OpenInterestUpdate

The OpenInterestUpdate message is also correctly marked as deprecated with option deprecated = true;. This ensures that users are aware that this message is deprecated and should migrate to newer alternatives.


Line range hint 565-569: Addition of RegisterAffiliateEventV1 is Correct

The RegisterAffiliateEventV1 message is properly defined with appropriate fields for referee and affiliate. The use of (cosmos_proto.scalar) = "cosmos.AddressString" ensures correct handling of address strings in the Cosmos SDK.


Line range hint 571-577: UpsertVaultEventV1 Message Addition is Well-Structured

The UpsertVaultEventV1 message is correctly structured, with clear fields for address, clob_pair_id, and status. Utilizing VaultStatus for the status field is appropriate and maintains consistency with existing protocol definitions.

Comment on lines +1399 to 1405

/** @deprecated */

export interface OpenInterestUpdate {
/** The ID of the perpetual market. */
perpetualId: number;
/** The new open interest value for the perpetual market. */

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Include @deprecated annotation within the JSDoc comment block

For OpenInterestUpdate, the @deprecated tag should be placed inside the JSDoc comment block.

Apply this diff:

 /**
  * OpenInterestUpdate contains a single open interest update for a perpetual
  * Deprecated.
+ * @deprecated
  */
- /** @deprecated */

 export interface OpenInterestUpdate {
   perpetualId: number;
   /** The new open interest value for the perpetual market. */
📝 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
/** @deprecated */
export interface OpenInterestUpdate {
/** The ID of the perpetual market. */
perpetualId: number;
/** The new open interest value for the perpetual market. */
/**
* OpenInterestUpdate contains a single open interest update for a perpetual
* Deprecated.
* @deprecated
*/
export interface OpenInterestUpdate {
perpetualId: number;
/** The new open interest value for the perpetual market. */

Comment on lines +1385 to +1390
/**
* OpenInterestUpdateEventV1 is used for open interest update events
* Deprecated.
*/

/** @deprecated */
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Combine @deprecated annotation with the JSDoc comment block

Similarly, include the @deprecated tag within the JSDoc comment block for OpenInterestUpdateEventV1SDKType.

Apply this diff:

 /**
  * OpenInterestUpdateEventV1 is used for open interest update events
  * Deprecated.
+ * @deprecated
  */
- /** @deprecated */

 export interface OpenInterestUpdateEventV1SDKType {
   open_interest_updates: OpenInterestUpdateSDKType[];
 }
📝 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
/**
* OpenInterestUpdateEventV1 is used for open interest update events
* Deprecated.
*/
/** @deprecated */
/**
* OpenInterestUpdateEventV1 is used for open interest update events
* Deprecated.
* @deprecated
*/
export interface OpenInterestUpdateEventV1SDKType {
open_interest_updates: OpenInterestUpdateSDKType[];
}

Comment on lines +1375 to +1380
/**
* OpenInterestUpdateEventV1 is used for open interest update events
* Deprecated.
*/

/** @deprecated */
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Combine @deprecated annotation with the JSDoc comment block

The @deprecated tag for OpenInterestUpdateEventV1 should be included within the JSDoc comment block to properly document the deprecation.

Apply this diff:

 /**
  * OpenInterestUpdateEventV1 is used for open interest update events
  * Deprecated.
+ * @deprecated
  */
- /** @deprecated */

 export interface OpenInterestUpdateEventV1 {
   openInterestUpdates: OpenInterestUpdate[];
 }
📝 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
/**
* OpenInterestUpdateEventV1 is used for open interest update events
* Deprecated.
*/
/** @deprecated */
/**
* OpenInterestUpdateEventV1 is used for open interest update events
* Deprecated.
* @deprecated
*/
export interface OpenInterestUpdateEventV1 {
openInterestUpdates: OpenInterestUpdate[];
}

💡 Codebase verification

Deprecated Interfaces Still in Use

The deprecated interfaces OpenInterestUpdateEventV1 and OpenInterestUpdate are still being used in the file indexer/services/ender/__tests__/helpers/constants.ts. Please remove these usages to complete the deprecation process.

🔗 Analysis chain

Verify that deprecated interfaces are no longer used in the codebase

Now that OpenInterestUpdateEventV1 and OpenInterestUpdate have been deprecated, ensure that they are not used elsewhere in the codebase.

Run the following script to check for usage:

Also applies to: 1399-1405

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for usage of deprecated interfaces in TypeScript files
# Expected: No occurrences of the deprecated interfaces

rg --type ts 'OpenInterestUpdateEventV1|OpenInterestUpdate' --glob '!events.ts'

Length of output: 726

Comment on lines +1412 to 1417

/** @deprecated */

export interface OpenInterestUpdateSDKType {
/** The ID of the perpetual market. */
perpetual_id: number;
/** The new open interest value for the perpetual market. */
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Include @deprecated annotation within the JSDoc comment block

Similarly, for OpenInterestUpdateSDKType, include the @deprecated tag within the JSDoc comment block.

Apply this diff:

 /**
  * OpenInterestUpdate contains a single open interest update for a perpetual
  * Deprecated.
+ * @deprecated
  */
- /** @deprecated */

 export interface OpenInterestUpdateSDKType {
   perpetual_id: number;
   /** The new open interest value for the perpetual market. */
📝 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
/** @deprecated */
export interface OpenInterestUpdateSDKType {
/** The ID of the perpetual market. */
perpetual_id: number;
/** The new open interest value for the perpetual market. */
/**
* OpenInterestUpdate contains a single open interest update for a perpetual
* Deprecated.
* @deprecated
*/
export interface OpenInterestUpdateSDKType {
perpetual_id: number;
/** The new open interest value for the perpetual market. */

@affanv14 affanv14 merged commit 4208b7b into main Oct 16, 2024
39 checks passed
@affanv14 affanv14 deleted the affan/protocol-oi-remove branch October 16, 2024 17:30
@affanv14
Copy link
Contributor Author

@Mergifyio backport release/protocol/v6.x

@affanv14
Copy link
Contributor Author

@Mergifyio backport release/protocol/v7.x

Copy link
Contributor

mergify bot commented Oct 16, 2024

backport release/protocol/v6.x

✅ Backports have been created

Copy link
Contributor

mergify bot commented Oct 16, 2024

backport release/protocol/v7.x

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Oct 16, 2024
mergify bot pushed a commit that referenced this pull request Oct 16, 2024
(cherry picked from commit 4208b7b)

# Conflicts:
#	protocol/indexer/events/events.pb.go
affanv14 added a commit that referenced this pull request Oct 17, 2024
affanv14 added a commit that referenced this pull request Oct 17, 2024
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