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

[IND-491]: Remove unused lastPrice from perpetual_markets table #813

Merged
merged 1 commit into from
Nov 29, 2023

Conversation

Christopher-Li
Copy link
Contributor

Changelist

Remove unused lastPrice from perpetual_markets table

Test Plan

Updated unit tests. While this is an indexer postgres breaking change, this should not cause any issues since lastPrice is not written to and is always '0' in all markets.

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

@Christopher-Li Christopher-Li added the indexer-postgres-breaking Breaking change for indexer postgres label Nov 28, 2023
Copy link
Contributor

coderabbitai bot commented Nov 28, 2023

Warning

Rate Limit Exceeded

@Christopher-Li has exceeded the limit for the number of files or commits that can be reviewed per hour. Please wait 8 minutes and 37 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between cf6c8e9 and 4c5cd26.

Walkthrough

The recent updates involve the removal of the lastPrice field from various components of a system, likely a trading platform. This field has been dropped from database tables, models, types, test cases, API and WebSocket documentation, and related scripts. A migration file has been added to handle the database schema change, with functions to both remove and potentially restore the lastPrice column. The changes suggest a refactoring or a shift in the data model where lastPrice is no longer required.

Changes

File Path Change Summary
.../__tests__/helpers/constants.ts Removed lastPrice from default perpetual market objects
.../src/db/migrations/.../remove_perpetual_market_last_price.ts Added migration to drop lastPrice column
.../src/models/perpetual-market-model.ts Removed lastPrice field from model class
.../src/types/db-model-types.ts Removed lastPrice type definition
.../src/types/perpetual-market-types.ts Removed lastPrice from perpetual market interfaces and enum
.../src/types/websocket-message-types.ts Removed lastPrice from WebSocket message interface
.../__tests__/lib/request-helpers/... Removed lastPrice from test object
.../public/api-documentation.md Removed lastPrice from API documentation
.../public/websocket-documentation.md Removed lastPrice from WebSocket documentation
.../src/request-helpers/request-transformer.ts Removed lastPrice from response transformer function
.../src/types.ts Removed lastPrice type definition
.../__tests__/helpers/indexer-proto-helpers.ts Removed lastPrice from hardcoded values
.../src/handlers/perpetual-market-handler.ts Removed processing of lastPrice field
.../src/scripts/dydx_perpetual_market_handler.sql Removed setting lastPrice to 0 in SQL script
.../src/lib/athena-ddl-tables/perpetual_markets.ts Changed lastPrice field handling in DDL

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

Note: For conversation with the bot, please use the review comments on code diffs or files.

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

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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between cf6c8e9 and 4ea1070.
Files ignored due to filter (1)
  • indexer/services/comlink/public/swagger.json
Files selected for processing (15)
  • indexer/packages/postgres/tests/helpers/constants.ts (3 hunks)
  • indexer/packages/postgres/src/db/migrations/migration_files/20231128171435_remove_perpetual_market_last_price.ts (1 hunks)
  • indexer/packages/postgres/src/models/perpetual-market-model.ts (4 hunks)
  • indexer/packages/postgres/src/types/db-model-types.ts (1 hunks)
  • indexer/packages/postgres/src/types/perpetual-market-types.ts (3 hunks)
  • indexer/packages/postgres/src/types/websocket-message-types.ts (1 hunks)
  • indexer/services/comlink/tests/lib/request-helpers/request-transformer.test.ts (1 hunks)
  • indexer/services/comlink/public/api-documentation.md (6 hunks)
  • indexer/services/comlink/public/websocket-documentation.md (3 hunks)
  • indexer/services/comlink/src/request-helpers/request-transformer.ts (1 hunks)
  • indexer/services/comlink/src/types.ts (1 hunks)
  • indexer/services/ender/tests/helpers/indexer-proto-helpers.ts (1 hunks)
  • indexer/services/ender/src/handlers/perpetual-market-handler.ts (1 hunks)
  • indexer/services/ender/src/scripts/dydx_perpetual_market_handler.sql (2 hunks)
  • indexer/services/roundtable/src/lib/athena-ddl-tables/perpetual_markets.ts (2 hunks)
Files skipped from review due to trivial changes (11)
  • indexer/packages/postgres/tests/helpers/constants.ts
  • indexer/packages/postgres/src/models/perpetual-market-model.ts
  • indexer/packages/postgres/src/types/db-model-types.ts
  • indexer/packages/postgres/src/types/perpetual-market-types.ts
  • indexer/packages/postgres/src/types/websocket-message-types.ts
  • indexer/services/comlink/tests/lib/request-helpers/request-transformer.test.ts
  • indexer/services/comlink/public/api-documentation.md
  • indexer/services/comlink/public/websocket-documentation.md
  • indexer/services/comlink/src/request-helpers/request-transformer.ts
  • indexer/services/comlink/src/types.ts
  • indexer/services/ender/tests/helpers/indexer-proto-helpers.ts
Additional comments: 4
indexer/services/ender/src/handlers/perpetual-market-handler.ts (1)
  • 94-99: The removal of the lastPrice field from the getPerpetualMarketCreateObject method aligns with the overall goal of the pull request to remove the unused lastPrice from the codebase. Ensure that any external systems or services that rely on the output of this method are also updated to handle the absence of the lastPrice field.
indexer/services/ender/src/scripts/dydx_perpetual_market_handler.sql (2)
  • 14-19: The changes in this hunk do not show the removal of the lastPrice field, but the summary indicates that it should be removed. Ensure that the lastPrice field is indeed removed from the perpetual_market_record and that any code handling this field is also updated accordingly.

  • 17-19: The fields priceChange24H, trades24H, and volume24H are being set to 0. If these are placeholders for future implementation, consider adding a comment to clarify their purpose. If they are meant to be initialized to 0 and updated later, ensure that there is logic elsewhere in the code to update these values accordingly.

indexer/services/roundtable/src/lib/athena-ddl-tables/perpetual_markets.ts (1)
  • 31-33: The summary states that the lastPrice column is being removed, but the hunk shows a cast to double being added for other fields. Please verify that the changes in the hunk are consistent with the intended removal of the lastPrice column and update the summary or the code accordingly.

return knex
.schema
.alterTable('perpetual_markets', (table) => {
table.decimal('lastPrice', null).defaultTo('0').notNullable();
Copy link
Contributor

Choose a reason for hiding this comment

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

The 'down' migration function should specify the precision and scale for the decimal type of the 'lastPrice' column to ensure that it matches the original column specification before it was dropped.

-      table.decimal('lastPrice', null).defaultTo('0').notNullable();
+      table.decimal('lastPrice', precision, scale).defaultTo('0').notNullable();

Replace precision and scale with the appropriate values that were used when the 'lastPrice' column was originally created.


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
table.decimal('lastPrice', null).defaultTo('0').notNullable();
table.decimal('lastPrice', precision, scale).defaultTo('0').notNullable();

@Christopher-Li Christopher-Li merged commit d6fa5fd into main Nov 29, 2023
11 checks passed
@Christopher-Li Christopher-Li deleted the cl_remove_lastPrice branch November 29, 2023 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
indexer indexer-postgres-breaking Breaking change for indexer postgres
Development

Successfully merging this pull request may close these issues.

3 participants