Skip to content

fix(collections): make use of exported iterator from dbm #24524

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

mmsqe
Copy link
Contributor

@mmsqe mmsqe commented Apr 15, 2025

Description

Closes: #24464, depends on cosmos/cosmos-db#127


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

  • Refactor
    • Updated the iterator type to use an external implementation, replacing the local interface.
    • Improved naming consistency and type annotations in mock database implementations.
    • Adopted more descriptive parameter names and updated interface return types in mock methods for clarity.

mmsqe added 2 commits April 15, 2025 23:23
to avoid cannot handle non-empty unnamed interfaces error on mockgen
Copy link

ironbird-prod bot commented Apr 15, 2025

Ironbird - launch a network To use Ironbird, you can use the following commands:
  • /ironbird start OR /ironbird start --load-test-config= - Launch a testnet with the specified chain and load test configuration.
  • /ironbird chains - List of chain images that ironbird can use to spin-up testnet
  • /ironbird loadtests - List of load test modes that ironbird can run against testnet
Custom Load Test Configuration You can provide a custom load test configuration using the `--load-test-config=` flag:
/ironbird start cosmos --load-test-config={
  "block_gas_limit_target": 0.75,
  "num_of_blocks": 50,
  "msgs": [
    {"weight": 0.3, "type": "MsgSend"},
    {"weight": 0.3, "type": "MsgMultiSend"},
	{"weight": 0.4, "type": "MsgArr", "ContainedType": "MsgSend", "NumMsgs": 3300}
  ]
}

Use /ironbird loadtests to see more examples.

@aljo242
Copy link
Contributor

aljo242 commented Apr 29, 2025

cosmos/cosmos-db#127

also will need conflict resolution

@mmsqe mmsqe marked this pull request as ready for review May 5, 2025 19:52
Copy link
Contributor

coderabbitai bot commented May 5, 2025

📝 Walkthrough

Walkthrough

The changes update the Iterator type in collections/corecompat/store.go from a local interface to an alias of dbm.Iterator from the external cosmos-db package. The mock implementation of the DB interface in store/mock/cosmos_cosmos_db_DB.go is regenerated for compatibility with updated type definitions and Go conventions.

Changes

File(s) Change Summary
collections/corecompat/store.go Changed Iterator from a local interface to a type alias of dbm.Iterator from the cosmos-db package; updated import statements accordingly.
store/mock/cosmos_cosmos_db_DB.go Regenerated mock for DB from cosmos-db: updated parameter names, changed parameter types from interface{} to any, changed return types to new interface names, added isgomock field, updated file header.

Assessment against linked issues

Objective Addressed Explanation
Support handling of non-empty unnamed interfaces and type aliases in mockgen (#24464)

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 39e90e1 and 380bd94.

⛔ Files ignored due to path filters (9)
  • collections/go.mod is excluded by !**/*.mod
  • collections/go.sum is excluded by !**/*.sum, !**/*.sum
  • core/go.mod is excluded by !**/*.mod
  • core/go.sum is excluded by !**/*.sum, !**/*.sum
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum, !**/*.sum
  • store/go.mod is excluded by !**/*.mod
  • store/go.sum is excluded by !**/*.sum, !**/*.sum
  • tests/go.mod is excluded by !**/*.mod
📒 Files selected for processing (2)
  • collections/corecompat/store.go (2 hunks)
  • store/mock/cosmos_cosmos_db_DB.go (9 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
collections/corecompat/store.go (1)
collections/iter.go (1)
  • Iterator (211-218)
store/mock/cosmos_cosmos_db_DB.go (1)
collections/corecompat/store.go (1)
  • Iterator (62-62)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze
  • GitHub Check: Summary
🔇 Additional comments (9)
collections/corecompat/store.go (2)

3-7: Good addition of the cosmos-db package import

The import of the cosmos-db package with the dbm alias aligns with the PR objective to utilize the exported iterator from dbm. This is a step toward better dependency management and code reuse.


62-62: Excellent refactoring to use the standard iterator interface

Converting the locally defined Iterator interface to a type alias of dbm.Iterator eliminates interface duplication and ensures consistency with the cosmos-db package. This change simplifies the codebase and makes it easier to maintain as the iterator implementation evolves in the dependency.

This change directly addresses the issue mentioned in the PR objectives and will help ensure that collections interfaces remain in sync with the underlying database APIs.

store/mock/cosmos_cosmos_db_DB.go (7)

3-7: Documentation improvement with mockgen command

Adding the exact mockgen command used to generate the file is helpful for maintainers who need to regenerate the mock in the future.


23-23: Mock struct field addition for gomock compatibility

The addition of the isgomock struct{} field is a standard pattern in newer gomock-generated mocks that helps with type assertions and improves mock identification.


66-66: Updated recorder function parameter types to use Go 1.18+ 'any' type

All the mock recorder functions have been updated to use the any type instead of interface{}, which follows modern Go conventions introduced in Go 1.18+.

Also applies to: 80-80, 95-95, 110-110, 125-125, 153-153, 182-182, 196-196, 210-210


100-113: Improved parameter naming in Has method

Renamed generic parameter names like arg0 to more descriptive names like key, which improves code readability and makes the mock implementation more maintainable.


116-120: Updated return types to use IteratorI interface

Changed return types from db.Iterator to db.IteratorI in both Iterator and ReverseIterator methods to match the interface naming conventions in the cosmos-db package. This ensures consistency with the interface updates in the dependent cosmos-db PR mentioned in the PR objectives.

Also applies to: 173-177


131-135: Updated return types for batch operations

Changed return types from db.Batch to db.BatchI in both NewBatch and NewBatchWithSize methods, maintaining consistency with the interface naming pattern in the cosmos-db package.

Also applies to: 145-149


124-128: Improved parameter naming in iterator methods

Parameters for Iterator and ReverseIterator methods have been renamed from generic arg0, arg1 to more descriptive start, end, which directly correspond to their usage and improve code readability.

Also applies to: 181-185

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

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

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

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.

[Bug]: cannot handle non-empty unnamed interfaces in mockgen
2 participants