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

include client ids in vault query #2328

Merged
merged 1 commit into from
Sep 24, 2024
Merged

include client ids in vault query #2328

merged 1 commit into from
Sep 24, 2024

Conversation

tqin7
Copy link
Contributor

@tqin7 tqin7 commented Sep 23, 2024

Changelist

expose client ids in vault query so we more easily know a vault's orders

Test Plan

unit tests
localnet testing

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.

Summary by CodeRabbit

  • New Features

    • Introduced a new field, MostRecentClientIds, in the vault query response, allowing retrieval of the most recent client IDs associated with a vault.
  • Bug Fixes

    • Enhanced the response structure to ensure accurate data delivery regarding client IDs in vault queries.
  • Tests

    • Updated test cases to validate the inclusion of MostRecentClientIds in the vault query responses, ensuring comprehensive coverage of various scenarios.

@tqin7 tqin7 requested a review from a team as a code owner September 23, 2024 21:30
Copy link

linear bot commented Sep 23, 2024

Copy link
Contributor

coderabbitai bot commented Sep 23, 2024

Walkthrough

The changes introduce a new property, mostRecentClientIds, to the QueryVaultResponse interface and its SDK type, allowing the inclusion of an array of client IDs in vault queries. This modification is reflected in the associated ProtoBuf definition, the Keeper implementation, and the corresponding test cases, enhancing the vault query response structure without altering existing fields.

Changes

File Path Change Summary
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.ts Added mostRecentClientIds: number[] to QueryVaultResponse and QueryVaultResponseSDKType. Updated initialization, encoding, decoding, and fromPartial methods accordingly.
proto/dydxprotocol/vault/query.proto Added repeated uint32 most_recent_client_ids = 6; to QueryVaultResponse.
protocol/x/vault/keeper/grpc_query_vault.go Updated Vault method to include MostRecentClientIds in the returned QueryVaultResponse.
protocol/x/vault/keeper/grpc_query_vault_test.go Modified TestVault to include clientIds in test cases and updated expected response to include MostRecentClientIds.

Possibly related PRs

Suggested reviewers

  • vincentwschau

Poem

In the vault where secrets hide,
New IDs join the client tide.
With arrays now in place,
Queries quicken their pace.
Hops of joy, we celebrate,
Changes bright, we elevate! 🐇✨


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>, please review it.
    -- 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @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.
    -- @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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/schema.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: 0

Outside diff range and nitpick comments (2)
protocol/x/vault/keeper/grpc_query_vault_test.go (2)

50-50: LGTM: clientIds added to "Success" test case

The addition of clientIds: []uint32{0, 1, 2, 3} to the "Success" test case is appropriate for testing the new functionality.

Consider adding a comment explaining the significance of these specific client ID values, or if they are arbitrary, mention that in the comment. This would improve the test's readability and maintainability.


78-78: LGTM: clientIds added to "negative inventory and equity" test case

The addition of clientIds: []uint32{77, 88, 99} to this test case is appropriate. It tests the system with a different set of client IDs, which is good for ensuring robustness.

Consider adding a comment explaining why these specific client ID values were chosen, or if they are arbitrary, mention that in the comment. This would improve the test's readability and maintainability.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0601feb and 19cc8ee.

Files ignored due to path filters (1)
  • protocol/x/vault/types/query.pb.go is excluded by !**/*.pb.go
Files selected for processing (4)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.ts (6 hunks)
  • proto/dydxprotocol/vault/query.proto (1 hunks)
  • protocol/x/vault/keeper/grpc_query_vault.go (1 hunks)
  • protocol/x/vault/keeper/grpc_query_vault_test.go (7 hunks)
Additional comments not posted (12)
protocol/x/vault/keeper/grpc_query_vault.go (1)

53-58: LGTM! Consider error handling and test updates.

The addition of MostRecentClientIds aligns well with the PR objective of exposing client IDs in the vault query. The implementation looks correct and doesn't introduce breaking changes to the existing structure.

However, I have a couple of suggestions:

  1. Verify the error handling for k.GetMostRecentClientIds(ctx, vaultId). If this method can potentially return an error, consider how to handle it appropriately.

  2. Update the relevant unit tests to cover the new MostRecentClientIds field in the QueryVaultResponse.

To ensure proper test coverage, let's check the existing tests:

proto/dydxprotocol/vault/query.proto (1)

92-92: LGTM! Verify related code updates.

The addition of the most_recent_client_ids field to the QueryVaultResponse message is appropriate and aligns with the PR objective. The field type and numbering are correct, and it maintains backward compatibility.

To ensure complete implementation, please verify that the following updates have been made:

  1. The server-side implementation populates this field correctly.
  2. Client-side code can handle and utilize this new field.
  3. Any relevant documentation has been updated to reflect this addition.

Run the following script to check for related code updates:

protocol/x/vault/keeper/grpc_query_vault_test.go (4)

31-32: LGTM: Addition of clientIds field

The addition of the clientIds []uint32 field to the test case struct aligns with the PR objective of exposing client IDs in vault queries. The field type is appropriate for storing client IDs.


65-65: LGTM: Empty clientIds added to "close only vault status" test case

The addition of an empty clientIds array ([]uint32{}) to this test case is appropriate. It ensures that the system can handle vaults with no associated client IDs, which is an important edge case to test.


Line range hint 1-311: Summary: Changes align with PR objectives and improve test coverage

The modifications to this test file effectively incorporate the new clientIds field into various test cases, covering scenarios with both empty and non-empty client ID arrays. The expected response structure has been updated to include MostRecentClientIds, ensuring that the new functionality is properly tested.

These changes align well with the PR objective of exposing client IDs in vault queries. The test structure remains consistent with the existing code, maintaining readability and maintainability.

Consider addressing the minor suggestions for improved documentation of test data to enhance the test file's clarity and maintainability.


172-177: LGTM: MostRecentClientIds added to expected response

The addition of MostRecentClientIds: k.GetMostRecentClientIds(ctx, tc.vaultId) to the expected response structure is appropriate. It ensures that the test verifies the inclusion of the most recent client IDs in the vault query response, which aligns with the PR objective.

To ensure the correctness of the GetMostRecentClientIds function, let's verify its implementation:

Verification successful

LGTM: MostRecentClientIds added to expected response

The addition of MostRecentClientIds: k.GetMostRecentClientIds(ctx, tc.vaultId) to the expected response structure is appropriately verified by existing tests that cover the GetMostRecentClientIds function. This ensures that the inclusion of the most recent client IDs in the vault query response aligns with the PR objectives and is properly tested.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of GetMostRecentClientIds function

# Test: Search for the GetMostRecentClientIds function definition
rg --type go -A 10 'func.*GetMostRecentClientIds'

Length of output: 2920


Script:

#!/bin/bash
# Description: Search for tests covering GetMostRecentClientIds function

rg --type go --glob '*_test.go' 'GetMostRecentClientIds'

Length of output: 972

indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.ts (6)

54-54: New property added to QueryVaultResponse interface

The mostRecentClientIds property has been added to both QueryVaultResponse and QueryVaultResponseSDKType interfaces. This change aligns with the PR objective of exposing client IDs in the vault query.

Also applies to: 64-64


471-472: Initialization of mostRecentClientIds in createBaseQueryVaultResponse

The mostRecentClientIds property is correctly initialized as an empty array in the createBaseQueryVaultResponse function. This ensures that the property is always defined, even if no client IDs are present.


498-504: Encoding of mostRecentClientIds in QueryVaultResponse.encode

The encoding logic for mostRecentClientIds has been implemented correctly. It uses a forked writer to efficiently encode the array of client IDs.


537-549: Decoding of mostRecentClientIds in QueryVaultResponse.decode

The decoding logic for mostRecentClientIds has been implemented correctly. It handles both packed and unpacked encoding formats, which is a good practice for backwards compatibility.


566-566: Partial object creation for mostRecentClientIds in QueryVaultResponse.fromPartial

The fromPartial method correctly handles the mostRecentClientIds property, creating a new array with the provided values or an empty array if the property is undefined.


54-54: Consider documentation and backwards compatibility

The addition of mostRecentClientIds to the QueryVaultResponse has been implemented correctly across all relevant parts of the code. However, consider the following:

  1. Documentation: Ensure that any API documentation is updated to reflect this new property.
  2. Backwards Compatibility: Verify that existing clients querying vault information can handle the presence of this new field without issues.
  3. Usage: Consider adding comments or updating existing documentation to explain the purpose and expected content of mostRecentClientIds.

To check for potential documentation updates, you can run:

To verify backwards compatibility, ensure that existing query handlers and clients are tested with this new response format.

Also applies to: 64-64, 471-472, 498-504, 537-549, 566-566

@tqin7 tqin7 merged commit c34d56d into main Sep 24, 2024
39 checks passed
@tqin7 tqin7 deleted the tq/tra-630 branch September 24, 2024 14:44
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