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(cometBFTService): some more minor cleanups #2021

Merged
merged 2 commits into from
Sep 27, 2024

Conversation

abi87
Copy link
Contributor

@abi87 abi87 commented Sep 25, 2024

I have collected here some minor cleanups around CometBFT service:

  1. dropped loadLatest bool since I believe we must call LoadLatestVersion() in order to initialize the stores. Failing of doing that causes a panic
  2. dropped SetName since it is not called and name is set in service constructor
  3. dropped SetVersion since it's simple the assignment of a service attribute that can be done inline
  4. modified StoreKeyServiceProvider to return a pointer rather than a pointer to a pointer. It's important to avoid copying the key, but passing around the pointer should be enough. All consumers of the key deference the double pointer.

I collected the changes together in the interest of reducing the number of PRs. Happy to further split them if reviewers require it.

Summary by CodeRabbit

  • New Features

    • Streamlined service initialization process by simplifying parameters and logic related to loading the latest version.
  • Bug Fixes

    • Removed outdated methods for setting service name and version, improving clarity and functionality.
  • Refactor

    • Updated function signatures to enhance parameter handling and reduce complexity in service-related functions.

@abi87 abi87 self-assigned this Sep 25, 2024
Copy link
Contributor

coderabbitai bot commented Sep 25, 2024

Walkthrough

The pull request introduces several modifications across multiple files in the codebase. Key changes include the removal of the SetName and SetVersion methods from the Service struct, the simplification of the NewService function by eliminating a boolean parameter, and adjustments to pointer types in various function signatures. These alterations impact how services are initialized and how certain parameters are passed, streamlining the overall code structure.

Changes

Files Change Summary
mod/consensus/pkg/cometbft/service/options.go Removed methods SetName and SetVersion from the Service struct.
mod/consensus/pkg/cometbft/service/service.go Updated NewService function to remove loadLatest parameter and simplified state loading logic.
mod/node-core/pkg/components/cometbft_service.go, mod/node-core/pkg/components/depinject.go Changed storeKey parameter type from **storetypes.KVStoreKey to *storetypes.KVStoreKey.

Possibly related PRs

Suggested reviewers

  • nidhi-singh02
  • ocnc
  • itsdevbear

🐰 In the code where bunnies hop,
Changes made, we’ll never stop!
Methods gone, but fear not,
Simpler paths are what we’ve got.
With pointers light and logic clear,
Let’s celebrate, give a cheer! 🎉


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.

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

codecov bot commented Sep 25, 2024

Codecov Report

Attention: Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.

Project coverage is 22.38%. Comparing base (9cbd0b0) to head (df03bcf).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
mod/consensus/pkg/cometbft/service/service.go 0.00% 3 Missing ⚠️
mod/node-core/pkg/components/depinject.go 0.00% 3 Missing ⚠️
mod/node-core/pkg/components/cometbft_service.go 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2021   +/-   ##
=======================================
  Coverage   22.37%   22.38%           
=======================================
  Files         358      358           
  Lines       16051    16045    -6     
  Branches       12       12           
=======================================
  Hits         3591     3591           
+ Misses      12311    12305    -6     
  Partials      149      149           
Flag Coverage Δ
22.38% <0.00%> (+<0.01%) ⬆️
Files with missing lines Coverage Δ
mod/consensus/pkg/cometbft/service/options.go 0.00% <ø> (ø)
mod/node-core/pkg/components/cometbft_service.go 0.00% <0.00%> (ø)
mod/consensus/pkg/cometbft/service/service.go 0.00% <0.00%> (ø)
mod/node-core/pkg/components/depinject.go 0.00% <0.00%> (ø)

@abi87 abi87 marked this pull request as ready for review September 25, 2024 20:07
Comment on lines +118 to +119
if err := s.sm.LoadLatestVersion(); err != nil {
panic(err)
Copy link
Contributor Author

@abi87 abi87 Sep 25, 2024

Choose a reason for hiding this comment

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

we must do this, otherwise beconKit will panic. The if loadLatest is confusing to me, as it suggests this initialization is not mandatory

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 its safe to remove, I think loadLatest was for if u want to instantiate a the cosmos BaseApp without initializing the DB, I don't see why we need this tho.

@itsdevbear itsdevbear merged commit dc08b08 into main Sep 27, 2024
16 checks passed
@itsdevbear itsdevbear deleted the cometBFT-some-more-cleanup branch September 27, 2024 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants