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(simapp): Audit simapp #21311

Merged
merged 23 commits into from
Aug 29, 2024
Merged

refactor(simapp): Audit simapp #21311

merged 23 commits into from
Aug 29, 2024

Conversation

hieuvubk
Copy link
Contributor

@hieuvubk hieuvubk commented Aug 15, 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, 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
    • Added new standalone commands for improved functionality.
    • Introduced a new command to bootstrap the state.
  • Bug Fixes
    • Minor formatting adjustments made without affecting functionality.
  • Chores
    • Enhanced command registration process for better readability and maintainability.
  • Refactor
    • Transitioned from method-based to standalone functions for command handling.
    • Simplified the application configuration retrieval process.

Copy link
Contributor

coderabbitai bot commented Aug 15, 2024

Walkthrough

Walkthrough

The changes involve refactoring several functions in the CometBFTServer project, converting methods into standalone functions, thereby reducing dependencies on the server's state. The rpcClient function and various command functions have been modified to enhance modularity. Additionally, a minor formatting change was made in the getConfigTomlFromViper function, and a new command was added to the CLI command list.

Changes

Files Change Summary
server/v2/cometbft/commands.go Refactored multiple methods of CometBFTServer into standalone functions, including rpcClient, StatusCommand, and others, reducing state dependencies.
server/v2/cometbft/config.go Added a new line in getConfigTomlFromViper for formatting; no functional changes were made.
server/v2/cometbft/server.go Updated CLICommands method to reference standalone functions instead of instance methods; added BootstrapStateCmd to the command list.
simapp/v2/go.mod Introduced a new direct dependency on cosmossdk.io/x/epochs module, replacing the previous indirect entry.
simapp/v2/simdv2/cmd/commands.go Removed several block-related query commands from the CLI command list, impacting the available commands for users.
simapp/v2/simdv2/cmd/testnet.go Removed commented-out code and simplified the writeFile function's return statement for improved readability.

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

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

Other keywords and placeholders

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

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.

@hieuvubk
Copy link
Contributor Author

seems like duplicate with #21310 🤯

@julienrbrt julienrbrt added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Aug 16, 2024
@julienrbrt
Copy link
Member

seems like duplicate with #21310 🤯

It isn't we actually found different stuff ❤️

@hieuvubk hieuvubk marked this pull request as ready for review August 27, 2024 07:01
@hieuvubk hieuvubk requested a review from a team as a code owner August 27, 2024 07:01
@julienrbrt julienrbrt mentioned this pull request Aug 27, 2024
28 tasks
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 (1)
simapp/app.go (1)

Issues Found: Impact of Removing consensustypes.ModuleName

The removal of consensustypes.ModuleName from the NewSimApp function may lead to inconsistencies, as it is still used in other parts of the codebase:

  • simapp/app_config.go
  • simapp/v2/app_config.go

Please review these files to ensure that all dependencies on consensustypes.ModuleName are correctly handled or removed to maintain the application's integrity.

Analysis chain

Line range hint 1-1: Verify the impact of the removal of consensustypes.ModuleName.

The removal of consensustypes.ModuleName from the NewSimApp function may affect other parts of the codebase that rely on the consensus module. Ensure that all dependencies on the consensus module are correctly handled or removed.

Run the following script to verify the usage of consensustypes.ModuleName in the codebase:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `consensustypes.ModuleName` in the codebase.

# Test: Search for the usage of `consensustypes.ModuleName`. Expect: No occurrences.
rg --type go 'consensustypes.ModuleName'

Length of output: 315

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 58af7ee and 42d7553.

Files ignored due to path filters (1)
  • simapp/v2/go.sum is excluded by !**/*.sum
Files selected for processing (16)
  • simapp/CHANGELOG.md (1 hunks)
  • simapp/app.go (1 hunks)
  • simapp/app_config.go (1 hunks)
  • simapp/app_di.go (1 hunks)
  • simapp/export.go (8 hunks)
  • simapp/genesis_account.go (1 hunks)
  • simapp/simd/cmd/commands.go (1 hunks)
  • simapp/simd/cmd/config.go (1 hunks)
  • simapp/simd/cmd/testnet.go (1 hunks)
  • simapp/v2/app_config.go (5 hunks)
  • simapp/v2/app_di.go (4 hunks)
  • simapp/v2/genesis_account.go (1 hunks)
  • simapp/v2/genesis_account_test.go (1 hunks)
  • simapp/v2/go.mod (3 hunks)
  • simapp/v2/simdv2/cmd/commands.go (1 hunks)
  • simapp/v2/simdv2/cmd/testnet.go (2 hunks)
Files skipped from review due to trivial changes (6)
  • simapp/CHANGELOG.md
  • simapp/app_config.go
  • simapp/app_di.go
  • simapp/simd/cmd/config.go
  • simapp/simd/cmd/testnet.go
  • simapp/v2/simdv2/cmd/testnet.go
Additional context used
Path-based instructions (9)
simapp/genesis_account.go (1)

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

simapp/v2/genesis_account.go (1)

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

simapp/v2/genesis_account_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"

simapp/simd/cmd/commands.go (1)

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

simapp/v2/simdv2/cmd/commands.go (1)

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

simapp/v2/app_di.go (1)

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

simapp/export.go (1)

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

simapp/v2/app_config.go (1)

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

simapp/app.go (1)

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

Learnings (1)
simapp/v2/genesis_account_test.go (1)
Learnt from: testinginprod
PR: cosmos/cosmos-sdk#18542
File: x/bank/types/balance.go:64-77
Timestamp: 2023-11-22T14:48:50.376Z
Learning: - The `SanitizeGenesisBalances` function in `x/bank/types/balance.go` of the Cosmos SDK should panic when encountering duplicate account addresses in the genesis state.
- A test case is required to verify the behavior of `SanitizeGenesisBalances` when duplicates are present.
Additional comments not posted (19)
simapp/genesis_account.go (1)

34-34: LGTM!

The updated error message accurately reflects the validation logic, improving clarity.

The code changes are approved.

simapp/v2/genesis_account.go (1)

34-34: LGTM!

The updated error message accurately reflects the validation logic, improving clarity.

The code changes are approved.

simapp/v2/genesis_account_test.go (1)

1-89: Well-written test cases!

The test function comprehensively covers various scenarios for validating SimGenesisAccount, ensuring robust test coverage.

The code changes are approved.

simapp/simd/cmd/commands.go (2)

152-152: LGTM!

The change to use viperAppOpts instead of appOpts is appropriate and ensures the correct configuration is used.

The code changes are approved.


158-158: LGTM!

The change to use viperAppOpts instead of appOpts is appropriate and ensures the correct configuration is used.

The code changes are approved.

simapp/v2/simdv2/cmd/commands.go (1)

Line range hint 63-63: Verify the impact of removed commands.

The removal of server.QueryBlockCmd(), server.QueryBlocksCmd(), and server.QueryBlockResultsCmd() reduces the available commands for querying block-related information. Ensure that these removals do not negatively impact the user experience or functionality.

Run the following script to verify the usage of these commands in the codebase:

simapp/v2/app_di.go (3)

22-22: LGTM!

The addition of the epochskeeper package is appropriate for managing epochs within the application's lifecycle.

The code changes are approved.


73-73: LGTM!

The addition of the EpochsKeeper field to the SimApp struct is appropriate for managing epochs within the application's lifecycle.

The code changes are approved.


182-182: LGTM!

The update to the NewSimApp function ensures that the EpochsKeeper is properly initialized when creating an instance of SimApp.

The code changes are approved.

simapp/export.go (5)

52-54: LGTM!

The updated comment provides a clearer description of the function's purpose.

The code changes are approved.


69-69: LGTM!

The updated error handling using panic(err) enforces stricter error management.

The code changes are approved.


82-85: LGTM!

The updated error handling using panic(err) enforces stricter error management.

The code changes are approved.


99-101: LGTM!

The updated address conversion using sdk.MustValAddressFromBech32 and sdk.MustAccAddressFromBech32 simplifies the code.

The code changes are approved.


238-238: LGTM!

The updated error handling using panic(err) enforces stricter error management.

The code changes are approved.

simapp/v2/app_config.go (3)

18-18: LGTM!

The import statement for epochsmodulev1 is necessary to utilize functionalities from the epochs module.

The code changes are approved.


49-50: LGTM!

The addition of epochstypes.ModuleName ensures that the epochs module is recognized and properly integrated into the application's block processing flow.

The code changes are approved.


278-281: LGTM!

The incorporation of epochstypes.ModuleName into the module configuration list enhances the application's modular capabilities by integrating the epochs module into its operational structure.

The code changes are approved.

simapp/v2/go.mod (2)

24-24: LGTM!

The addition of the cosmossdk.io/x/epochs module in the require section is necessary to explicitly incorporate the module into the project's dependencies.

The code changes are approved.


263-263: LGTM!

The addition of the cosmossdk.io/x/epochs module in the replace section is necessary to manage the specific version or commit of the module being utilized.

The code changes are approved.

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

lgtm! nice cleanups

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 42d7553 and fe63167.

Files selected for processing (1)
  • simapp/v2/app_di.go (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • simapp/v2/app_di.go

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 fe63167 and 819afd2.

Files selected for processing (6)
  • simapp/CHANGELOG.md (1 hunks)
  • simapp/app.go (1 hunks)
  • simapp/app_config.go (1 hunks)
  • simapp/app_di.go (1 hunks)
  • simapp/simd/cmd/config.go (1 hunks)
  • simapp/v2/app_config.go (5 hunks)
Files skipped from review due to trivial changes (3)
  • simapp/CHANGELOG.md
  • simapp/app_config.go
  • simapp/app_di.go
Files skipped from review as they are similar to previous changes (3)
  • simapp/app.go
  • simapp/simd/cmd/config.go
  • simapp/v2/app_config.go

simapp/export.go Outdated
@@ -80,7 +79,10 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
if err != nil {
panic(err)
}
_, _ = app.DistrKeeper.WithdrawValidatorCommission(ctx, valBz)
_, err = app.DistrKeeper.WithdrawValidatorCommission(ctx, valBz)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should check the error, it fails tests when a validator has no commission.
Could you revert?

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 819afd2 and 08ebc82.

Files selected for processing (1)
  • simapp/export.go (7 hunks)
Files skipped from review as they are similar to previous changes (1)
  • simapp/export.go

@github-actions github-actions bot added C:server/v2 Issues related to server/v2 C:server/v2 cometbft labels Aug 28, 2024
@@ -605,7 +605,7 @@ jobs:
simdv2 start &
SIMD_PID=$!
cnt=0
while ! simdv2 query block --type=height 5; do
while ! simdv2 query comet block --type=height 5; do
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update a little bit CI and server/v2/cometbft since we using cometbft queries

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

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 08ebc82 and acb8140.

Files ignored due to path filters (1)
  • simapp/v2/go.sum is excluded by !**/*.sum
Files selected for processing (5)
  • .github/workflows/test.yml (1 hunks)
  • server/v2/cometbft/commands.go (1 hunks)
  • server/v2/cometbft/config.go (1 hunks)
  • server/v2/cometbft/server.go (1 hunks)
  • simapp/v2/go.mod (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • simapp/v2/go.mod
Additional context used
Path-based instructions (3)
server/v2/cometbft/config.go (1)

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

server/v2/cometbft/server.go (1)

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

server/v2/cometbft/commands.go (1)

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

Additional comments not posted (3)
server/v2/cometbft/server.go (1)

63-63: Streamline configuration retrieval in Init method.

The change to use getAppTomlFromViper directly simplifies the configuration setup. Ensure that this modification integrates seamlessly with all dependent components of the CometBFTServer.

The modification is approved, but verification is recommended to ensure no regressions in the initialization process.

Run integration tests to confirm that all components dependent on AppTomlConfig are functioning correctly.

server/v2/cometbft/commands.go (1)

32-33: Enhance configuration retrieval in rpcClient.

The use of getAppTomlFromViper for dynamic configuration retrieval is a positive change, improving flexibility and maintainability. Ensure robust error handling is in place for cases where configuration retrieval fails.

The change is approved, but adding comprehensive error handling is recommended to prevent issues during RPC client initialization.

.github/workflows/test.yml (1)

608-608: Verify the updated command for querying comet blocks.

The change from simdv2 query block --type=height 5 to simdv2 query comet block --type=height 5 indicates a shift to a more specific block type. Ensure that this new command is supported by simdv2 and correctly implemented in the context of the intended functionality.

Comment on lines 68 to 75
func getAppTomlFromViper(v *viper.Viper) *AppTomlConfig {
appTomlConfig := DefaultAppTomlConfig()
if err := serverv2.UnmarshalSubConfig(v, ServerName, &appTomlConfig); err != nil {
return DefaultAppTomlConfig()
}

return appTomlConfig
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Review the error handling strategy in getAppTomlFromViper.

The function correctly handles configuration retrieval with a fallback to the default configuration. However, it would be beneficial to log the error when unmarshalling fails to aid in debugging and ensure that configuration issues are noticeable.

Consider adding error logging before returning the default configuration:

if err := serverv2.UnmarshalSubConfig(v, ServerName, &appTomlConfig); err != nil {
+  log.Errorf("Failed to unmarshal AppTomlConfig: %v", err)
  return DefaultAppTomlConfig()
}
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. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
func getAppTomlFromViper(v *viper.Viper) *AppTomlConfig {
appTomlConfig := DefaultAppTomlConfig()
if err := serverv2.UnmarshalSubConfig(v, ServerName, &appTomlConfig); err != nil {
return DefaultAppTomlConfig()
}
return appTomlConfig
}
func getAppTomlFromViper(v *viper.Viper) *AppTomlConfig {
appTomlConfig := DefaultAppTomlConfig()
if err := serverv2.UnmarshalSubConfig(v, ServerName, &appTomlConfig); err != nil {
log.Errorf("Failed to unmarshal AppTomlConfig: %v", err)
return DefaultAppTomlConfig()
}
return appTomlConfig
}

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 acb8140 and adcda83.

Files selected for processing (2)
  • simapp/simd/cmd/testnet.go (1 hunks)
  • simapp/v2/simdv2/cmd/testnet.go (2 hunks)
Files skipped from review due to trivial changes (1)
  • simapp/v2/simdv2/cmd/testnet.go
Files skipped from review as they are similar to previous changes (1)
  • simapp/simd/cmd/testnet.go

@@ -64,3 +64,12 @@ func getConfigTomlFromViper(v *viper.Viper) *cmtcfg.Config {

return conf.SetRoot(rootDir)
}

func getAppTomlFromViper(v *viper.Viper) *AppTomlConfig {
appTomlConfig := DefaultAppTomlConfig()
Copy link
Member

Choose a reason for hiding this comment

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

I think the default should be s.config and not DefaultAppTomlConfig

}

// StatusCommand returns the command to return the status of the network.
func (s *CometBFTServer[T]) StatusCommand() *cobra.Command {
func StatusCommand() *cobra.Command {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

comet queries should not relayed on CometBFTServer anymore.

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 adcda83 and 3bd4f72.

Files selected for processing (3)
  • server/v2/cometbft/commands.go (11 hunks)
  • server/v2/cometbft/config.go (1 hunks)
  • server/v2/cometbft/server.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • server/v2/cometbft/config.go
Additional context used
Path-based instructions (2)
server/v2/cometbft/server.go (1)

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

server/v2/cometbft/commands.go (1)

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

Additional comments not posted (10)
server/v2/cometbft/server.go (2)

236-241: LGTM! Improved modularity.

The changes enhance modularity by referencing standalone functions instead of instance methods.

The code changes are approved.


241-241: Verify the new command addition.

Ensure that the new command s.BootstrapStateCmd() is correctly implemented and integrated.

Run the following script to verify the implementation of BootstrapStateCmd:

Verification successful

BootstrapStateCmd Implementation Verified

The method BootstrapStateCmd is implemented in server/v2/cometbft/commands.go and is correctly integrated in server/v2/cometbft/server.go. The implementation aligns with the expected structure and usage. No issues found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of `BootstrapStateCmd`.

# Test: Search for the function implementation. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'func (s *CometBFTServer[T]) BootstrapStateCmd() *cobra.Command'

Length of output: 84


Script:

#!/bin/bash
# Searching for any occurrence of BootstrapStateCmd in the codebase
rg --type go 'BootstrapStateCmd'

Length of output: 343

server/v2/cometbft/commands.go (8)

31-55: LGTM! Improved modularity.

The rpcClient function has been converted to a standalone function, enhancing modularity by allowing it to operate independently of the server's internal state.

The code changes are approved.


Line range hint 59-74: LGTM! Improved modularity.

The StatusCommand function has been converted to a standalone function, enhancing modularity by reducing dependencies on the server's state.

The code changes are approved.


Line range hint 90-101: LGTM! Improved modularity.

The ShowNodeIDCmd function has been converted to a standalone function, enhancing modularity by reducing dependencies on the server's state.

The code changes are approved.


Line range hint 108-129: LGTM! Improved modularity.

The ShowValidatorCmd function has been converted to a standalone function, enhancing modularity by reducing dependencies on the server's state.

The code changes are approved.


Line range hint 142-153: LGTM! Improved modularity.

The ShowAddressCmd function has been converted to a standalone function, enhancing modularity by reducing dependencies on the server's state.

The code changes are approved.


Line range hint 161-180: LGTM! Improved modularity.

The VersionCmd function has been converted to a standalone function, enhancing modularity by reducing dependencies on the server's state.

The code changes are approved.


Line range hint 189-221: LGTM! Improved modularity.

The QueryBlocksCmd function has been converted to a standalone function, enhancing modularity by reducing dependencies on the server's state.

The code changes are approved.


Line range hint 327-347: LGTM! Improved modularity.

The QueryBlockResultsCmd function has been converted to a standalone function, enhancing modularity by reducing dependencies on the server's state.

The code changes are approved.

func (s *CometBFTServer[T]) rpcClient(cmd *cobra.Command) (rpc.CometRPC, error) {
if s.config.AppTomlConfig.Standalone {
func rpcClient(cmd *cobra.Command) (rpc.CometRPC, error) {
v := client.GetViperFromCmd(cmd)
Copy link
Member

Choose a reason for hiding this comment

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

when doing queries it shouldn't need to read the app.toml actually right, but the client.toml

Copy link
Contributor Author

Choose a reason for hiding this comment

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

only for Standalone check, should we remove? I think FlagNode is enough

Copy link
Member

Choose a reason for hiding this comment

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

Yeah flag node will get if from client.toml, so that's great. Not sure what a standalone check means for query tbh.

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 3bd4f72 and 55701f6.

Files ignored due to path filters (1)
  • simapp/v2/go.sum is excluded by !**/*.sum
Files selected for processing (4)
  • server/v2/cometbft/commands.go (11 hunks)
  • simapp/v2/go.mod (3 hunks)
  • simapp/v2/simdv2/cmd/commands.go (1 hunks)
  • simapp/v2/simdv2/cmd/testnet.go (2 hunks)
Files skipped from review due to trivial changes (2)
  • server/v2/cometbft/commands.go
  • simapp/v2/simdv2/cmd/testnet.go
Files skipped from review as they are similar to previous changes (2)
  • simapp/v2/go.mod
  • simapp/v2/simdv2/cmd/commands.go

@hieuvubk
Copy link
Contributor Author

should I merge this now? @julienrbrt

@julienrbrt julienrbrt added this pull request to the merge queue Aug 29, 2024
Merged via the queue into main with commit 4096fb8 Aug 29, 2024
74 checks passed
@julienrbrt julienrbrt deleted the hieu/simapp-audit branch August 29, 2024 21:28
mergify bot pushed a commit that referenced this pull request Aug 29, 2024
(cherry picked from commit 4096fb8)

# Conflicts:
#	simapp/v2/go.mod
#	simapp/v2/go.sum
julienrbrt added a commit that referenced this pull request Aug 29, 2024
Co-authored-by: Hieu Vu <72878483+hieuvubk@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release C:server/v2 cometbft C:server/v2 Issues related to server/v2 Type: CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants