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

refactor(core,stf): complete gas service + simplify deps #21166

Merged
merged 4 commits into from
Aug 8, 2024

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented Aug 2, 2024

Description


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, you can find examples of the prefixes below:
  • 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.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

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

    • Enhanced gas configuration management across various services.
    • Improved default gas configuration handling for better clarity and usability.
  • Bug Fixes

    • Removed potentially problematic methods from the gas service, simplifying the interface.
  • Refactor

    • Streamlined dependency management by removing outdated dependencies and introducing more relevant configurations.
    • Simplified service architecture by removing deprecated interfaces and methods.
  • Documentation

    • Added comments for better clarity on gas configuration parameters and their usage.

@julienrbrt julienrbrt requested a review from a team as a code owner August 2, 2024 15:07
Copy link
Contributor

coderabbitai bot commented Aug 2, 2024

Walkthrough

Walkthrough

The changes introduce significant restructuring within the Cosmos SDK, focusing on dependency management and interface simplification. Several indirect dependencies have been removed, streamlining module interactions. Key interfaces related to service registration (such as HasServices) and gas measurement have been altered or eliminated, aiming to enhance clarity, reduce complexity, and improve maintainability. This reorganization may affect existing implementations while facilitating future module integrations.

Changes

Files Change Summary
collections/go.mod Removed several indirect dependencies to streamline the module's dependency management.
core/go.mod Removed indirect dependencies and added github.com/golang/protobuf as an indirect dependency.
core/appmodule/module.go, core/gas/service.go Removed HasServices interface and BlockGasMeter method, simplifying service registration and interface.
runtime/v2/module.go Modified ProvideEnvironment function signature for improved readability without changing functionality.
server/v2/stf/core_gas_service.go, server/v2/stf/gas/defaults.go, Updated gas configuration methods and types to enhance gas cost management.
server/v2/stf/gas/store.go, server/v2/stf/gas/writer_map.go Transitioned configurations to use gas.GasConfig, streamlining gas cost management.
store/v2/go.mod Removed github.com/golang/protobuf dependency, indicating a shift in protocol buffer management.
runtime/app.go, runtime/services/autocli.go, runtime/v2/manager.go, Introduced new hasServicesV1 interface for service registration, affecting how modules are integrated.
types/module/core_module.go, types/module/module.go, types/module/module_test.go Removed HasServices interface implementation from several modules, changing their service handling capabilities.

Sequence Diagram(s)

sequenceDiagram
    participant Module as Module
    participant ServiceRegistrar as ServiceRegistrar
    participant AppModule as AppModule

    Module->>ServiceRegistrar: RegisterServices()
    ServiceRegistrar-->>Module: Acknowledge registration
    AppModule->>Module: Call methods
Loading

Possibly related issues


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

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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, codebase verification and nitpick comments (3)
core/gas/service.go (1)

Update Required: References to BlockGasMeter still exist in the codebase.

The removal of BlockGasMeter from the Service interface has not been fully managed. The following files still contain references to BlockGasMeter:

  • types/context.go
  • types/context_test.go
  • tests/e2e/baseapp/block_gas_test.go
  • runtime/gas.go
  • store/types/gas.go
  • baseapp/baseapp.go
  • baseapp/baseapp_test.go
  • baseapp/abci.go
  • baseapp/abci_test.go

Please update or remove these references to ensure consistency and avoid potential issues.

Analysis chain

Line range hint 15-20:
LGTM! But verify the impact of removing BlockGasMeter.

The removal of BlockGasMeter from the Service interface simplifies the interface. Ensure that all references to BlockGasMeter are removed or updated accordingly.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that `BlockGasMeter` is no longer referenced in the codebase.

# Test: Search for any remaining references to `BlockGasMeter`. Expect: No occurrences.
rg --type go 'BlockGasMeter'

Length of output: 2908


Script:

#!/bin/bash
# Description: Extract context around references to `BlockGasMeter` to verify proper handling after its removal from the `Service` interface.

# Extract context around each reference to `BlockGasMeter`.
rg --type go --context 5 'BlockGasMeter'

Length of output: 15884

server/v2/stf/README.md (1)

Line range hint 1-34:
Approve formatting changes but address grammatical issues.

The formatting changes improve readability. Address the following grammatical issues:

  1. Use a hyphen in "read-only" (Line 5).
  2. Correct "THe" to "The" and "wrappGasMeter" to "wrapGasMeter" (Line 34).
  3. Consider shortening "in order to" to "to" (Line 34).
- The state transition function receives a read only instance of state.
+ The state transition function receives a read-only instance of state.

- THe wrappGasMeter is used in order to consume gas.
+ The wrapGasMeter is used to consume gas.
Tools
LanguageTool

[style] ~34-~34: Consider a shorter alternative to avoid wordiness.
Context: ...terMap ) ``` THe wrappGasMeter is used in order to consume gas. Application developers can...

(IN_ORDER_TO_PREMIUM)


[style] ~34-~34: Consider a shorter alternative to avoid wordiness.
Context: ...gas meter with their own implementation in order to customize consumption of gas.

(IN_ORDER_TO_PREMIUM)

core/appmodule/module.go (1)

36-53: References to HasServices and RegisterServices still exist.

The removal of HasServices and RegisterServices is incomplete. The following files still contain references to these interfaces and methods:

  • x/upgrade/module.go
  • x/staking/module.go
  • x/slashing/module.go
  • x/nft/module/module.go
  • x/group/module/module.go
  • x/params/module.go
  • x/gov/module.go
  • x/mint/module.go
  • x/protocolpool/module.go
  • x/feegrant/module/module.go
  • x/epochs/module.go
  • x/evidence/module.go
  • x/bank/module.go
  • x/circuit/module.go
  • x/consensus/module.go
  • x/distribution/module.go
  • x/authz/module/module.go
  • x/accounts/module.go
  • x/auth/module.go
  • types/module/mock_appmodule_test.go
  • types/module/module_test.go
  • types/module/module.go
  • types/module/core_module.go
  • testutil/x/counter/module.go
  • testutil/mock/types_mock_appmodule.go
  • runtime/v2/builder.go
  • runtime/v2/services/autocli.go
  • runtime/v2/module.go
  • runtime/services/autocli.go
  • runtime/module.go
  • runtime/v2/manager.go
  • runtime/builder.go
  • runtime/app.go
  • simapp/app_test.go
  • simapp/app.go
  • core/appmodule/module.go

Please ensure that all references to HasServices and RegisterServices are removed or updated accordingly.

Analysis chain

LGTM! But verify the impact of removing HasServices.

The removal of HasServices and RegisterServices indicates a change in service registration. Ensure that all references to HasServices and RegisterServices are removed or updated accordingly.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that `HasServices` and `RegisterServices` are no longer referenced in the codebase.

# Test: Search for any remaining references to `HasServices` and `RegisterServices`. Expect: No occurrences.
rg --type go 'HasServices|RegisterServices'

Length of output: 11909


Script:

#!/bin/bash
# Description: Gather detailed context for references to `HasServices` and `RegisterServices`.

# List all files containing references to `HasServices` and `RegisterServices` with context lines.
rg --type go 'HasServices|RegisterServices' -A 5 -B 5

Length of output: 47547

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a26970e and 27c68b8.

Files ignored due to path filters (6)
  • collections/go.sum is excluded by !**/*.sum
  • core/go.sum is excluded by !**/*.sum
  • core/testing/go.sum is excluded by !**/*.sum
  • server/v2/appmanager/go.sum is excluded by !**/*.sum
  • server/v2/stf/go.sum is excluded by !**/*.sum
  • store/v2/go.sum is excluded by !**/*.sum
Files selected for processing (11)
  • collections/go.mod (1 hunks)
  • core/appmodule/module.go (2 hunks)
  • core/gas/service.go (1 hunks)
  • core/go.mod (1 hunks)
  • runtime/v2/module.go (1 hunks)
  • server/v2/stf/README.md (2 hunks)
  • server/v2/stf/core_gas_service.go (2 hunks)
  • server/v2/stf/gas/defaults.go (1 hunks)
  • server/v2/stf/gas/store.go (3 hunks)
  • server/v2/stf/gas/writer_map.go (2 hunks)
  • store/v2/go.mod (1 hunks)
Files skipped from review due to trivial changes (4)
  • collections/go.mod
  • core/go.mod
  • runtime/v2/module.go
  • store/v2/go.mod
Additional context used
Path-based instructions (7)
server/v2/stf/core_gas_service.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

server/v2/stf/gas/defaults.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

server/v2/stf/gas/writer_map.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

core/gas/service.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

server/v2/stf/README.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

core/appmodule/module.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

server/v2/stf/gas/store.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

LanguageTool
server/v2/stf/README.md

[uncategorized] ~5-~5: When ‘read-only’ is used as a modifier, it is usually spelled with a hyphen.
Context: ...he state transition function receives a read only instance of state. It does not directly...

(READ_ONLY_HYPHEN)


[style] ~34-~34: Consider a shorter alternative to avoid wordiness.
Context: ...terMap ) ``` THe wrappGasMeter is used in order to consume gas. Application developers can...

(IN_ORDER_TO_PREMIUM)


[style] ~34-~34: Consider a shorter alternative to avoid wordiness.
Context: ...gas meter with their own implementation in order to customize consumption of gas.

(IN_ORDER_TO_PREMIUM)

Additional comments not posted (9)
server/v2/stf/core_gas_service.go (1)

29-29: LGTM!

The GasConfig method now returns a default configuration from the stfgas package, which enhances functionality by providing a valid gas configuration.

server/v2/stf/gas/defaults.go (2)

28-28: LGTM!

The type of DefaultConfig has been correctly modified from StoreConfig to coregas.GasConfig, enhancing the management of gas costs.


30-30: LGTM!

The DeleteCostFlat field has been correctly renamed to DeleteCost, reflecting a simplification of the cost structure.

server/v2/stf/gas/writer_map.go (2)

10-10: LGTM!

The parameter type for conf in the NewMeteredWriterMap function has been correctly changed from StoreConfig to gas.GasConfig, enhancing the handling of gas-related settings.


23-23: LGTM!

The internal field config within the MeteredWriterMap struct has been correctly updated to change its type from StoreConfig to gas.GasConfig, maintaining consistency in the type of configuration being utilized.

server/v2/stf/gas/store.go (4)

23-23: LGTM! Standardization of gas configuration.

The change from StoreConfig to gas.GasConfig aligns with the goal of standardizing gas configuration management.


26-29: LGTM! Consistency in gas configuration management.

The NewStore function now accepts gas.GasConfig, ensuring consistency in gas configuration management across the store functionalities.


73-73: LGTM! Refinement in deletion cost calculation.

The Delete method now uses DeleteCost instead of DeleteCostFlat, enhancing clarity and consistency in deletion cost calculation.


110-114: LGTM! Alignment in gas cost configuration.

The iterator struct and newIterator function now use gas.GasConfig, ensuring alignment in gas cost configuration and promoting better maintainability and coherence.

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, codebase verification and nitpick comments (11)
x/protocolpool/module.go (1)

Removal of HasServices Implementation from AppModule.

The removal of _ appmodule.HasServices = AppModule{} in x/protocolpool/module.go impacts the implementation of AppModule. This change affects other parts of the codebase where AppModule was expected to implement the HasServices interface.

Affected Files:

  • types/module/core_module.go
  • types/module/mock_appmodule_test.go
  • types/module/module_test.go
  • runtime/app.go
  • runtime/services/autocli.go

Please review these files to ensure that the removal of the HasServices implementation does not introduce any unintended side effects or break existing functionality.

Analysis chain

Line range hint 14-14:
Verify the impact of removing HasServices implementation.

The removal of _ appmodule.HasServices = AppModule{} simplifies the module's interface. Ensure that this change does not affect other parts of the codebase that may rely on this interface.


Verify the impact of removing HasServices implementation from AppModule.

The removal of _ appmodule.HasServices = AppModule{} might affect other parts of the codebase that rely on AppModule implementing HasServices. We need to ensure that this change does not break any functionality or tests.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify if the removal of `HasServices` implementation affects other parts of the codebase.

# Test: Search for the usage of `HasServices` interface. Expect: No occurrences of `HasServices` in the codebase.
rg --type go 'HasServices'

Length of output: 2372


Script:

#!/bin/bash
# Description: Verify if the removal of `HasServices` implementation affects other parts of the codebase.

# Search for the definition of `AppModule` and its interaction with `HasServices`.
rg --type go 'AppModule' -A 10

Length of output: 464768

x/group/module/module.go (1)

Removal of appmodule.HasServices interface implementation is problematic.

The HasServices interface is still being referenced in several key files. Removing its implementation from AppModule without addressing these references will likely cause issues. The following files contain references to HasServices:

  • runtime/services/autocli.go
  • runtime/app.go
  • runtime/module.go
  • simapp/app_test.go
  • types/module/module.go
  • types/module/core_module.go

Please ensure that these references are properly handled before removing the HasServices interface implementation.

Analysis chain

Line range hint 28-35:
Removal of appmodule.HasServices interface implementation.

The appmodule.HasServices interface implementation has been removed. Ensure that this change does not break any functionality or dependencies relying on this interface.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the removal of `appmodule.HasServices` interface implementation does not break any dependencies.

# Test: Search for the usage of `HasServices` in the codebase. Expect: No broken dependencies.
rg --type go 'HasServices'

Length of output: 2372


Script:

#!/bin/bash
# Description: Verify the impact of removal of `appmodule.HasServices` interface implementation by checking the references in core files.

# Check for references in core files.
rg --type go 'HasServices' types/module/core_module.go types/module/module.go simapp/app_test.go runtime/module.go runtime/app.go runtime/services/autocli.go

Length of output: 790

x/distribution/module.go (1)

Removal of appmodule.HasServices

The removal of appmodule.HasServices from AppModule is likely to impact the module's functionality. The HasServices interface is used extensively across the codebase for registering services, and its absence could break critical functionality.

  • core/appmodule/module.go
  • runtime/services/autocli.go
  • runtime/app.go
  • runtime/module.go
  • simapp/app_test.go
  • testutil/mock/types_module_module.go
  • types/module/mock_appmodule_test.go
  • types/module/module.go
  • types/module/core_module.go

Please ensure that there is a proper replacement or fallback mechanism for HasServices to avoid breaking the module's functionality.

Analysis chain

Line range hint 14-14:
Removal of appmodule.HasServices

The removal of appmodule.HasServices from AppModule suggests that the module no longer needs to handle services through this interface. Ensure that this change does not break any functionality relying on this interface.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify if the removal of `appmodule.HasServices` impacts the module functionality.

# Test: Search for the usage of `HasServices` in the codebase. Expect: No critical dependencies.
rg --type go 'HasServices'

Length of output: 2372


Script:

#!/bin/bash
# Extract context around the usage of `HasServices` in the identified files.

# Search for `HasServices` in the identified files with context lines.
rg --type go -A 5 -B 5 'HasServices' types/module/core_module.go types/module/module_test.go types/module/module.go types/module/mock_appmodule_test.go testutil/mock/types_module_module.go simapp/app_test.go runtime/app.go runtime/services/autocli.go runtime/module.go core/appmodule/module.go

Length of output: 11179

x/gov/module.go (1)

Removal of appmodule.HasServices

The removal of appmodule.HasServices from AppModule affects critical parts of the codebase that rely on this interface to register services. The following files contain dependencies on HasServices:

  • types/module/module.go
  • runtime/app.go
  • runtime/services/autocli.go

Please ensure that these dependencies are addressed to avoid breaking functionality.

Analysis chain

Line range hint 14-14:
Removal of appmodule.HasServices

The removal of appmodule.HasServices from AppModule suggests that the module no longer needs to handle services through this interface. Ensure that this change does not break any functionality relying on this interface.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify if the removal of `appmodule.HasServices` impacts the module functionality.

# Test: Search for the usage of `HasServices` in the codebase. Expect: No critical dependencies.
rg --type go 'HasServices'

Length of output: 2372


Script:

#!/bin/bash
# Extract and display the relevant code snippets for `HasServices` usage to understand its impact.

# Extract from types/module/module.go
rg --type go -A 10 'HasServices' types/module/module.go

# Extract from runtime/app.go
rg --type go -A 10 'HasServices' runtime/app.go

# Extract from runtime/services/autocli.go
rg --type go -A 10 'HasServices' runtime/services/autocli.go

Length of output: 1334

core/CHANGELOG.md (3)

41-41: Ensure consistent use of tense in changelog entries.

The changelog entries should consistently use the past tense for clarity and consistency.

- Comment out `appmodule.HasServices` to simplify dependencies. This interface is however still supported.
+ Commented out `appmodule.HasServices` to simplify dependencies. This interface is however still supported.

41-41: Clarify the support status of appmodule.HasServices.

The phrase "This interface is however still supported" is ambiguous. Specify how it is supported or in what context.

- Comment out `appmodule.HasServices` to simplify dependencies. This interface is however still supported.
+ Commented out `appmodule.HasServices` to simplify dependencies. This interface is still supported in legacy modules.

41-41: Fix grammatical error in changelog entry.

The phrase "Add branch.ExecuteWithGasLimit" should be consistent with the other entries.

- Add branch.ExecuteWithGasLimit.
+ Added `branch.ExecuteWithGasLimit`.
runtime/app.go (2)

81-81: Ensure the correct interface type in RegisterModules method.

The variable name module should be renamed to avoid shadowing and confusion.

- } else if module, ok := appModule.(hasServicesV1); ok {
- if err := module.RegisterServices(a.configurator); err != nil {
+ } else if modV1, ok := appModule.(hasServicesV1); ok {
+ if err := modV1.RegisterServices(a.configurator); err != nil {

276-280: Clarify the purpose of the hasServicesV1 interface.

The comment should explain why the interface is defined and how it is intended to be used.

- // hasServicesV1 is the interface for registering service in baseapp Cosmos SDK.
- // This API is part of core/appmodule but commented out for dependencies.
+ // hasServicesV1 is the interface for registering services in baseapp Cosmos SDK.
+ // This API is part of core/appmodule but is commented out in the main codebase to simplify dependencies.
simapp/app_test.go (1)

111-113: Improve readability of inline interface definition.

The inline interface definition can be moved to a separate variable to improve readability.

- if mod, ok := mod.(interface {
- RegisterServices(grpc.ServiceRegistrar) error
- }); ok {
+ type serviceRegistrar interface {
+   RegisterServices(grpc.ServiceRegistrar) error
+ }
+ if mod, ok := mod.(serviceRegistrar); ok {
types/module/module.go (1)

Inconsistency in Interface Usage:

The RegisterServices method is not consistently using the hasServicesV1 interface across all modules. Please ensure that all modules are updated to implement the hasServicesV1 interface for consistent behavior.

  • Files to update:
    • x/upgrade/module.go
    • x/staking/module.go
    • x/slashing/module.go
    • x/protocolpool/module.go
    • x/mint/module.go
    • x/nft/module/module.go
    • x/params/module.go
    • x/gov/module.go
    • x/group/module/module.go
    • x/authz/module/module.go
    • x/bank/module.go
    • x/distribution/module.go
    • x/feegrant/module/module.go
    • x/evidence/module.go
    • x/circuit/module.go
    • x/epochs/module.go
    • x/consensus/module.go
    • x/auth/module.go
    • x/accounts/module.go
    • testutil/x/counter/module.go
    • runtime/v2/module.go
Analysis chain

Line range hint 395-405: LGTM! But verify the method usage in the codebase.

The changes to the RegisterServices method are approved.

However, ensure that all modules implementing RegisterServices are updated to use the new hasServicesV1 interface.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all implementations of `RegisterServices` use the new `hasServicesV1` interface.

# Test: Search for the `RegisterServices` method. Expect: Only occurrences of the new interface.
rg --type go -A 5 $'RegisterServices'

Length of output: 21286

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 27c68b8 and 12e82ba.

Files selected for processing (25)
  • core/CHANGELOG.md (1 hunks)
  • runtime/app.go (3 hunks)
  • runtime/services/autocli.go (1 hunks)
  • runtime/v2/manager.go (3 hunks)
  • runtime/v2/module.go (3 hunks)
  • runtime/v2/services/autocli.go (1 hunks)
  • simapp/app_test.go (2 hunks)
  • types/module/core_module.go (1 hunks)
  • types/module/module.go (3 hunks)
  • types/module/module_test.go (1 hunks)
  • x/accounts/module.go (1 hunks)
  • x/auth/module.go (1 hunks)
  • x/authz/module/module.go (1 hunks)
  • x/bank/module.go (1 hunks)
  • x/circuit/module.go (1 hunks)
  • x/distribution/module.go (1 hunks)
  • x/feegrant/module/module.go (1 hunks)
  • x/gov/module.go (1 hunks)
  • x/group/module/module.go (1 hunks)
  • x/mint/module.go (1 hunks)
  • x/params/module.go (1 hunks)
  • x/protocolpool/module.go (1 hunks)
  • x/slashing/module.go (1 hunks)
  • x/staking/module.go (1 hunks)
  • x/upgrade/module.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • runtime/v2/module.go
Additional context used
Path-based instructions (24)
x/accounts/module.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/params/module.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/circuit/module.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/protocolpool/module.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

runtime/services/autocli.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

runtime/v2/services/autocli.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/upgrade/module.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/feegrant/module/module.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

types/module/core_module.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/authz/module/module.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/group/module/module.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/staking/module.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/bank/module.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/mint/module.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/slashing/module.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/distribution/module.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/auth/module.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/gov/module.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

core/CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

runtime/app.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

simapp/app_test.go (2)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

runtime/v2/manager.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

types/module/module_test.go (2)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

types/module/module.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

Additional comments not posted (22)
x/accounts/module.go (1)

Line range hint 14-14:
Removal of appmodule.HasServices interface assertion.

The assertion var _ appmodule.HasServices = AppModule{} has been removed. This indicates that AppModule no longer provides services as defined by the HasServices interface. Ensure that this change aligns with the overall design and does not impact other components relying on this interface.

x/params/module.go (1)

Line range hint 14-14:
Removal of appmodule.HasServices interface assertion.

The assertion var _ appmodule.HasServices = AppModule{} has been removed. This indicates that AppModule no longer provides services as defined by the HasServices interface. Ensure that this change aligns with the overall design and does not impact other components relying on this interface.

x/circuit/module.go (1)

Line range hint 14-14:
Removal of appmodule.HasServices interface implementation.

The implementation of the appmodule.HasServices interface has been removed from AppModule. This indicates that AppModule no longer provides services as defined by the HasServices interface. Ensure that this change aligns with the overall design and does not impact other components relying on this interface.

runtime/services/autocli.go (1)

57-59: Improved type safety with explicit method signature.

The modification to the type assertion ensures that only types with the specified RegisterServices(grpc.ServiceRegistrar) error method signature can be treated as valid modules for service registration. This enhances type safety and prevents runtime errors related to incompatible types.

runtime/v2/services/autocli.go (1)

55-57: Enhanced compatibility and flexibility in service registration.

The modification to the ExtractAutoCLIOptions function broadens the interface check to accommodate modules that implement a custom interface with a RegisterServices(grpc.ServiceRegistrar) error method. This improves compatibility and flexibility in handling different module types.

x/upgrade/module.go (1)

Line range hint 14-18:
Verify the impact of removing appmodule.HasServices implementation.

The removal of the appmodule.HasServices interface implementation suggests a shift in design. Ensure that the services previously registered through this interface are either handled differently or are no longer necessary.

Verification successful

Verify the impact of removing appmodule.HasServices implementation.

The RegisterServices method is still implemented in x/upgrade/module.go and continues to register the necessary services. This indicates that the removal of the appmodule.HasServices interface does not affect the functionality, as the services are still being registered correctly.

  • x/upgrade/module.go:81-86
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of removing `appmodule.HasServices` implementation.

# Test: Search for usages of `appmodule.HasServices` to ensure no breaking changes.
rg --type go 'appmodule.HasServices'

Length of output: 117


Script:

#!/bin/bash
# Description: Verify the implementation and usage of `RegisterServices` method.

# Search for the implementation of `RegisterServices` method.
ast-grep --lang go --pattern 'func RegisterServices($_, $_) { $$$ }'

# Search for the usage of `RegisterServices` method.
rg --type go 'RegisterServices'

Length of output: 8719


Script:

#!/bin/bash
# Description: Verify the implementation of `RegisterServices` in `x/upgrade/module.go`.

# Extract the implementation of `RegisterServices` from `x/upgrade/module.go`.
ast-grep --lang go --pattern 'func (am AppModule) RegisterServices(registrar grpc.ServiceRegistrar) error { $$$ }' -- x/upgrade/module.go

Length of output: 491

x/feegrant/module/module.go (1)

Line range hint 21-25:
Verify the impact of removing appmodule.HasServices implementation.

The removal of the appmodule.HasServices interface implementation suggests a shift in design. Ensure that the services previously registered through this interface are either handled differently or are no longer necessary.

Verification successful

Verified the impact of changing the type assertion to hasServicesV1.

The hasServicesV1 interface maintains the core functionality of registering services, similar to the commented-out HasServices interface. Therefore, the change in type assertion is compatible with the expected behavior.

  • hasServicesV1 includes RegisterServices(grpc.ServiceRegistrar) error.
  • The commented-out HasServices also includes RegisterServices and extends AppModule.

The modification does not negatively impact the functionality.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of changing the type assertion to `hasServicesV1`.

# Test: Search for the definition and usage of `hasServicesV1` to ensure compatibility.
rg --type go 'hasServicesV1'

Length of output: 979


Script:

#!/bin/bash
# Description: Compare the definitions of `hasServicesV1` and `appmodule.HasServices`.

# Search for the definition of `appmodule.HasServices`.
rg --type go 'appmodule.HasServices'

Length of output: 117


Script:

#!/bin/bash
# Description: Search for the definition of `HasServices` within the `appmodule` package to compare it with `hasServicesV1`.

# Search for the definition of `HasServices` in the `appmodule` package.
rg --type go 'HasServices' | rg 'appmodule'

Length of output: 400


Script:

#!/bin/bash
# Description: Locate the complete definition of `HasServices` in `core/appmodule/module.go` to compare it with `hasServicesV1`.

# Search for the definition of `HasServices` in `core/appmodule/module.go`.
rg --type go 'HasServices' core/appmodule/module.go

Length of output: 167


Script:

#!/bin/bash
# Description: Extract the definition of `hasServicesV1` and compare it with the commented-out `HasServices` interface.

# Extract the definition of `hasServicesV1`.
rg --type go 'type hasServicesV1 interface' -A 5

# Extract the commented-out definition of `HasServices`.
rg --type go 'type HasServices interface' -A 5 core/appmodule/module.go

Length of output: 793

x/authz/module/module.go (1)

Line range hint 21-28:
Removal of appmodule.HasServices interface implementation.

The appmodule.HasServices interface implementation has been removed. Ensure that this change does not break any functionality or dependencies relying on this interface.

x/staking/module.go (1)

Line range hint 26-34:
Removal of appmodule.HasServices interface implementation.

The appmodule.HasServices interface implementation has been removed. Ensure that this change does not break any functionality or dependencies relying on this interface.

x/bank/module.go (1)

Line range hint 14-14:
Removed appmodule.HasServices interface assertion.

The removal of the appmodule.HasServices interface assertion indicates that the AppModule no longer provides services defined by this interface. Ensure that this change does not affect the functionality of the module or its integration with other components that rely on this interface.

Verification successful

Verification successful: The removal of the appmodule.HasServices interface assertion does not affect the functionality of the module. No critical dependencies on this interface were found in the core module files.

  • The only references to appmodule.HasServices were found in test files, which do not impact the core functionality.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the removal of `appmodule.HasServices` does not affect the functionality of the module.

# Test: Search for the usage of `appmodule.HasServices` in the codebase. Expect: No critical dependencies on this interface.
rg --type go -A 5 $'appmodule.HasServices'

Length of output: 549


Script:

#!/bin/bash
# Description: Verify that the removal of `appmodule.HasServices` does not affect the functionality of the module.

# Test: Search for the usage of `appmodule.HasServices` in the core module files, excluding test files.
rg --type go --glob '!*_test.go' -A 5 $'appmodule.HasServices'

Length of output: 61

x/mint/module.go (1)

Line range hint 14-14:
Removed appmodule.HasServices interface assertion.

The removal of the appmodule.HasServices interface assertion indicates that the AppModule no longer provides services defined by this interface. Ensure that this change does not affect the functionality of the module or its integration with other components that rely on this interface.

Verification successful

Verification successful: The removal of the appmodule.HasServices interface assertion does not affect the functionality of the module. The only references to this interface were found in test files, indicating no critical dependencies in the main codebase.

  • No further action is required.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the removal of `appmodule.HasServices` does not affect the functionality of the module.

# Test: Search for the usage of `appmodule.HasServices` in the codebase. Expect: No critical dependencies on this interface.
rg --type go -A 5 $'appmodule.HasServices'

Length of output: 549


Script:

#!/bin/bash
# Description: Verify that the removal of `appmodule.HasServices` does not affect the functionality of the module.

# Test: Search for the usage of `appmodule.HasServices` in the main codebase, excluding test files. Expect: No critical dependencies on this interface.
rg --type go --glob '!*_test.go' -A 5 $'appmodule.HasServices'

Length of output: 61

x/slashing/module.go (1)

Line range hint 14-14:
Removed appmodule.HasServices interface assertion.

The removal of the appmodule.HasServices interface assertion indicates that the AppModule no longer provides services defined by this interface. Ensure that this change does not affect the functionality of the module or its integration with other components that rely on this interface.

Verification successful

Removal of appmodule.HasServices interface assertion verified.

The appmodule.HasServices interface is only referenced in a test file (types/module/module_test.go) and is not used in the core functionality of the module. Therefore, its removal does not impact the functionality or integration of the module.

  • types/module/module_test.go: Reference found in test implementation.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the removal of `appmodule.HasServices` does not affect the functionality of the module.

# Test: Search for the usage of `appmodule.HasServices` in the codebase. Expect: No critical dependencies on this interface.
rg --type go -A 5 $'appmodule.HasServices'

Length of output: 549


Script:

#!/bin/bash
# Description: Verify that the removal of `appmodule.HasServices` does not affect the functionality of the module.

# Test: Search for any additional references to `appmodule.HasServices` in the codebase. Expect: No critical dependencies on this interface.
rg --type go $'appmodule.HasServices'

Length of output: 117

x/distribution/module.go (1)

Line range hint 1-1:
File Overview

This file implements the AppModule for the x/distribution module. It includes various functionalities such as registering services, migrations, and genesis state management.

x/auth/module.go (2)

Line range hint 1-1:
File Overview

This file implements the AppModule for the x/auth module. It includes various functionalities such as registering services, migrations, and genesis state management.


Line range hint 14-14:
Removal of appmodule.HasServices

The removal of appmodule.HasServices from AppModule suggests that the module no longer needs to handle services through this interface. Ensure that this change does not break any functionality relying on this interface.

x/gov/module.go (1)

Line range hint 1-1:
File Overview

This file implements the AppModule for the x/gov module. It includes various functionalities such as registering services, migrations, and genesis state management.

runtime/v2/manager.go (3)

714-718: Introduction of hasServicesV1 interface looks good.

The new interface hasServicesV1 encapsulates the service registration logic effectively.


Line range hint 428-438: LGTM! But verify the method usage in the codebase.

The changes to the RegisterServices method are approved.

However, ensure that all modules implementing RegisterServices are updated to use the new hasServicesV1 interface.


Line range hint 557-568: LGTM! But verify the function usage in the codebase.

The changes to the registerServices function are approved.

However, ensure that all calls to registerServices are updated to use the new hasServicesV1 interface.

Verification successful

Function usage verified!

The services variable is correctly checked for the hasServicesV1 interface before being passed to the registerServices function.

  • runtime/v2/manager.go:
    • services is verified to implement hasServicesV1 before being used.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all calls to `registerServices` use the new `hasServicesV1` interface.

# Test: Search for the `registerServices` function calls. Expect: Only occurrences of the new interface.
rg --type go -A 5 $'registerServices'

Length of output: 748


Script:

#!/bin/bash
# Description: Verify that the `services` variable implements the `hasServicesV1` interface.

# Find the definition of `services` in the runtime/v2/manager.go file.
rg --type go --context 10 'services' runtime/v2/manager.go

Length of output: 1176

types/module/module.go (2)

96-102: Introduction of hasServicesV1 interface looks good.

The new interface hasServicesV1 encapsulates the service registration logic effectively.


33-33: Introduction of hasServicesV1 interface looks good.

The new interface hasServicesV1 encapsulates the service registration logic effectively.

@akhilkumarpilli
Copy link
Contributor

I have a small question, we are setting gas config in app_config.go, but it seems like gasService.GasConfig always returns the default gasConfig here. Shouldn't these two be linked? Am I missing something?

@julienrbrt
Copy link
Member Author

I have a small question, we are setting gas config in app_config.go, but it seems like gasService.GasConfig always returns the default gasConfig here. Shouldn't these two be linked? Am I missing something?

Read too fast earlier, but those aren't the same. There are the gas limits from the app config and the gas costs from (stf) gas service. One is app wide, the other one can be node wide.

@julienrbrt
Copy link
Member Author

julienrbrt commented Aug 5, 2024

I have to say that the runtime gas config is a bit weird and its config (app.toml) is still not super well implemented. I will do that in a follow-up.

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

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 12e82ba and 61a82de.

Files selected for processing (2)
  • runtime/v2/module.go (3 hunks)
  • simapp/go.mod (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • runtime/v2/module.go
Additional comments not posted (2)
simapp/go.mod (2)

51-51: Direct dependency addition looks good.

The addition of google.golang.org/grpc v1.64.1 as a direct dependency is correctly formatted and placed.


52-52: Indirect dependency removal looks good.

The removal of google.golang.org/grpc v1.64.1 as an indirect dependency is correctly reflected.

@akhilkumarpilli
Copy link
Contributor

I have a small question, we are setting gas config in app_config.go, but it seems like gasService.GasConfig always returns the default gasConfig here. Shouldn't these two be linked? Am I missing something?

Read too fast earlier, but those aren't the same. There are the gas limits from the app config and the gas costs from (stf) gas service. One is app wide, the other one can be node wide.

Understood. Bit confused with same name.

@julienrbrt
Copy link
Member Author

Understood. Bit confused with same name.

Agreed, I'll be renaming the one from runtime.

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

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 61a82de and 18869bd.

Files ignored due to path filters (1)
  • store/v2/go.sum is excluded by !**/*.sum
Files selected for processing (2)
  • simapp/go.mod (2 hunks)
  • store/v2/go.mod (1 hunks)
Files skipped from review due to trivial changes (1)
  • store/v2/go.mod
Files skipped from review as they are similar to previous changes (1)
  • simapp/go.mod

Copy link
Contributor

@testinginprod testinginprod left a comment

Choose a reason for hiding this comment

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

lgtm

@julienrbrt julienrbrt added this pull request to the merge queue Aug 8, 2024
Merged via the queue into main with commit 7040177 Aug 8, 2024
94 checks passed
@julienrbrt julienrbrt deleted the julien/stfcore branch August 8, 2024 07:34
@julienrbrt
Copy link
Member Author

Partially backporting this in v0.52 for module changes

@julienrbrt
Copy link
Member Author

@Mergifyio backport release/v0.52.x

Copy link
Contributor

mergify bot commented Aug 8, 2024

backport release/v0.52.x

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Aug 8, 2024
(cherry picked from commit 7040177)

# Conflicts:
#	collections/go.mod
#	collections/go.sum
#	core/CHANGELOG.md
#	core/appmodule/module.go
#	core/gas/service.go
#	core/go.mod
#	core/go.sum
#	core/testing/go.sum
#	runtime/v2/manager.go
#	runtime/v2/module.go
#	runtime/v2/services/autocli.go
#	server/v2/appmanager/go.sum
#	server/v2/stf/README.md
#	server/v2/stf/core_gas_service.go
#	server/v2/stf/gas/defaults.go
#	server/v2/stf/gas/store.go
#	server/v2/stf/gas/writer_map.go
#	server/v2/stf/go.sum
#	store/v2/go.mod
#	store/v2/go.sum
julienrbrt added a commit that referenced this pull request Aug 8, 2024
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