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

chore: api cleanups #19541

Merged
merged 6 commits into from
Feb 25, 2024
Merged

chore: api cleanups #19541

merged 6 commits into from
Feb 25, 2024

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented Feb 23, 2024

Description

Closes: #XXXX


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

  • Refactor
    • Simplified module management and logic enhancements in the system's core functionality.
  • Bug Fixes
    • Fixed a typo that led to the removal of an unnecessary type.
  • Deprecated
    • Removed outdated functions related to public key conversions.
    • Deprecated specific public key function in favor of a more efficient alternative.
  • Documentation
    • Updated the CHANGELOG.md file to reflect the removal and replacement of deprecated functions in the crypto module.
    • Improved type specificity for better clarity and type safety in the codebase by updating types in various functions.
  • New Features
    • Added a MockAppModuleBasic struct with associated methods for mocking AppModuleBasic interface.

@julienrbrt julienrbrt requested a review from a team as a code owner February 23, 2024 20:58
Copy link
Contributor

coderabbitai bot commented Feb 23, 2024

Walkthrough

The recent updates aim to enhance the codebase by removing deprecated functions related to public key conversions, refining module handling using appmodule.AppModule, clarifying the staking module's EndBlock function behavior, and introducing a new method for consistent consensus public key casting.

Changes

File(s) Summary
crypto/codec/cmt.go Removed deprecated functions for converting public keys.
types/module/module.go - Removed HasABCIEndblock type due to a typo.
- Updated Manager struct to use appmodule.AppModule.
- Simplified EndBlock method logic.
x/staking/module.go Clarified that EndBlock no longer returns validator updates.
x/staking/types/validator.go Deprecated TmConsPublicKey in favor of CmtConsPublicKey for casting ConsensusPubkey.
runtime/services/autocli.go Updated appModules parameter type for better type safety.
testutil/mock/types_module_module.go Added MockAppModuleBasic struct for mocking AppModuleBasic interface.
types/module/simulation.go Updated import statement and function signature type for clarity.

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.
  • 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 from git 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.yml

Commits Files that changed from the base of the PR and between 4b73e31 and d12707b.
Files selected for processing (5)
  • crypto/codec/cmt.go (1 hunks)
  • types/module/module.go (5 hunks)
  • types/module/module_int_test.go (3 hunks)
  • x/staking/module.go (1 hunks)
  • x/staking/types/validator.go (1 hunks)
Additional comments: 7
types/module/module_int_test.go (1)
  • 21-21: The update to use appmodule.AppModule instead of interface{} for the Modules field in the Manager struct enhances type safety and clarity. This ensures that only modules implementing the AppModule interface can be added, aligning with the Cosmos SDK's module system design goals.

Also applies to: 46-46

x/staking/module.go (1)
  • 171-171: The update to the EndBlock function, indicating it can return validator updates, is a logical and necessary change. This aligns with the Cosmos SDK's expectations for module behavior and enhances the staking module's functionality.
x/staking/types/validator.go (1)
  • 473-478: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [1-1]

The introduction of CmtConsPublicKey and the deprecation of TmConsPublicKey represent a positive shift towards standardization in handling consensus public keys within the Cosmos SDK. This change enhances clarity and interoperability between the Cosmos SDK and CometBFT ecosystems.

types/module/module.go (4)
  • 139-139: The update to the Manager struct to use appmodule.AppModule instead of interface{} for the Modules map is a positive change. It enhances type safety and clarity in the module management system.
  • 152-152: The NewManager function correctly initializes a Manager with appmodule.AppModule types, ensuring consistency with the updated Manager struct. This change improves type safety and module management.
  • 182-182: Similarly, the NewManagerFromMap function's adaptation to use appmodule.AppModule for its map parameter aligns with the Manager struct's changes, promoting type safety and clarity in module management.
  • 766-766: The simplification in the EndBlock method by directly appending moduleValUpdates to validatorUpdates is a logical improvement. It streamlines the process of collecting validator updates from modules, making the code more readable and efficient.

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.yml

Commits Files that changed from the base of the PR and between d12707b and d804a02.
Files selected for processing (4)
  • CHANGELOG.md (1 hunks)
  • runtime/services/autocli.go (2 hunks)
  • testutil/mock/types_module_module.go (1 hunks)
  • x/staking/types/validator.go (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • x/staking/types/validator.go
Additional comments: 4
runtime/services/autocli.go (2)
  • 28-28: The change in the NewAutoCLIQueryService function's appModules parameter type from map[string]interface{} to map[string]appmodule.AppModule enhances type safety and clarity, aligning with the PR's objectives.
  • 39-39: The modification in the ExtractAutoCLIOptions function's appModules parameter type from map[string]interface{} to map[string]appmodule.AppModule is consistent with the PR's goal of refining type usage for better clarity and type safety.
testutil/mock/types_module_module.go (1)
  • 22-93: The addition of the MockAppModuleBasic struct and its methods for mocking the AppModuleBasic interface, including Name, RegisterGRPCGatewayRoutes, RegisterInterfaces, and RegisterLegacyAminoCodec, is a valuable enhancement for testing. It allows for more comprehensive and isolated testing of modules that depend on AppModuleBasic without needing to instantiate the actual implementations.
CHANGELOG.md (1)
  • 150-150: The change log entry is clear and accurately reflects the changes made in the crypto module as part of PR chore: api cleanups #19541. It follows the established format and provides the necessary details for understanding the impact of the changes.

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.yml

Commits Files that changed from the base of the PR and between d804a02 and 886dbd6.
Files selected for processing (1)
  • types/module/simulation.go (2 hunks)
Additional comments: 2
types/module/simulation.go (2)
  • 9-9: The addition of the cosmossdk.io/core/appmodule import statement is necessary for the updated function signature in NewSimulationManagerFromAppModules. This change aligns with the PR's objective of refining type usage and simplifying logic.
  • 65-65: The function signature of NewSimulationManagerFromAppModules has been updated to use map[string]appmodule.AppModule instead of map[string]interface{}. This change enhances type safety and clarity, which is in line with the PR's objectives of enhancing type usage and simplifying logic. However, it's important to ensure that all calls to this function throughout the codebase have been updated to match the new signature to avoid runtime errors.

@julienrbrt julienrbrt added this pull request to the merge queue Feb 25, 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.yml

Commits Files that changed from the base of the PR and between 886dbd6 and 97d5774.
Files selected for processing (1)
  • types/module/module_int_test.go (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • types/module/module_int_test.go

Merged via the queue into main with commit 8432570 Feb 25, 2024
59 of 60 checks passed
@julienrbrt julienrbrt deleted the julien/nits branch February 25, 2024 09:31
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.

4 participants