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-98] Update upper limit of subaccount number constraint #1164

Merged
merged 3 commits into from
Mar 11, 2024
Merged

Conversation

shrenujb
Copy link
Contributor

Changelist

Increase upper limit of subaccount number to 128,000 to allow for isolated margin subaccounts

Test Plan

Unit tests

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.

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

linear bot commented Mar 11, 2024

Copy link
Contributor

coderabbitai bot commented Mar 11, 2024

Walkthrough

The changes involve expanding the maximum number of allowable subaccount IDs in the system from 127 to 128,000, significantly broadening the range of valid subaccount IDs. Test cases were adjusted to align with this change, considering a subaccount ID of 128,001 as invalid due to the new maximum limit.

Changes

Files Change Summary
.../subaccounts/types/subaccount.go,
.../subaccounts/types/subaccount_test.go,
.../proto/dydxprotocol/subaccounts/subaccount.proto
- Updated MaxSubaccountIdNumber from 127 to 128,000.
- Adjusted test case in subaccount_test.go for an invalid number.
.../clob/types/message_cancel_order_test.go,
.../clob/types/message_place_order_test.go,
.../sending/types/message_create_transfer_test.go
- Modified Number field values within various test functions.
.../subaccounts/module_test.go,
.../subaccounts/types/errors.go,
.../subaccounts/types/genesis_test.go
- Added imports and updated test cases.
- Adjusted error message and formatting.
- Updated test case in genesis_test.go.

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-tests 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 tests 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 tests.
    • @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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 340801a and 459f7fb.
Files selected for processing (2)
  • protocol/x/subaccounts/types/subaccount.go (1 hunks)
  • protocol/x/subaccounts/types/subaccount_test.go (1 hunks)
Additional comments: 2
protocol/x/subaccounts/types/subaccount.go (1)
  • 14-14: The update to MaxSubaccountIdNumber from 127 to 128,000 is clear and aligns with the PR's objectives to accommodate a larger range of subaccount numbers. Ensure that the broader implications of this change on system performance and storage have been considered.
protocol/x/subaccounts/types/subaccount_test.go (1)
  • 56-56: The update to the test case for an "invalid number" in TestSubaccountIdValidate correctly reflects the new upper limit of subaccount numbers. Ensure that all related test cases are updated to comprehensively test the new range of valid subaccount numbers.

Signed-off-by: Shrenuj Bansal <shrenuj@dydx.exchange>
@github-actions github-actions bot added the proto label Mar 11, 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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 459f7fb and 19741a9.
Files ignored due to path filters (1)
  • protocol/x/subaccounts/types/subaccount.pb.go is excluded by: !**/*.pb.go
Files selected for processing (7)
  • proto/dydxprotocol/subaccounts/subaccount.proto (1 hunks)
  • protocol/x/clob/types/message_cancel_order_test.go (1 hunks)
  • protocol/x/clob/types/message_place_order_test.go (1 hunks)
  • protocol/x/sending/types/message_create_transfer_test.go (2 hunks)
  • protocol/x/subaccounts/module_test.go (2 hunks)
  • protocol/x/subaccounts/types/errors.go (2 hunks)
  • protocol/x/subaccounts/types/genesis_test.go (2 hunks)
Additional comments: 11
proto/dydxprotocol/subaccounts/subaccount.proto (1)
  • 14-15: The comment update on lines 14-15 clearly communicates the new upper limit for subaccount numbers per owner, aligning with the PR's objective to increase the limit to 128,000. This change enhances the documentation for future reference and is consistent with the PR's goals.
protocol/x/subaccounts/types/errors.go (2)
  • 5-8: The addition of imports on lines 5-8 is appropriate and necessary for the subsequent changes in this file. The imported packages are used for error handling and converting integer values to strings, which is crucial for the dynamic error message introduced later.
  • 24-28: The modification of the ErrInvalidSubaccountIdNumber error message on lines 24-28 to include a dynamic value (MaxSubaccountIdNumber) is a significant improvement. It ensures that the error message remains accurate even if the maximum subaccount ID number changes in the future. This change enhances maintainability and clarity for developers and users.
protocol/x/clob/types/message_cancel_order_test.go (1)
  • 32-32: The change on line 32, updating the Number field value from 9999 to 999_999 in the test case, aligns with the PR's objective to increase the upper limit of subaccount numbers. This adjustment ensures that the test reflects the new constraints and continues to validate the system's behavior correctly.
protocol/x/sending/types/message_create_transfer_test.go (2)
  • 52-52: The update on line 52, changing the Number field value for Sender from 9999 to 999_999, correctly reflects the new upper limit for subaccount numbers. This change ensures the test remains relevant and accurately assesses the system's behavior under the updated constraints.
  • 66-66: Similarly, the change on line 66 for the Recipient's Number field value to 999_999 is consistent with the PR's objectives and the updated subaccount number constraints. It's crucial for maintaining the accuracy and relevance of the test coverage.
protocol/x/subaccounts/types/genesis_test.go (2)
  • 6-7: The adjustment in the import order on lines 6-7, moving errorsmod "cosmossdk.io/errors" to a different position, is a minor change that does not impact the functionality. However, maintaining a consistent and logical import order can improve code readability.
  • 89-95: The modification of the test case on lines 89-95 to check for an id number greater than 128_000 instead of 128 is crucial for validating the new upper limit for subaccount numbers. This change ensures that the test accurately reflects the updated constraints and continues to provide meaningful coverage.
protocol/x/subaccounts/module_test.go (2)
  • 12-14: The addition of imports for lib and types on lines 12-14 is necessary for the subsequent changes in this file, particularly for using lib.IntToString in the dynamic error message comparison. This ensures the test remains accurate and maintainable.
  • 138-142: The update to the test case on lines 138-142, using a different subaccount number (128001) and comparing it dynamically against types.MaxSubaccountIdNumber, is a significant improvement. It ensures the test remains relevant under the new subaccount number constraints and accurately assesses the system's behavior.
protocol/x/clob/types/message_place_order_test.go (1)
  • 35-35: The change on line 35, updating the Number value in the SubaccountId struct from 9999 to 999_999, aligns with the PR's objective to increase the upper limit of subaccount numbers. This adjustment ensures that the test reflects the new constraints and continues to validate the system's behavior correctly.

Signed-off-by: Shrenuj Bansal <shrenuj@dydx.exchange>
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: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 19741a9 and e437327.
Files selected for processing (1)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/subaccounts/subaccount.ts (2 hunks)

Comment on lines +11 to +12
* The unique number of this subaccount for the owner.
* Currently limited to 128*1000 subaccounts per owner.
Copy link
Contributor

Choose a reason for hiding this comment

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

The updated description for the number field in the SubaccountId interface correctly reflects the new limit of 128,000 subaccounts per owner. However, for better readability and to avoid potential confusion, consider explicitly stating the number "128,000" instead of "128*1000".

- Currently limited to 128*1000 subaccounts per owner.
+ Currently limited to 128,000 subaccounts per owner.

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
* The unique number of this subaccount for the owner.
* Currently limited to 128*1000 subaccounts per owner.
* The unique number of this subaccount for the owner.
* Currently limited to 128,000 subaccounts per owner.

Comment on lines +23 to +24
* The unique number of this subaccount for the owner.
* Currently limited to 128*1000 subaccounts per owner.
Copy link
Contributor

Choose a reason for hiding this comment

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

The updated description for the number field in the SubaccountIdSDKType interface correctly reflects the new limit of 128,000 subaccounts per owner. For consistency with the previous comment and to enhance readability, consider explicitly stating the number "128,000" instead of "128*1000".

- Currently limited to 128*1000 subaccounts per owner.
+ Currently limited to 128,000 subaccounts per owner.

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
* The unique number of this subaccount for the owner.
* Currently limited to 128*1000 subaccounts per owner.
* The unique number of this subaccount for the owner.
* Currently limited to 128,000 subaccounts per owner.

@shrenujb shrenujb merged commit 525bb6f into main Mar 11, 2024
33 checks passed
@shrenujb shrenujb deleted the tra98 branch March 11, 2024 22:55
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