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

Revert "[CT-708] Indexer track e2e latency (#1237)" #1292

Merged
merged 1 commit into from
Apr 1, 2024

Conversation

jonfung-dydx
Copy link
Contributor

This reverts commit 60b94df.

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.

Copy link

linear bot commented Mar 29, 2024

Copy link
Contributor

coderabbitai bot commented Mar 29, 2024

Walkthrough

The series of changes across various files primarily involve the reorganization and simplification of code related to message handling and timestamp conversions. Key adjustments include the removal of the headers parameter from method signatures, the elimination of unused variables, and the restructuring of timestamp-related functions. These modifications suggest an effort to streamline operations, reduce dependencies on specific data structures, and enhance the clarity and maintainability of the codebase.

Changes

File(s) Change Summary
indexer/packages/v4-protos/src/index.ts Removed export statement for utils.
.../__tests__/helpers/indexer-proto-helpers.ts, .../services/ender/src/lib/helper.ts Adjusted imports and added/removed protoTimestampToDate function reflecting reorganization of helper functions.
.../services/socks/src/lib/message-forwarder.ts Refactored time metrics calculation in MessageForwarder, simplifying timestamp calculations.
.../__tests__/handlers/order-place-handler.test.ts, .../__tests__/handlers/order-remove-handler.test.ts, .../__tests__/helpers/helpers.ts, .../__tests__/helpers/websocket-helpers.ts, .../__tests__/lib/on-message.test.ts Various adjustments including removal of defaultKafkaHeaders and simplification of message header handling in tests.
.../services/vulcan/src/handlers/handler.ts, .../services/vulcan/src/handlers/order-place-handler.ts, .../services/vulcan/src/handlers/order-remove-handler.ts, .../services/vulcan/src/handlers/order-update-handler.ts Removed headers: IHeaders parameter from method signatures, streamlining message handling.
.../services/vulcan/src/lib/on-message.ts Removed logic for tracking message processing time based on Kafka message headers.

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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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 Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 0231edc and 2d70df5.
Files selected for processing (14)
  • indexer/packages/v4-protos/src/index.ts (1 hunks)
  • indexer/services/ender/tests/helpers/indexer-proto-helpers.ts (2 hunks)
  • indexer/services/ender/src/lib/helper.ts (3 hunks)
  • indexer/services/socks/src/lib/message-forwarder.ts (3 hunks)
  • indexer/services/vulcan/tests/handlers/order-place-handler.test.ts (3 hunks)
  • indexer/services/vulcan/tests/handlers/order-remove-handler.test.ts (24 hunks)
  • indexer/services/vulcan/tests/helpers/helpers.ts (3 hunks)
  • indexer/services/vulcan/tests/helpers/websocket-helpers.ts (1 hunks)
  • indexer/services/vulcan/tests/lib/on-message.test.ts (1 hunks)
  • indexer/services/vulcan/src/handlers/handler.ts (2 hunks)
  • indexer/services/vulcan/src/handlers/order-place-handler.ts (7 hunks)
  • indexer/services/vulcan/src/handlers/order-remove-handler.ts (11 hunks)
  • indexer/services/vulcan/src/handlers/order-update-handler.ts (3 hunks)
  • indexer/services/vulcan/src/lib/on-message.ts (2 hunks)
Additional Context Used
Path-based Instructions (14)
indexer/packages/v4-protos/src/index.ts (1)

**/**:
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/services/vulcan/__tests__/helpers/websocket-helpers.ts (1)

**/**:
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/services/vulcan/src/handlers/handler.ts (1)

**/**:
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/services/vulcan/__tests__/helpers/helpers.ts (1)

**/**:
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/services/vulcan/src/lib/on-message.ts (1)

**/**:
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/services/vulcan/__tests__/lib/on-message.test.ts (1)

**/**:
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/services/ender/src/lib/helper.ts (1)

**/**:
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/services/socks/src/lib/message-forwarder.ts (1)

**/**:
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/services/vulcan/src/handlers/order-update-handler.ts (1)

**/**:
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/services/vulcan/src/handlers/order-place-handler.ts (1)

**/**:
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/services/ender/__tests__/helpers/indexer-proto-helpers.ts (1)

**/**:
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/services/vulcan/src/handlers/order-remove-handler.ts (1)

**/**:
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/services/vulcan/__tests__/handlers/order-place-handler.test.ts (1)

**/**:
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/services/vulcan/__tests__/handlers/order-remove-handler.test.ts (1)

**/**:
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 (19)
indexer/packages/v4-protos/src/index.ts (1)

16-18: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-23]

The removal of the utils export from index.ts could impact other parts of the project that rely on utilities from this file. Ensure that any dependencies on the removed utils export have been addressed or that the functionalities provided by utils are no longer needed.

Verification successful

The search for imports of the removed utils from @dydxprotocol-indexer/v4-protos across the project did not yield any results. This suggests that there are no direct dependencies on the removed utils export in TypeScript files within the project. However, it's important to consider any potential indirect dependencies or more complex usage patterns that weren't captured by this search.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for imports of the removed `utils` from `v4-protos` across the project
rg --type ts "from '@dydxprotocol-indexer/v4-protos'.*utils"

Length of output: 68

indexer/services/vulcan/__tests__/helpers/websocket-helpers.ts (1)

1-18: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [3-22]

The removal of expectedHeaders from expectWebsocketSubaccountMessage simplifies the function by focusing on the message content. Ensure that this change aligns with the testing requirements and that any tests relying on header comparisons have been updated or are no longer necessary.

indexer/services/vulcan/src/handlers/handler.ts (1)

18-22: The removal of the headers: IHeaders parameter from handleUpdate simplifies the method signature. Ensure that any logic previously relying on headers has been appropriately adjusted or is no longer necessary.

indexer/services/vulcan/__tests__/helpers/helpers.ts (1)

13-18: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-81]

The removal of defaultKafkaHeaders and its usage in testing helpers simplifies the code by removing unnecessary header assignments. Ensure that this change aligns with the testing requirements and that any tests relying on specific header values have been updated or are no longer necessary.

indexer/services/vulcan/src/lib/on-message.ts (1)

86-92: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [89-133]

The removal of timing statistics tracking from onMessage simplifies the function by focusing solely on message handling. Ensure that this change aligns with the project's performance monitoring strategy and that any necessary adjustments have been made.

indexer/services/vulcan/__tests__/lib/on-message.test.ts (1)

67-67: The modification of the assertion in the onMessage test to remove the check for message.headers aligns with the changes made in the onMessage function. Ensure that this change aligns with the testing requirements and that any tests relying on header comparisons have been updated or are no longer necessary.

indexer/services/ender/src/lib/helper.ts (1)

11-11: The addition of the protoTimestampToDate function and related imports (Timestamp, MILLIS_IN_NANOS, SECONDS_IN_MILLIS) enhances the utility of the helper file by providing a standardized way to convert Timestamp to Date. Ensure that the implementation of protoTimestampToDate is correct and aligns with the project's date handling requirements.

Also applies to: 32-35, 73-80

indexer/services/socks/src/lib/message-forwarder.ts (1)

90-90: The refactoring of time metrics calculation in the MessageForwarder class simplifies the logic for measuring message queue time and message forwarding time. Ensure that the refactored logic accurately measures the intended metrics and aligns with the project's performance monitoring strategy.

Also applies to: 128-133

indexer/services/vulcan/src/handlers/order-update-handler.ts (1)

54-54: The removal of the headers parameter from the handle method simplifies the message handling process by focusing solely on the content of the messages rather than their metadata. This change aligns with the PR's objective to streamline message and Kafka headers handling.

indexer/services/vulcan/src/handlers/order-place-handler.ts (1)

55-55: The removal of the headers parameter from the handle method and related adjustments reflect the PR's objective to simplify message handling by eliminating the use of Kafka headers in the message processing logic.

indexer/services/ender/__tests__/helpers/indexer-proto-helpers.ts (1)

66-66: The change in the import location of protoTimestampToDate from @dydxprotocol-indexer/v4-protos to ../../src/lib/helper likely reflects a reorganization of helper functions within the project. This adjustment aligns with the PR's objective to reorganize timestamp conversion utilities.

indexer/services/vulcan/src/handlers/order-remove-handler.ts (2)

71-71: The changes from lines 41 to 138 involve the removal of the headers parameter from the handle method signature. This simplification could improve code readability and maintainability by focusing on the essential data needed for processing. Ensure that all calls to this method across the codebase have been updated accordingly to prevent runtime errors.

Verification successful

Given the files identified as potentially using OrderRemoveHandler, we need to inspect these files to ensure that the handle method is called correctly without the previously mentioned headers parameter. This step is crucial to confirm that the changes have been properly propagated throughout the codebase and to verify the review comment accurately.


The examination of the provided context suggests that the removal of the headers parameter from the handle method in OrderRemoveHandler has been correctly propagated throughout the codebase, as no calls to the handle method with two parameters were found. However, it's important to note that the direct invocation of the handle method was not explicitly shown in the outputs, introducing a slight uncertainty. Based on the evidence available, the review comment is considered verified, with the recommendation for a manual check to ensure complete confidence in the method's usage across the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for files that might import and use OrderRemoveHandler. Expecting list of dependent files.
rg --type ts "OrderRemoveHandler" --files-with-matches
# Verify that no calls to handle method include the headers parameter. Expecting no results.
ast-grep --lang typescript --pattern $'OrderRemoveHandler.prototype.handle($_, $_)'

Length of output: 375



Script:

#!/bin/bash
# Inspect the usage of OrderRemoveHandler in the identified files to ensure the handle method is called correctly.
# File: indexer/services/vulcan/src/lib/on-message.ts
rg "OrderRemoveHandler" indexer/services/vulcan/src/lib/on-message.ts
# File: indexer/services/vulcan/__tests__/handlers/order-remove-handler.test.ts
rg "OrderRemoveHandler" indexer/services/vulcan/__tests__/handlers/order-remove-handler.test.ts
# File: indexer/services/vulcan/__tests__/lib/on-message.test.ts
rg "OrderRemoveHandler" indexer/services/vulcan/__tests__/lib/on-message.test.ts

Length of output: 2370


138-138: The removal of the headers parameter and its related adjustments within the OrderRemoveHandler class streamline the message handling process. This change should simplify the code and potentially improve performance by reducing the complexity of method signatures and calls. However, ensure that this simplification does not remove any critical functionality related to message headers that might be required for other features or performance tracking.

indexer/services/vulcan/__tests__/handlers/order-place-handler.test.ts (1)

1228-1228: The changes from lines 1228 to 1228 involve the call to expectWebsocketSubaccountMessage within the expectWebsocketMessagesSent function. This update is part of the refactoring effort to simplify message handling and Kafka headers usage throughout the project. It's important to ensure that the updated call correctly matches the expected structure and content of the subaccount message, especially after the removal of defaultKafkaHeaders. The test logic here appears to correctly validate the expected subaccount message against the actual message sent by the producer, which is a good practice for ensuring the integrity of message handling logic.

indexer/services/vulcan/__tests__/handlers/order-remove-handler.test.ts (5)

52-65: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-1065]

The setup and teardown code, including the use of mocks and timers, is appropriate for the tests being conducted. It ensures that the tests are isolated from external effects and can run in a controlled environment. Good job on maintaining a clean testing environment.


182-182: The tests for handling invalid updates are well-implemented, using parameterized tests with it.each to efficiently cover multiple scenarios. The use of expect().rejects.toThrow() and expect(logger.error) ensures that the handler's error handling and logging are correctly tested.


323-323: The tests for successful order removal are comprehensive and cover a wide range of scenarios. They effectively use helper functions and spies to simulate system state and verify outcomes. Consider adding comments to clarify the purpose and setup of each test case, enhancing future maintainability.


1426-1426: The tests for error scenarios and special conditions are correctly implemented, testing important aspects of the handler's behavior in edge cases. Ensure that all edge cases are covered and that the tests remain up-to-date with any changes to the handler's logic. The use of specific assertions like expectNoWebsocketMessagesSent and expect(logger.error) is commendable.


2047-2047: The utility functions used in the tests, such as expectOrderStatus and expectWebsocketMessagesSent, are well-designed and improve the readability and maintainability of the tests. Their consistent use across the test suite is commendable. Consider adding more utility functions for other repetitive tasks to further improve test code quality.

@jonfung-dydx jonfung-dydx merged commit 1d561c9 into main Apr 1, 2024
18 checks passed
@jonfung-dydx jonfung-dydx deleted the jonfung/fixIndexerRevert branch April 1, 2024 14:28
dydxwill added a commit that referenced this pull request Apr 3, 2024
* Add subaccountNumber to PerpetualPositionResponseObject (#1274)

Signed-off-by: Shrenuj Bansal <[email protected]>

* [CT-712] send updates for both normal order matches and liquidation (#1280)

* Remove volatile market (#1263)

* [SKI-21] Bump slinky version to v0.3.1 (#1275)

* Bump slinky version

* Add cp number method

* clean up socks logging (#1285)

* [CT-681] fix liquidated side and offsetting side for indexer delevera… (#1284)

* [CT-681] fix liquidated side and offsetting side for indexer deleveraging events

* fix test

* fix test

* fix lint

* [TRA-105] Add API for parent subaccount perpetual positions (#1282)


Signed-off-by: Shrenuj Bansal <[email protected]>

* Use sample rate with stream destroyed stats. (#1294)

* Revert "[CT-708] Indexer track e2e latency (#1237)" (#1292)

This reverts commit 60b94df.

* Fix swagger generation makefile command / regen swagger docs (#1299)

* pull dydx fork to generate swagger properly

* remove the print

* remove vault constants (#1293)

* Remove custom ping message from socks (#1301)

* Add subaccountNumber to the OrderResponseObject (#1296)

Signed-off-by: Shrenuj Bansal <[email protected]>

* sample more metrics (#1304)

* [OTE-256] Add upgrade handler to initialize OI during upgrade handler (#1302)

* Add upgrade handler to initialize OI during upgrade handler

* nits

* Fix lib.ErrorLogWithError: properly pass in args (#1306)

* fix broken tests (#1312)

* Explicitly close websockets on errors (#1290)

* Increase the number of allowed connections to 8000 (#1317)

* [TRA-104] Add parentSubaccountNumber API for orders (#1313)


Signed-off-by: Shrenuj Bansal <[email protected]>

* Improve Slinky logs to prevent unnecessary logs (#1289)

* [SKI-26]: Prevent funding index update with no oracle prices from (#1321)

halting indexer

* Skip equity tier limit check in PlaceShortTermOrder (#1318)

* Skip equity tier limit check in PlaceShortTermOrder

* remove tests

* Add comment

* fix lint (#1323)

---------

Signed-off-by: Shrenuj Bansal <[email protected]>
Co-authored-by: shrenujb <[email protected]>
Co-authored-by: jayy04 <[email protected]>
Co-authored-by: Eric Warehime <[email protected]>
Co-authored-by: vincentwschau <[email protected]>
Co-authored-by: Jonathan Fung <[email protected]>
Co-authored-by: Tian <[email protected]>
Co-authored-by: Teddy Ding <[email protected]>
Co-authored-by: roy-dydx <[email protected]>
Co-authored-by: Christopher-Li <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants