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

fix(server/v2/cometbft): fix mock store #22293

Merged
merged 1 commit into from
Oct 17, 2024
Merged

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented Oct 17, 2024

Description

Follow-up of #22285


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

    • Updated the storage mechanism to utilize VersionedWriter, enhancing performance and compatibility.
  • Documentation

    • Revised documentation to reflect changes from VersionedDatabase to VersionedWriter across the storage package.
  • Bug Fixes

    • Corrected interface assertions and comments to ensure accurate representation of the StorageStore functionality.

Copy link
Contributor

coderabbitai bot commented Oct 17, 2024

📝 Walkthrough

Walkthrough

The changes in this pull request involve modifications to the MockStore structure and related components in the mock package. The primary update is the transition from using storev2.VersionedDatabase to storev2.VersionedWriter across various functions and interfaces. This includes alterations to function signatures and return types, as well as updates to documentation in the storage package to reflect the new interface terminology.

Changes

File Path Change Summary
server/v2/cometbft/internal/mock/... Updated MockStore to use storev2.VersionedWriter instead of storev2.VersionedDatabase.
store/v2/mock/types.go Updated StateStorage interface to mock store.VersionedWriter instead of store.VersionedDatabase.
store/v2/storage/README.md Updated documentation to replace references of VersionedDatabase with VersionedWriter.
store/v2/storage/store.go Updated StorageStore documentation and interface assertions to reflect store.VersionedWriter.

Possibly related PRs

Suggested labels

C:server/v2 cometbft, C:Store, C:x/accounts, C:x/group, backport/v0.52.x

Suggested reviewers

  • kocubinski
  • tac0turtle
  • hieuvubk
  • cool-develope
  • sontrinh16

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.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@julienrbrt your pull request is missing a changelog!

Copy link
Contributor

@hieuvubk hieuvubk left a comment

Choose a reason for hiding this comment

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

lgtm

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

🧹 Outside diff range and nitpick comments (4)
store/v2/mock/types.go (1)

Remove Unused UpgradableDatabase from StateStorage Interface

The StateStorage interface currently embeds store.UpgradableDatabase, but there are no implementations or usages of UpgradableDatabase found in the codebase. It is recommended to remove store.UpgradableDatabase from the StateStorage interface to eliminate unnecessary dependencies.

  • File: store/v2/mock/types.go
  • Lines: 10-16
🔗 Analysis chain

Line range hint 14-18: Verify consistency of embedded interfaces

The StateStorage interface correctly embeds store.VersionedWriter, which aligns with the updated comment. However, it also embeds store.UpgradableDatabase. Please verify if this is still appropriate given the transition from VersionedDatabase to VersionedWriter.

To check the definitions and usages of these interfaces:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check definitions and usages of VersionedWriter and UpgradableDatabase

echo "Definition of VersionedWriter:"
rg --type go "type\s+VersionedWriter\s+interface"

echo "Definition of UpgradableDatabase:"
rg --type go "type\s+UpgradableDatabase\s+interface"

echo "Usages of UpgradableDatabase in relation to VersionedWriter:"
rg --type go -C 5 "UpgradableDatabase.*VersionedWriter|VersionedWriter.*UpgradableDatabase"

Length of output: 590


Script:

#!/bin/bash
# Description: Find all implementations of the StateStorage interface

echo "Searching for implementations of StateStorage:"
rg --type go "type\s+\w+\s+struct\s+.*StateStorage"

echo "Searching for methods implementing UpgradableDatabase:"
rg --type go "func\s+\(.*\)\s+.*UpgradableDatabase"

echo "Checking for deprecation notices related to UpgradableDatabase:"
rg --type go "Deprecated.*UpgradableDatabase"

echo "Listing all references to UpgradableDatabase in comments:"
rg --type go "//.*UpgradableDatabase"

Length of output: 997

server/v2/cometbft/internal/mock/mock_store.go (2)

19-19: LGTM! Consider updating documentation.

The change from storev2.VersionedDatabase to storev2.VersionedWriter for the Storage field is appropriate. It suggests a more focused interface for writing versioned data, which aligns well with the mock store's responsibilities.

Consider adding a comment to explain the rationale behind using VersionedWriter instead of VersionedDatabase. This would help future maintainers understand the design decision.


86-86: LGTM! Update method documentation.

The change in the return type from storev2.VersionedDatabase to storev2.VersionedWriter is consistent with the previous modifications.

Consider updating the method documentation to reflect the new return type and explain any implications of this change for users of the MockStore.

store/v2/storage/store.go (1)

25-25: LGTM with a minor suggestion for documentation improvement.

The update to use store.VersionedWriter instead of store.VersionedDatabase in the StorageStore documentation and interface assertions is correct and aligns with the changes in the underlying functionality.

Consider expanding the documentation slightly to provide more context:

- // StorageStore is a wrapper around the store.VersionedWriter interface.
+ // StorageStore is a wrapper around the store.VersionedWriter interface,
+ // providing versioned storage capabilities for the Cosmos SDK.

This addition gives readers a clearer understanding of the struct's purpose within the larger system.

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 553e110 and 35cfec7.

📒 Files selected for processing (4)
  • server/v2/cometbft/internal/mock/mock_store.go (3 hunks)
  • store/v2/mock/types.go (1 hunks)
  • store/v2/storage/README.md (4 hunks)
  • store/v2/storage/store.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
server/v2/cometbft/internal/mock/mock_store.go (1)

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

store/v2/mock/types.go (1)

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

store/v2/storage/README.md (1)

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

store/v2/storage/store.go (1)

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

🪛 LanguageTool
store/v2/storage/README.md

[misspelling] ~95-~95: Did you mean “meant”?
Context: ...rface in the storage package which is mean to be represent a VersionedWriter wit...

(MEAN_MEANT)


[grammar] ~95-~95: Consider using either the past participle “represented” or the present participle “representing” here.
Context: ...e storage package which is mean to be represent a VersionedWriter with only the neces...

(BEEN_PART_AGREEMENT)

🔇 Additional comments (7)
store/v2/mock/types.go (1)

13-13: Comment update reflects interface change.

The comment has been updated to indicate that StateStorage is now a mock of store.VersionedWriter instead of store.VersionedDatabase. This change aligns with the PR objectives and the AI-generated summary, which mention a transition from storev2.VersionedDatabase to storev2.VersionedWriter.

To ensure consistency across the codebase, let's verify the usage of VersionedWriter:

✅ Verification successful

Comment update verified successfully.

The StateStorage comment now correctly references store.VersionedWriter, and there are no remaining occurrences of VersionedDatabase in the codebase. This change aligns with the project's objectives and maintains consistency.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for occurrences of VersionedWriter and VersionedDatabase

echo "Occurrences of VersionedWriter:"
rg --type go "VersionedWriter"

echo "Occurrences of VersionedDatabase:"
rg --type go "VersionedDatabase"

Length of output: 2211

server/v2/cometbft/internal/mock/mock_store.go (3)

39-39: LGTM! Consistent change.

The modification of the ss parameter type from storev2.VersionedDatabase to storev2.VersionedWriter is consistent with the previous changes. This ensures type consistency throughout the mock store implementation.


Line range hint 1-138: Overall assessment: Changes are consistent and well-implemented.

The modifications in this file consistently replace storev2.VersionedDatabase with storev2.VersionedWriter across the MockStore implementation. This change likely reflects a design decision to use a more specific interface for writing versioned data.

Key points:

  1. All changes are consistent and properly implemented.
  2. The transition to VersionedWriter might provide better encapsulation of write operations.
  3. Minor suggestions for documentation updates have been made to improve code clarity.

To further improve the PR:

  1. Update relevant documentation to explain the rationale behind using VersionedWriter.
  2. Verify that all callers of these modified functions are updated accordingly.
  3. Ensure that comprehensive tests are in place to validate the behavior with the new interface.

23-23: LGTM! Verify storage.NewStorageStore return type.

The change in the return type from storev2.VersionedDatabase to storev2.VersionedWriter is consistent with the MockStore struct modification.

Please verify that storage.NewStorageStore now returns a storev2.VersionedWriter. Run the following command to check:

Ensure that $ret_type matches storev2.VersionedWriter or a type that implements this interface.

store/v2/storage/README.md (3)

5-5: LGTM: Interface update correctly reflected

The change from VersionedDatabase to VersionedWriter is consistent with the reported interface update.


29-29: LGTM: Interface update correctly reflected in RocksDB section

The change from VersionedDatabase to VersionedWriter is consistent in the RocksDB implementation description.


45-45: LGTM: Interface update correctly reflected in SQLite section

The change from VersionedDatabase to VersionedWriter is consistent in the SQLite implementation description.

store/v2/storage/README.md Show resolved Hide resolved
@julienrbrt julienrbrt added this pull request to the merge queue Oct 17, 2024
@julienrbrt julienrbrt added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Oct 17, 2024
Merged via the queue into main with commit f01baf3 Oct 17, 2024
82 of 83 checks passed
@julienrbrt julienrbrt deleted the julien/fix-store-build branch October 17, 2024 09:19
mergify bot pushed a commit that referenced this pull request Oct 17, 2024
(cherry picked from commit f01baf3)

# Conflicts:
#	store/v2/mock/types.go
#	store/v2/storage/README.md
#	store/v2/storage/store.go
julienrbrt added a commit that referenced this pull request Oct 17, 2024
@coderabbitai coderabbitai bot mentioned this pull request Dec 9, 2024
12 tasks
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 C:Store
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants