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

feat(x/accounts): use router service from env #20003

Merged
merged 12 commits into from
Apr 15, 2024
Merged

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented Apr 10, 2024

Description

Use router service from environment instead of custom x/accounts router service


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • New Features

    • Added two new message types for enhanced transaction capabilities.
  • Refactor

    • Streamlined initialization and configuration processes for account management.
    • Consolidated routing functionalities into centralized services for improved module communication.
    • Simplified and focused testing functions, enhancing clarity and efficiency.
  • Bug Fixes

    • Adjusted fixture initialization in testing to align with updated module configurations.
  • Documentation

    • Enhanced inline comments to clarify the initialization and setup process in tests.

Copy link
Contributor

coderabbitai bot commented Apr 10, 2024

Walkthrough

Walkthrough

The recent updates primarily streamline the interaction with routers and services across various modules in the application. The changes involve removing older router interfaces and replacing them with direct calls to new modular services within the environment structure. This refactoring enhances clarity and efficiency in message and query handling, reducing dependency on redundant components and imports, and improving the overall structure and testing of the codebase.

Changes

Files Affected Summary of Changes
simapp/app.go Updated initialization of accountsKeeper to include additional router configurations.
x/accounts/genesis_test.go, x/accounts/query_server_test.go Removed context imports and updated router-related code.
x/accounts/keeper.go, x/accounts/utils_test.go Replaced QueryRouter and MsgRouter with direct service calls from the environment. Added new routing functionalities and service registrations.
x/accounts/keeper_test.go, x/accounts/msg_server_test.go Streamlined test functions, removed unused imports, and adjusted fixture initializations.
x/bank/types/codec.go Added new message types MsgBurn and MsgSetSendEnabled.

Recent Review Details

Configuration used: .coderabbit.yml

Commits Files that changed from the base of the PR and between febc15f and cf2d7d4.
Files selected for processing (1)
  • tests/integration/auth/keeper/msg_server_test.go (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • tests/integration/auth/keeper/msg_server_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 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/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

@julienrbrt your pull request is missing a changelog!

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

@@ -1,29 +1,19 @@
package accounts
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

The removed mock functions mockQuery and mockExec from x/accounts/keeper_test.go are indeed referenced in other test files within the repository (x/bank/keeper/grpc_query_test.go and x/bank/keeper/keeper_test.go). This indicates that the elimination of these mock functions could potentially affect other test functionalities or dependencies within the test suite.

Analysis chain

Confirm that the elimination of redundant mock functions does not affect other test functionalities or dependencies within the test suite.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for any references to eliminated mock functions in the test files to ensure they are not used elsewhere.
rg --type go --files-with-matches --glob '*_test.go' 'mock'

Length of output: 3896



Script:

#!/bin/bash
# First, identify the specific mock functions that were removed from x/accounts/keeper_test.go
git diff origin/main...HEAD -- x/accounts/keeper_test.go | grep -P '^\-.*mock.*\('

# Then, check if these specific mock functions are referenced in other test files
rg --type go --files-with-matches --glob '*_test.go' 'specific_mock_function_name_here'

Length of output: 673



Script:

#!/bin/bash
# Search for references to 'mockQuery' and 'mockExec' in the test files to ensure they are not used elsewhere.
rg --type go --files-with-matches --glob '*_test.go' 'mockQuery|mockExec'

Length of output: 137

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

Comment on lines +39 to +40
// TODO: Add a way to inject custom accounts.
// Currently only the base account is supported.
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider providing more details or a timeline in the TODO comment.

Would you like assistance in defining a more detailed plan or creating a tracking issue for this TODO?

in.Cdc, in.Environment, in.AddressCodec, in.Cdc,
in.ExecRouter, in.QueryRouter, in.Registry, account,
)
accountskeeper, err := NewKeeper(in.Cdc, in.Environment, in.AddressCodec, in.Cdc, in.Registry, account)
Copy link
Contributor

Choose a reason for hiding this comment

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

Improve error handling by avoiding panic and returning an error instead.

- panic(err)
+ return ModuleOutputs{}, err

This change allows the caller of ProvideModule to handle the error appropriately, improving the robustness and maintainability of the module.


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
accountskeeper, err := NewKeeper(in.Cdc, in.Environment, in.AddressCodec, in.Cdc, in.Registry, account)
accountskeeper, err := NewKeeper(in.Cdc, in.Environment, in.AddressCodec, in.Cdc, in.Registry, account)
return ModuleOutputs{}, err

@julienrbrt
Copy link
Member Author

if we can merge this so I can stop fixing merge conflicts that would be great!

Copy link
Contributor

@likhita-809 likhita-809 left a comment

Choose a reason for hiding this comment

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

seems like integration test is failing

@julienrbrt julienrbrt added this pull request to the merge queue Apr 15, 2024
Merged via the queue into main with commit 369847c Apr 15, 2024
63 checks passed
@julienrbrt julienrbrt deleted the julien/accounts-env branch April 15, 2024 15:45
alpe added a commit to alpe/cosmos-sdk that referenced this pull request Apr 16, 2024
* main:
  refactor(x/simulation)!: remove accounts string (cosmos#20056)
  fix(baseapp): don't share global gas meter in tx execution (cosmos#19616)
  feat(x/accounts): use router service from env (cosmos#20003)
  refactor(x): remove Address.String() (cosmos#20048)
  build(deps): Bump github.com/jhump/protoreflect from 1.15.6 to 1.16.0 in /tests (cosmos#20040)
  feat(collections): add `NewJSONValueCodec` (cosmos#19861)
alpe added a commit that referenced this pull request Apr 17, 2024
* main:
  build(deps): Bump github.com/pelletier/go-toml/v2 from 2.2.0 to 2.2.1 in /tools/confix (#20052)
  build(deps): Bump cosmossdk.io/api from 0.7.3 to 0.7.4 (#20063)
  fix: secp256r1 json missing quotes (#20060)
  fix(x/accounts): remove double execute (#20065)
  refactor(x/accounts): Skip Importing Unregistered Genesis Account Types (#20053)
  refactor(x/simulation)!: remove accounts string (#20056)
  fix(baseapp): don't share global gas meter in tx execution (#19616)
  feat(x/accounts): use router service from env (#20003)
  refactor(x): remove Address.String() (#20048)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants