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

[TRA-195] Add new error code to be returned when orders fail isolated subaccount checks. #1331

Merged

Conversation

vincentwschau
Copy link
Contributor

@vincentwschau vincentwschau commented Apr 4, 2024

Changelist

Updated returned error for FOK / stateful orders when isolated subaccount checks fail.
Added new removal reason for orders that fail the isolated subaccount constraint checks.
Renamed AddOrderToOrderbookCollatCheck to AddOrdertoOrderbookSubaccountUpdatesCheck to indicate the check is more than for collateralization, but also any other constraints on the resulting subaccount updates.

Test Plan

Added E2E test cases.

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 Apr 4, 2024

Copy link
Contributor

coderabbitai bot commented Apr 4, 2024

Walkthrough

The recent updates focus on enhancing order handling within a trading protocol, particularly for isolated subaccount orders. New order definitions for specific users were added, alongside improvements in error handling for order collateralization and status violations. A significant addition is the error type ErrWouldViolateIsolatedSubaccountConstraints, designed to address scenarios where orders could breach isolated subaccount constraints. The changes span across various components, including test utilities, order placement and matching logic, and error management, aiming to refine the system's robustness and clarity in order operations.

Changes

Files Change Summary
protocol/testutil/constants/orders.go Added new order definitions for Bob and Alice.
protocol/x/clob/e2e/isolated_subaccount_orders_test.go
protocol/x/clob/keeper/orders.go
protocol/x/clob/memclob/memclob.go
protocol/x/clob/types/errors.go
protocol/x/clob/types/orderbook.go
protocol/x/subaccounts/types/update.go
- Introduced ErrWouldViolateIsolatedSubaccountConstraints error type and handling.
- Updated order placement, matching logic, and test cases for improved error management and clarity in isolated subaccount order scenarios.
- Added method to check for isolated subaccount errors.

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

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 39981f1 and 5215906.
Files selected for processing (8)
  • protocol/testutil/constants/orders.go (2 hunks)
  • protocol/x/clob/e2e/isolated_subaccount_orders_test.go (7 hunks)
  • protocol/x/clob/keeper/orders.go (1 hunks)
  • protocol/x/clob/memclob/memclob.go (3 hunks)
  • protocol/x/clob/types/errors.go (1 hunks)
  • protocol/x/clob/types/orderbook.go (2 hunks)
  • protocol/x/clob/types/orderbook_test.go (1 hunks)
  • protocol/x/subaccounts/types/update.go (1 hunks)
Additional Context Used
Path-based Instructions (8)
protocol/x/clob/types/orderbook_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/subaccounts/types/update.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/types/orderbook.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/types/errors.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/e2e/isolated_subaccount_orders_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.

protocol/testutil/constants/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.

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

Learnings (1)
protocol/x/clob/memclob/memclob.go (1)
User: jonfung-dydx"
PR: dydxprotocol/v4-chain#1009
File: protocol/x/clob/memclob/memclob_place_order_test.go:4108-4108
Timestamp: 2024-02-05T20:01:55.204Z
Learning: The `assertPlaceOrderOffchainMessages` function in `memclob_test_util.go` indeed requires `ctx` as a parameter for its operations, contrary to the initial comment made.
Additional comments not posted (10)
protocol/x/clob/types/orderbook_test.go (1)

81-85: LGTM! The test case for "ViolatesIsolatedSubaccountConstraints" correctly follows the established pattern for testing OrderStatus string representations.

protocol/x/subaccounts/types/update.go (1)

26-28: LGTM! The method IsIsolatedSubaccountError() correctly implements the functionality to check for isolated subaccount errors, following established patterns.

protocol/x/clob/types/orderbook.go (1)

185-189: LGTM! The addition of the constant ViolatesIsolatedSubaccountConstraints to the OrderStatus enum is correctly implemented and follows established naming conventions.

protocol/x/clob/types/errors.go (1)

359-363: LGTM! The error ErrWouldViolateIsolatedSubaccountContraints is correctly registered with a unique code and a descriptive message, following established error definition patterns.

protocol/x/clob/e2e/isolated_subaccount_orders_test.go (4)

38-46: Ensure the new order placement PlaceOrder_Alice_Num0_Id0_Clob3_Buy_1ISO_Price10_GTB5_FOK is correctly used in the test cases to validate the behavior of Fill-or-Kill orders in isolated subaccount scenarios.


55-66: Verify that the long-term order definition LongTermOrder_Alice_Num0_Id0_Clob3_Buy_1ISO_Price5_GTBT5 is appropriately utilized in test scenarios to assess the handling of long-term orders in isolated subaccount contexts.


365-366: Ensure the use of sdkerrors.ErrPanic.ABCICode() is appropriate for the test case scenarios where insufficient funds are expected. Consider if a more specific error code should be used to reflect the scenario accurately.


444-445: Confirm that the test case Subaccount with isolated perpetual position fails to place stateful order for non-isolated perpetual correctly asserts the new error code ErrWouldViolateIsolatedSubaccountContraints and provides a meaningful error message.

protocol/testutil/constants/orders.go (1)

403-408: Consider adding a comment above Order_Bob_Num0_Id0_Clob0_Sell1BTC_Price50000_GTB10 to describe its purpose or scenario it's used for, similar to other orders in this file for consistency and clarity.

protocol/x/clob/memclob/memclob.go (1)

2030-2033: The mapping from satypes.UpdateResult to types.OrderStatus in updateResultToOrderStatus should be exhaustive to cover all possible UpdateResult values. Ensure that all cases are handled appropriately to prevent unexpected behavior.

protocol/x/clob/keeper/orders.go Outdated Show resolved Hide resolved
protocol/x/clob/e2e/isolated_subaccount_orders_test.go Outdated Show resolved Hide resolved
protocol/x/clob/memclob/memclob.go Outdated Show resolved Hide resolved
protocol/x/clob/memclob/memclob.go Outdated Show resolved Hide resolved
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 5215906 and 0c66d42.
Files selected for processing (1)
  • protocol/x/clob/memclob/memclob.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • protocol/x/clob/memclob/memclob.go

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 0c66d42 and 052d492.
Files selected for processing (16)
  • protocol/mocks/ClobKeeper.go (2 hunks)
  • protocol/mocks/MemClobKeeper.go (2 hunks)
  • protocol/mocks/mocks/CacheMultiStore.go (1 hunks)
  • protocol/mocks/mocks/MultiStore.go (1 hunks)
  • protocol/testutil/memclob/keeper.go (1 hunks)
  • protocol/x/clob/e2e/isolated_subaccount_orders_test.go (7 hunks)
  • protocol/x/clob/keeper/orders.go (3 hunks)
  • protocol/x/clob/keeper/process_operations.go (1 hunks)
  • protocol/x/clob/memclob/memclob.go (6 hunks)
  • protocol/x/clob/memclob/memclob_get_order_filled_amount_test.go (1 hunks)
  • protocol/x/clob/memclob/memclob_place_order_test.go (2 hunks)
  • protocol/x/clob/memclob/memclob_purge_invalid_memclob_state_test.go (1 hunks)
  • protocol/x/clob/memclob/memclob_remove_order_test.go (1 hunks)
  • protocol/x/clob/types/clob_keeper.go (1 hunks)
  • protocol/x/clob/types/errors.go (1 hunks)
  • protocol/x/clob/types/mem_clob_keeper.go (1 hunks)
Files skipped from review due to trivial changes (2)
  • protocol/mocks/mocks/CacheMultiStore.go
  • protocol/mocks/mocks/MultiStore.go
Files skipped from review as they are similar to previous changes (4)
  • protocol/x/clob/e2e/isolated_subaccount_orders_test.go
  • protocol/x/clob/keeper/orders.go
  • protocol/x/clob/memclob/memclob.go
  • protocol/x/clob/types/errors.go
Additional Context Used
Path-based Instructions (10)
protocol/x/clob/memclob/memclob_get_order_filled_amount_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/types/mem_clob_keeper.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/types/clob_keeper.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/testutil/memclob/keeper.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/mocks/MemClobKeeper.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/memclob/memclob_purge_invalid_memclob_state_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/memclob/memclob_remove_order_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/process_operations.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/mocks/ClobKeeper.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/memclob/memclob_place_order_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.

Learnings (3)
protocol/x/clob/memclob/memclob_purge_invalid_memclob_state_test.go (1)
User: jonfung-dydx"
PR: dydxprotocol/v4-chain#1009
File: protocol/x/clob/memclob/memclob_place_order_test.go:4108-4108
Timestamp: 2024-02-05T20:01:55.204Z
Learning: The `assertPlaceOrderOffchainMessages` function in `memclob_test_util.go` indeed requires `ctx` as a parameter for its operations, contrary to the initial comment made.
protocol/x/clob/memclob/memclob_remove_order_test.go (1)
User: jonfung-dydx"
PR: dydxprotocol/v4-chain#1009
File: protocol/x/clob/memclob/memclob_place_order_test.go:4108-4108
Timestamp: 2024-02-05T20:01:55.204Z
Learning: The `assertPlaceOrderOffchainMessages` function in `memclob_test_util.go` indeed requires `ctx` as a parameter for its operations, contrary to the initial comment made.
protocol/x/clob/memclob/memclob_place_order_test.go (1)
User: jonfung-dydx"
PR: dydxprotocol/v4-chain#1009
File: protocol/x/clob/memclob/memclob_place_order_test.go:4108-4108
Timestamp: 2024-02-05T20:01:55.204Z
Learning: The `assertPlaceOrderOffchainMessages` function in `memclob_test_util.go` indeed requires `ctx` as a parameter for its operations, contrary to the initial comment made.
Additional comments not posted (14)
protocol/x/clob/memclob/memclob_get_order_filled_amount_test.go (1)

49-49: The change from AddOrderToOrderbookCollatCheck to AddOrderToOrderbookSubaccountUpdatesCheck correctly reflects the PR's objective to enhance error handling for isolated subaccount checks.

protocol/x/clob/types/mem_clob_keeper.go (1)

32-32: Renaming AddOrderToOrderbookCollatCheck to AddOrderToOrderbookSubaccountUpdatesCheck in the interface aligns with the PR's goal of enhancing error handling for isolated subaccount checks.

protocol/x/clob/types/clob_keeper.go (1)

17-17: Renaming AddOrderToOrderbookCollatCheck to AddOrderToOrderbookSubaccountUpdatesCheck in the ClobKeeper interface is consistent with the PR's objectives to improve error handling for isolated subaccount checks.

protocol/testutil/memclob/keeper.go (1)

287-287: Renaming AddOrderToOrderbookCollatCheck to AddOrderToOrderbookSubaccountUpdatesCheck in the FakeMemClobKeeper struct aligns with the PR's goal of enhancing error handling for isolated subaccount checks.

protocol/mocks/MemClobKeeper.go (1)

27-27: Renaming AddOrderToOrderbookCollatCheck to AddOrderToOrderbookSubaccountUpdatesCheck in the autogenerated mock file is consistent with the PR's objectives to improve error handling for isolated subaccount checks.

protocol/x/clob/memclob/memclob_purge_invalid_memclob_state_test.go (1)

269-269: Ensure the new functionality introduced by AddOrderToOrderbookSubaccountUpdatesCheck is thoroughly tested, particularly focusing on subaccount updates and their impact on order handling.

Verification successful

The method AddOrderToOrderbookSubaccountUpdatesCheck is referenced in multiple test files, indicating that the functionality it introduces is being tested across different scenarios within the memclob module. This suggests that the review comment regarding the need for thorough testing of the new functionality has been addressed. However, for a comprehensive evaluation of the test coverage and quality, a manual review of these tests is recommended.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify if specific tests for AddOrderToOrderbookSubaccountUpdatesCheck exist
rg "AddOrderToOrderbookSubaccountUpdatesCheck" --type go | grep -i "test"

Length of output: 1009

protocol/x/clob/memclob/memclob_remove_order_test.go (1)

330-330: Ensure the new functionality introduced by AddOrderToOrderbookSubaccountUpdatesCheck is thoroughly tested, especially in the context of order removal, to maintain the integrity of the memclob state.

protocol/mocks/ClobKeeper.go (1)

27-32: The renaming and implementation of AddOrderToOrderbookSubaccountUpdatesCheck align well with the PR's objectives and Go best practices.

protocol/x/clob/memclob/memclob_place_order_test.go (6)

2859-2859: Ensure that the test case for TestAddOrderToOrderbook_PanicsIfFullyFilled accurately reflects the expected behavior of the system when an order is already fully filled. It's crucial to verify that the system handles this scenario gracefully without causing unexpected panics in production.


2822-2828: > 📝 NOTE

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

The test cases TestAddOrderToOrderbook_ErrorPlaceNewFullyFilledOrder and TestAddOrderToOrderbook_PanicsIfFullyFilled seem to test similar scenarios but with different outcomes (error vs panic). Ensure consistency in handling fully filled orders across the system to avoid confusion and potential bugs.


2822-2828: > 📝 NOTE

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

For the test cases involving panics (TestAddOrderToOrderbook_PanicsOnInvalidSide, TestAddOrderToOrderbook_PanicsOnInvalidClob, TestUpdateOrderbookStateWithMatchedMakerOrder_PanicsOnInvalidFillAmount, TestAddOrderToSubaccountOrders_PanicsOnInvalidSide, TestAddOrderToSubaccountOrders_PanicsOnInvalidClob), consider using require.PanicsWithValue to ensure that the panic message is as expected. This adds an additional layer of verification to ensure that the panic is caused by the expected condition.


2822-2828: > 📝 NOTE

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

The test TestPlaceOrder_Telemetry verifies telemetry metrics are correctly gathered. Ensure that the telemetry setup and teardown are properly handled to avoid side effects on other tests, especially when running tests in parallel or in a shared environment.


2822-2828: > 📝 NOTE

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

In TestPlaceOrder_GenerateOffchainUpdatesFalse_NoMessagesSent, it's good to see a test ensuring no offchain messages are sent when GenerateOffchainUpdates is false. Consider also verifying that the state changes (e.g., order book updates) are still correctly applied to ensure the flag only affects offchain messages.


2822-2828: > 📝 NOTE

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

The test TestPlaceOrder_DuplicateOrder correctly checks for ErrInvalidReplacement when placing a duplicate order. This is crucial for ensuring order uniqueness in the system. Consider adding a test case for a scenario where a duplicate order is placed with a different size or price to verify that it's treated as a new order or correctly rejected based on the system's rules.

Would you like me to generate the additional test case code for handling duplicate orders with different sizes or prices?

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 052d492 and fbee655.
Files ignored due to path filters (1)
  • protocol/indexer/shared/types/removal_reason.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
Files selected for processing (5)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/shared/removal_reason.ts (4 hunks)
  • proto/dydxprotocol/indexer/shared/removal_reason.proto (1 hunks)
  • protocol/indexer/shared/order_removal_reason.go (1 hunks)
  • protocol/indexer/shared/order_removal_reason_test.go (1 hunks)
  • protocol/x/clob/simulation/place_order.go (1 hunks)
Additional Context Used
Path-based Instructions (5)
proto/dydxprotocol/indexer/shared/removal_reason.proto (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/indexer/shared/order_removal_reason_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/indexer/shared/order_removal_reason.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/simulation/place_order.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.

indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/shared/removal_reason.ts (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 (8)
proto/dydxprotocol/indexer/shared/removal_reason.proto (1)

56-58: The addition of ORDER_REMOVAL_REASON_VIOLATES_ISOLATED_SUBACCOUNT_CONSTRAINTS is correctly implemented and follows the existing naming conventions and numeric ordering.

protocol/indexer/shared/order_removal_reason_test.go (1)

38-42: The addition of the test case for ViolatesIsolatedSubaccountConstraints is correctly implemented, aligning with the structure and expectations of existing test cases.

protocol/indexer/shared/order_removal_reason.go (1)

63-64: The addition of the case for clobtypes.ViolatesIsolatedSubaccountConstraints in the GetOrderRemovalReason function is correctly implemented, aligning with the structure and expectations of the switch statement.

protocol/x/clob/simulation/place_order.go (1)

177-178: The addition of the error condition types.ErrWouldViolateIsolatedSubaccountConstraints in the SimulateMsgPlaceOrder function is correctly implemented, aligning with the structure and expectations of the switch statement.

indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/shared/removal_reason.ts (4)

81-86: The addition of ORDER_REMOVAL_REASON_VIOLATES_ISOLATED_SUBACCOUNT_CONSTRAINTS to the OrderRemovalReason enum is correctly implemented and follows the existing naming conventions and numeric ordering.


170-175: The addition of ORDER_REMOVAL_REASON_VIOLATES_ISOLATED_SUBACCOUNT_CONSTRAINTS to the OrderRemovalReasonSDKType enum is correctly implemented and follows the existing naming conventions and numeric ordering.


240-243: The update to orderRemovalReasonFromJSON function to handle ORDER_REMOVAL_REASON_VIOLATES_ISOLATED_SUBACCOUNT_CONSTRAINTS is correctly implemented.


297-299: The update to orderRemovalReasonToJSON function to handle ORDER_REMOVAL_REASON_VIOLATES_ISOLATED_SUBACCOUNT_CONSTRAINTS is correctly implemented.

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 fbee655 and a744f00.
Files selected for processing (3)
  • protocol/mocks/ClobKeeper.go (1 hunks)
  • protocol/x/clob/keeper/orders.go (3 hunks)
  • protocol/x/clob/types/clob_keeper.go (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • protocol/mocks/ClobKeeper.go
  • protocol/x/clob/keeper/orders.go
  • protocol/x/clob/types/clob_keeper.go

@vincentwschau vincentwschau merged commit 360ee9c into main Apr 4, 2024
32 checks passed
@vincentwschau vincentwschau deleted the vincentc/tra-195-fok-stateful-isolated-subaccount-errors branch April 4, 2024 22:00
@vincentwschau vincentwschau restored the vincentc/tra-195-fok-stateful-isolated-subaccount-errors branch April 4, 2024 22:08
@vincentwschau
Copy link
Contributor Author

@Mergifyio backport release/protocol/v5.x

Copy link
Contributor

mergify bot commented Apr 4, 2024

backport release/protocol/v5.x

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Apr 4, 2024
vincentwschau added a commit that referenced this pull request Apr 4, 2024
… subaccount checks. (#1331) (#1341)

(cherry picked from commit 360ee9c)

Co-authored-by: vincentwschau <99756290+vincentwschau@users.noreply.github.com>
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