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

Skip equity tier limit check in PlaceShortTermOrder #1318

Merged
merged 3 commits into from
Apr 3, 2024
Merged

Conversation

roy-dydx
Copy link
Contributor

@roy-dydx roy-dydx commented Apr 2, 2024

Changelist

These checks are not effective for their original purpose and take 30% of the CheckTx global lock time in testnet loads.

Test Plan

image

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
Contributor

coderabbitai bot commented Apr 2, 2024

Walkthrough

The recent updates focus on simplifying the order placement process within a trading protocol by adjusting how equity tier limits impact order placements. These changes involve removing validations for subaccount equity tier limits during short-term order placements and modifying related test cases. This streamlines the order placement process by eliminating certain checks for equity tiers, impacting both functionality and testing of order placements and cancellations based on these limits.

Changes

Files Change Summary
.../clob/e2e/equity_tier_limit_test.go,
.../clob/keeper/orders_test.go
Modified and removed test cases related to order placements and cancellations based on equity tier limits. Adjusted scenarios for order limits across and within blocks. Removed maker buy and sell order tests for BTC trades based on collateral and pricing.
.../clob/keeper/orders.go Removed validation check for subaccount equity tier limits before placing a short-term order.
.../clob/keeper/equity_tier_limit.go Deprecated and removed functionality related to equity tier limits for short-term orders. Updated ValidateSubaccountEquityTierLimitForShortTermOrder function with deprecation notice.

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/coderabbit-overrides.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: 2

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e88d637 and d6492b0.
Files selected for processing (3)
  • protocol/x/clob/e2e/equity_tier_limit_test.go (8 hunks)
  • protocol/x/clob/keeper/orders.go (1 hunks)
  • protocol/x/clob/keeper/orders_test.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • protocol/x/clob/keeper/orders_test.go
Additional Context Used
Path-based Instructions (2)
protocol/x/clob/e2e/equity_tier_limit_test.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.

protocol/x/clob/keeper/orders.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.

Additional comments not posted (3)
protocol/x/clob/e2e/equity_tier_limit_test.go (2)

10-10: Ensure that the logic for order expiry, especially in the context of equity tier limits, is still valid and necessary after the removal of equity tier limit checks. If the concept of order expiry is tightly coupled with equity tier limits, consider if adjustments or additional tests are needed to reflect the new system behavior without these checks.


10-10: With the removal of equity tier limit checks, reassess the necessity and accuracy of tests related to order fills in the context of equity tier limits. If these tests are still relevant, ensure they accurately reflect the system's behavior without the equity tier limit checks. Otherwise, consider adjusting or removing these tests to align with the updated system logic.

protocol/x/clob/keeper/orders.go (1)

208-213: > 📝 NOTE

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

Ensure all newly introduced or modified functions, especially those related to order processing and validation, are accompanied by corresponding unit tests. This is crucial for verifying the correctness of the changes and maintaining the reliability of the system. Additionally, review the error handling strategies across the file to ensure they are consistent and robust, particularly in functions that interact with external systems or perform critical operations.

Would you like assistance in creating additional unit tests or reviewing error handling strategies?

Comment on lines 208 to 213
return 0, 0, err
}

// Validate that adding the order wouldn't exceed subaccount equity tier limits.
err = k.ValidateSubaccountEquityTierLimitForShortTermOrder(ctx, order)
if err != nil {
return 0, 0, err
}

// Place the order on the memclob and return the result.
orderSizeOptimisticallyFilledFromMatchingQuantums, orderStatus, offchainUpdates, err := k.MemClob.PlaceOrder(
ctx,
Copy link
Contributor

Choose a reason for hiding this comment

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

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [285-357]

The removal of the equity tier limit validation from the PlaceShortTermOrder function aligns with the PR objectives to optimize performance by eliminating ineffective checks. Ensure that this change has been thoroughly tested, especially in scenarios where equity tier limits might have previously impacted order placements. Additionally, consider documenting this change prominently in the function's comments or in the project's change log to maintain clarity for future maintainers and users.

@@ -2,6 +2,9 @@ package clob_test

import (
"fmt"
"testing"
"time"

"github.com/cometbft/cometbft/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/dydxprotocol/v4-chain/protocol/dtypes"
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Given the widespread references to equity tier limits across various parts of the codebase, including protobuf definitions, configuration files, keeper logic, and end-to-end tests, it is evident that other functionalities or tests do rely on equity tier limits for critical operations. The removal of these checks needs careful consideration to ensure it does not inadvertently affect these interconnected parts of the system.

Analysis chain

Given the PR's objective to remove equity tier limit checks, ensure that the removal of these checks does not inadvertently affect other functionalities or tests that might still rely on the concept of equity tiers for validation or setup. It's crucial to verify that the removal aligns with the overall system design and does not introduce unintended side effects.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that no other functionalities or tests rely on equity tier limits for critical operations.
rg "equityTierLimit" --type go

Length of output: 6576

@@ -208,12 +208,6 @@ func (k Keeper) PlaceShortTermOrder(
return 0, 0, err
}

// Validate that adding the order wouldn't exceed subaccount equity tier limits.
err = k.ValidateSubaccountEquityTierLimitForShortTermOrder(ctx, order)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

remove the comment on line 170

Copy link
Contributor

Choose a reason for hiding this comment

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

we also technically dont use ValidateSubaccountEquityTierLimitForShortTermOrder anymore maybe add a comment that we removed the sa eq tier check for short term orders on check tx to that fn or just del

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK I marked it as deprecated.

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 d6492b0 and f1260be.
Files selected for processing (1)
  • protocol/x/clob/keeper/equity_tier_limit.go (1 hunks)
Additional Context Used
Path-based Instructions (1)
protocol/x/clob/keeper/equity_tier_limit.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.

Additional comments not posted (1)
protocol/x/clob/keeper/equity_tier_limit.go (1)

98-99: The deprecation notice for ValidateSubaccountEquityTierLimitForShortTermOrder is clear and well-documented.

However, consider adding guidance for developers on handling short-term orders without equity tier limits, if there's a new mechanism in place.

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 d6492b0 and 10364d5.
Files selected for processing (2)
  • protocol/x/clob/keeper/equity_tier_limit.go (1 hunks)
  • protocol/x/clob/keeper/orders.go (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • protocol/x/clob/keeper/equity_tier_limit.go
  • protocol/x/clob/keeper/orders.go

@roy-dydx roy-dydx merged commit 24790ff into main Apr 3, 2024
15 of 17 checks passed
@roy-dydx roy-dydx deleted the roy/equitytier branch April 3, 2024 03:13
dydxwill added a commit that referenced this pull request Apr 3, 2024
* Add subaccountNumber to PerpetualPositionResponseObject (#1274)

Signed-off-by: Shrenuj Bansal <shrenuj@dydx.exchange>

* [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 <shrenuj@dydx.exchange>

* 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 <shrenuj@dydx.exchange>

* 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 <shrenuj@dydx.exchange>

* 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 <shrenuj@dydx.exchange>
Co-authored-by: shrenujb <98204323+shrenujb@users.noreply.github.com>
Co-authored-by: jayy04 <103467857+jayy04@users.noreply.github.com>
Co-authored-by: Eric Warehime <eric.warehime@gmail.com>
Co-authored-by: vincentwschau <99756290+vincentwschau@users.noreply.github.com>
Co-authored-by: Jonathan Fung <121899091+jonfung-dydx@users.noreply.github.com>
Co-authored-by: Tian <tian@dydx.exchange>
Co-authored-by: Teddy Ding <teddy@dydx.exchange>
Co-authored-by: roy-dydx <133032749+roy-dydx@users.noreply.github.com>
Co-authored-by: Christopher-Li <Christopher-Li@users.noreply.github.com>
roy-dydx added a commit that referenced this pull request May 14, 2024
* Skip equity tier limit check in PlaceShortTermOrder

* remove tests

* Add comment
@roy-dydx
Copy link
Contributor Author

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

Copy link
Contributor

mergify bot commented May 14, 2024

backport release/protocol/v4.1.x

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request May 14, 2024
* Skip equity tier limit check in PlaceShortTermOrder

* remove tests

* Add comment

(cherry picked from commit 24790ff)

# Conflicts:
#	protocol/x/clob/e2e/equity_tier_limit_test.go
#	protocol/x/clob/keeper/equity_tier_limit.go
#	protocol/x/clob/keeper/orders.go
roy-dydx added a commit that referenced this pull request May 14, 2024
…1516)

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

* Skip equity tier limit check in PlaceShortTermOrder

* remove tests

* Add comment

(cherry picked from commit 24790ff)

# Conflicts:
#	protocol/x/clob/e2e/equity_tier_limit_test.go
#	protocol/x/clob/keeper/equity_tier_limit.go
#	protocol/x/clob/keeper/orders.go

* resolve conflict

---------

Co-authored-by: roy-dydx <133032749+roy-dydx@users.noreply.github.com>
Co-authored-by: Roy Li <roy@dydx.exchange>
@roy-dydx
Copy link
Contributor Author

https://github.com/Mergifyio backport release/protocol/v5.x

Copy link
Contributor

mergify bot commented May 20, 2024

backport release/protocol/v5.x

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request May 20, 2024
* Skip equity tier limit check in PlaceShortTermOrder

* remove tests

* Add comment

(cherry picked from commit 24790ff)
roy-dydx added a commit that referenced this pull request May 20, 2024
…1549)

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

* Skip equity tier limit check in PlaceShortTermOrder

* remove tests

* Add comment

(cherry picked from commit 24790ff)

* Fix lint

---------

Co-authored-by: roy-dydx <133032749+roy-dydx@users.noreply.github.com>
Co-authored-by: Roy Li <roy@dydx.exchange>
tqin7 pushed a commit that referenced this pull request May 23, 2024
…1549)

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

* Skip equity tier limit check in PlaceShortTermOrder

* remove tests

* Add comment

(cherry picked from commit 24790ff)

* Fix lint

---------

Co-authored-by: roy-dydx <133032749+roy-dydx@users.noreply.github.com>
Co-authored-by: Roy Li <roy@dydx.exchange>
tqin7 pushed a commit that referenced this pull request May 24, 2024
…1549)

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

* Skip equity tier limit check in PlaceShortTermOrder

* remove tests

* Add comment

(cherry picked from commit 24790ff)

* Fix lint

---------

Co-authored-by: roy-dydx <133032749+roy-dydx@users.noreply.github.com>
Co-authored-by: Roy Li <roy@dydx.exchange>
tqin7 pushed a commit that referenced this pull request May 24, 2024
…1549)

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

* Skip equity tier limit check in PlaceShortTermOrder

* remove tests

* Add comment

(cherry picked from commit 24790ff)

* Fix lint

---------

Co-authored-by: roy-dydx <133032749+roy-dydx@users.noreply.github.com>
Co-authored-by: Roy Li <roy@dydx.exchange>
roy-dydx added a commit that referenced this pull request May 24, 2024
…1549)

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

* Skip equity tier limit check in PlaceShortTermOrder

* remove tests

* Add comment

(cherry picked from commit 24790ff)

* Fix lint

---------

Co-authored-by: roy-dydx <133032749+roy-dydx@users.noreply.github.com>
Co-authored-by: Roy Li <roy@dydx.exchange>
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