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-87] add x/vault protos #1169

Merged
merged 2 commits into from
Mar 14, 2024
Merged

[tra-87] add x/vault protos #1169

merged 2 commits into from
Mar 14, 2024

Conversation

tqin7
Copy link
Contributor

@tqin7 tqin7 commented Mar 13, 2024

Changelist

add x/vault protos

Test Plan

N/A

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 Mar 13, 2024

Copy link
Contributor

coderabbitai bot commented Mar 13, 2024

Walkthrough

The recent updates focus on enhancing the dydxprotocol namespace by reorganizing imports, updating module references, and introducing vault-related functionalities. A significant addition is the capability to deposit funds into vaults, marked by new message interfaces and services in the protocol's codebase. These changes streamline the structure and accessibility of the dydxprotocol, improving its integration and interaction within the ecosystem. Furthermore, modifications extend to supporting files, ensuring compatibility and extending the protocol's capabilities.

Changes

Files Summary
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/vault.ts
proto/dydxprotocol/vault/vault.proto
Added new interfaces for depositing into a vault, defined vault types, IDs, and shares using Protobuf in TypeScript.
indexer/packages/v4-protos/src/codegen/google/bundle.ts Reordered and added imports, updated the structure of the google namespace.
protocol/app/basic_manager/basic_manager.go Added the vaultmodule to the list of AppModuleBasic instances.
protocol/app/msgs/all_msgs.go
protocol/app/msgs/normal_msgs.go
protocol/app/msgs/normal_msgs_test.go
Added declarations for vault messages and deposit functionality.
protocol/testutil/app/app.go Modified interface to include vaulttypes.GenesisState and updated functions accordingly.
protocol/x/vault/keeper/msg_server_deposit_to_vault.go
protocol/x/vault/types/msg_deposit_to_vault.go
Introduced functionality for depositing from a subaccount to a vault and added validation for MsgDepositToVault type.

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

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between d92b5b2 and 7b252f5.
Files ignored due to path filters (2)
  • protocol/x/vault/types/tx.pb.go is excluded by: !**/*.pb.go
  • protocol/x/vault/types/vault.pb.go is excluded by: !**/*.pb.go
Files selected for processing (14)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts (4 hunks)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/rpc.tx.ts (1 hunks)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.rpc.msg.ts (1 hunks)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts (1 hunks)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/vault.ts (1 hunks)
  • indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts (1 hunks)
  • indexer/packages/v4-protos/src/codegen/google/bundle.ts (1 hunks)
  • proto/dydxprotocol/vault/tx.proto (1 hunks)
  • proto/dydxprotocol/vault/vault.proto (1 hunks)
  • protocol/app/basic_manager/basic_manager.go (2 hunks)
  • protocol/app/msgs/all_msgs.go (1 hunks)
  • protocol/testutil/app/app.go (3 hunks)
  • protocol/x/vault/keeper/msg_server_deposit_to_vault.go (1 hunks)
  • protocol/x/vault/types/msg_deposit_to_vault.go (1 hunks)
Check Runs (11)
install-runsim completed (5)
v4-proto-py-gen completed (1)
v4-proto-js-gen completed (1)
protocol-gen completed (1)
lint completed (1)
indexer-gen completed (1)
check-bc-breaking completed (1)
check-sample-pregenesis-up-to-date completed (1)
build completed (1)
validate-yaml completed (1)
format completed (1)
Additional comments: 19
indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts (1)
  • 1-2: The update from _101 to _102 in the import statement seems appropriate. Ensure that the new version of the module is fully compatible and does not introduce any breaking changes.
indexer/packages/v4-protos/src/codegen/google/bundle.ts (1)
  • 1-14: The reordering and addition of imports in this file, along with the updates to the google namespace structure, appear to be well-organized. Ensure that all newly added imports are compatible and correctly referenced to maintain the integrity of the namespace structure.
proto/dydxprotocol/vault/vault.proto (1)
  • 8-34: The definitions in vault.proto, including the VaultType enum, VaultId, and NumShares messages, are well-structured. Ensure that the custom type used for num_shares is correctly implemented and thoroughly tested to maintain data integrity.
proto/dydxprotocol/vault/tx.proto (1)
  • 16-33: The message definitions in tx.proto, including MsgDepositToVault and MsgDepositToVaultResponse, are appropriately structured for handling deposit operations. Ensure that the custom types used, especially for quote_quantums, are correctly implemented and thoroughly tested to ensure data integrity.
indexer/packages/v4-protos/src/codegen/dydxprotocol/rpc.tx.ts (1)
  • 20-20: The addition of the vault entity to the createRPCMsgClient function is a logical step to enable RPC calls for vault operations. Ensure that the vault/tx.rpc.msg module is correctly implemented and tested to support these operations effectively.
protocol/app/basic_manager/basic_manager.go (1)
  • 39-39: Adding vaultmodule to the list of AppModuleBasic instances is a crucial step in integrating the new vault functionality into the application. Ensure that the vaultmodule is properly implemented and tested to maintain the integrity of the application.
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts (3)
  • 7-15: The MsgDepositToVault interface is well-defined, with clear comments and appropriate field types. Ensure that quoteQuantums is correctly handled in all relevant operations, especially considering its type Uint8Array.
  • 36-97: The encoding and decoding functions for MsgDepositToVault are correctly implemented, following the protobufjs conventions. It's important to ensure comprehensive testing, particularly for edge cases in the encoding and decoding processes.
  • 101-131: The MsgDepositToVaultResponse interface and its associated functions are minimal, as expected for a response type without specific fields. This simplicity is appropriate unless future requirements necessitate additional response data.
indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/vault.ts (5)
  • 5-11: The VaultType enum is correctly defined with appropriate comments. Ensure that all potential vault types are covered, and consider future extensibility for new vault types.
  • 54-59: The VaultId interface is well-structured, providing a clear way to uniquely identify vaults. Ensure that the number field is sufficient for identifying vaults within a type and consider any potential for collisions.
  • 72-74: The NumShares interface correctly represents the number of shares in a vault. Given its use of Uint8Array for numShares, ensure that there's a consistent approach to interpreting this data across the application.
  • 83-134: The encoding and decoding functions for VaultId are implemented following the protobufjs conventions. It's important to ensure these functions are thoroughly tested, especially for edge cases.
  • 138-179: Similarly, the encoding and decoding functions for NumShares follow the correct conventions. Ensure that the handling of Uint8Array for numShares is consistent and well-documented throughout the application.
indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts (1)
  • 90-174: > 📝 NOTE

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

The reordering of imports and updates to references in bundle.ts appear to be correctly implemented, enhancing the organization within the dydxprotocol namespace. Ensure that all references are correctly updated across the codebase to reflect these changes, avoiding any broken imports or references.

protocol/app/msgs/all_msgs.go (1)
  • 237-239: The addition of "/dydxprotocol.vault.MsgDepositToVault": {}, correctly aligns with the PR's objectives to introduce new functionalities related to vault operations. This change is well-placed within the AllTypeMessages map, ensuring that the new vault-related message type is registered and recognized by the application.

However, considering the potential for future expansions in the vault functionality or other areas, it might be beneficial to consider a strategy for organizing these message types. For instance, grouping related message types or introducing comments to delineate sections could enhance readability and maintainability as the list grows.

protocol/testutil/app/app.go (3)
  • 66-66: The addition of vaulttypes import is necessary for incorporating vault functionality into the test utilities. Looks good.
  • 204-205: The inclusion of vaulttypes.GenesisState in the GenesisStates interface is a necessary update to handle vault-related genesis state. This change aligns well with the PR's objectives.
  • 259-260: Adding a case for vaulttypes.GenesisState in the UpdateGenesisDocWithAppStateForModule function is essential for updating the genesis document with vault-related state. This change is consistent and necessary for the introduction of vault functionality.

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 7b252f5 and 4e9afab.
Files selected for processing (2)
  • protocol/app/msgs/all_msgs.go (1 hunks)
  • protocol/app/msgs/normal_msgs.go (2 hunks)
Check Runs (18)
install-runsim completed (5)
call-build-ecs-service-vulcan / (vulcan) Check docker image build completed (1)
v4-proto-py-gen completed (1)
call-build-ecs-service-socks / (socks) Check docker image build completed (1)
v4-proto-js-gen completed (1)
call-build-ecs-service-comlink / (comlink) Check docker image build completed (1)
protocol-gen completed (1)
call-build-ecs-service-roundtable / (roundtable) Check docker image build completed (1)
lint completed (1)
call-build-ecs-service-ender / (ender) Check docker image build completed (1)
validate-yaml completed (1)
format completed (1)
golangci-lint completed (1)
check-build-bazooka completed (1)
check-bc-breaking completed (1)
check-sample-pregenesis-up-to-date completed (1)
build completed (1)
indexer-gen completed (1)
Files skipped from review as they are similar to previous changes (1)
  • protocol/app/msgs/all_msgs.go
Additional comments: 2
protocol/app/msgs/normal_msgs.go (2)
  • 22-22: The import statement for vault "github.com/dydxprotocol/v4-chain/protocol/x/vault/types" has been correctly added to include the new vault types. This is necessary for the subsequent use of vault.MsgDepositToVault and vault.MsgDepositToVaultResponse in the NormalMsgsDydxCustom map.
  • 239-240: The addition of "/dydxprotocol.vault.MsgDepositToVault": &vault.MsgDepositToVault{} and "/dydxprotocol.vault.MsgDepositToVaultResponse": nil to the NormalMsgsDydxCustom map correctly registers the new vault messages. This is essential for enabling the handling of these messages within the application. However, it's important to ensure that the corresponding message handlers are implemented and tested thoroughly to handle these new message types effectively.

Please confirm that the message handlers for MsgDepositToVault and MsgDepositToVaultResponse have been implemented and covered by unit tests to ensure correct behavior.

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 7b252f5 and 191d9e2.
Files selected for processing (3)
  • protocol/app/msgs/all_msgs.go (1 hunks)
  • protocol/app/msgs/normal_msgs.go (2 hunks)
  • protocol/app/msgs/normal_msgs_test.go (1 hunks)
Check Runs (18)
install-runsim completed (5)
call-build-ecs-service-vulcan / (vulcan) Check docker image build completed (1)
call-build-ecs-service-socks / (socks) Check docker image build completed (1)
v4-proto-py-gen completed (1)
call-build-ecs-service-roundtable / (roundtable) Check docker image build completed (1)
protocol-gen completed (1)
call-build-ecs-service-comlink / (comlink) Check docker image build completed (1)
indexer-gen completed (1)
call-build-ecs-service-ender / (ender) Check docker image build completed (1)
v4-proto-js-gen completed (1)
lint completed (1)
check-build-bazooka completed (1)
validate-yaml completed (1)
format completed (1)
build completed (1)
check-bc-breaking completed (1)
golangci-lint completed (1)
check-sample-pregenesis-up-to-date completed (1)
Files skipped from review as they are similar to previous changes (2)
  • protocol/app/msgs/all_msgs.go
  • protocol/app/msgs/normal_msgs.go
Additional comments: 1
protocol/app/msgs/normal_msgs_test.go (1)
  • 141-143: The addition of vault messages "/dydxprotocol.vault.MsgDepositToVault" and "/dydxprotocol.vault.MsgDepositToVaultResponse" to the expectedMsgs array in TestNormalMsgs_Key is correctly implemented and logically categorized.

Ensure that the NormalMsgs map is updated to include these new messages, as this test assumes their presence.

@vincentwschau
Copy link
Contributor

vincentwschau commented Mar 14, 2024

@tqin7 Does this file need to be updated for the MsgDepositToVault message to indicate ('subaccount_id', 'owner') is a custom signer to check? Is this slated for a later PR?

@tqin7
Copy link
Contributor Author

tqin7 commented Mar 14, 2024

@tqin7 Does this file need to be updated for the MsgDepositToVault message to indicate ('subaccount_id', 'owner') is a custom signer to check? Is this slated for a later PR?

Yep! Implementation of that message (including signer check) is for a later PR

@tqin7 tqin7 merged commit 20ffef4 into main Mar 14, 2024
33 checks passed
@tqin7 tqin7 deleted the tq/tra-87 branch March 14, 2024 15:36
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