Skip to content

Conversation

@mmsqe
Copy link
Contributor

@mmsqe mmsqe commented Mar 24, 2025

Description

Reopen #22893


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

    • Enabled object store mounting with a new API.
    • Added a SpendableBalances query for retrieving total account balances.
    • Introduced an event for pruned group proposals.
  • Improvements

    • Enhanced proposal processing to respect initial blockchain parameters.
    • Strengthened bank module permissions with additional safety checks.
  • Chores

    • Updated dependencies and refined internal storage handling with generics.

yihuang and others added 6 commits March 24, 2025 21:11
generic interface

generic btree

generic cachekv

generic transient store

support ObjStore

changelog

Update CHANGELOG.md

Signed-off-by: yihuang <[email protected]>

object store key

Apply review suggestions

fix merge conflict

fix snapshot

revert dependers

Problem: store key type assertion is incorrect (cosmos#244)

fix and add test

resolve

Apply suggestions from code review

cleanup
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 24, 2025

📝 Walkthrough

Walkthrough

This pull request introduces support for mounting object stores in the BaseApp and adds a new ObjectStore API to the Context. In addition, it adjusts proposal processing, event logging in the group module, and bank module functionality (including a new SpendableBalances gRPC query). Public API changes include updates to the Calculator and runtime modules. A large set of store implementations (cachekv, gaskv, cachemulti, listenkv, prefix, rootmulti, tracekv, transient, etc.) have been refactored to leverage Go generics for improved type safety and flexibility. Finally, multiple go.mod files have been updated with new dependency versions and replace directives for the store module.

Changes

File(s) Change Summary
baseapp/baseapp.go, runtime/module.go, runtime/store.go Added object store mounting support; introduced MountObjectStores and ProvideObjectStoreKey; updated iterator return types to use new generic types.
src/calculator.py Added coderabbit_add method; updated signature of coderabbit_formula to include an extra parameter; renamed a global variable.
store/* (cachekv, gaskv, cachemulti, listenkv, prefix, rootmulti, tracekv, transient, types, types/validity.go, internal/btree*, internal/btreeadaptor.go) Integrated Go generics into store implementations; refactored method signatures and iterators; introduced new types such as GStore, ObjStore, and ObjectStoreKey to enhance type safety and flexibility.
client/v2/go.mod, go.mod, server/v2/cometbft/go.mod, simapp/v2/go.mod, tests/go.mod, tools/benchmark/go.mod, x/*/go.mod Updated dependency versions for github.com/cosmos/iavl (v1.3.4 → v1.3.5) and github.com/hashicorp/go-plugin (v1.6.2 → v1.6.3); added replace directives for cosmossdk.io/store with appropriate relative paths.
x/accounts/*, x/authz/*, x/bank/*, x/circuit/*, x/consensus/*, x/distribution/*, x/epochs/*, x/evidence/*, x/feegrant/*, x/gov/*, x/group/*, x/mint/*, x/nft/*, x/protocolpool/*, x/slashing/*, x/staking/*, x/upgrade/* Applied uniform dependency version updates and replace directives across various modules for consistency with the new store module structure.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Context
    participant MultiStore
    participant ObjStoreAdapter

    Client->>Context: Call ObjectStore(key)
    Context->>MultiStore: GetObjKVStore(key)
    MultiStore-->>Context: Return ObjKVStore instance
    Context->>ObjStoreAdapter: Invoke gaskv.NewObjStore(ObjStore, gasMeter, transientKVGasConfig)
    ObjStoreAdapter-->>Context: Return wrapped object store
    Context-->>Client: Return ObjKVStore
Loading

Possibly related PRs

  • chore: prepare v2 beta (2/3) #23032: Contains changes related to object store functionality and dependency updates, showing a shared focus on the cosmossdk.io/store module enhancements.

Suggested labels

C:x/params, C:collections, C:core/testing, C:indexer/postgres

Suggested reviewers

  • julienrbrt
  • sontrinh16
  • akhilkumarpilli

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 golangci-lint (1.64.8)

level=warning msg="[runner] Can't run linter goanalysis_metalinter: buildir: failed to load package sqlite3: could not load export data: no export data for "github.com/bvinc/go-sqlite-lite/sqlite3""
level=error msg="Running error: can't run linter goanalysis_metalinter\nbuildir: failed to load package sqlite3: could not load export data: no export data for "github.com/bvinc/go-sqlite-lite/sqlite3""

✨ 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:

  • 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 generate docstrings to generate docstrings for 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.

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.

store, ok := cms.getCacheWrap(key).(types.KVStore)
if !ok {
panic(fmt.Sprintf("store with key %v is not KVStore", key))
}

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
store := types.KVStore(s)
store, ok := s.(types.KVStore)
if !ok {
panic(fmt.Sprintf("store with key %v is not KVStore", key))

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
// AssertValidValueGeneric checks if the value is valid(value is not nil and within length limit)
func AssertValidValueGeneric[V any](value V, isZero func(V) bool, valueLen func(V) int) {
if isZero(value) {
panic("value is nil")

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
@mmsqe mmsqe marked this pull request as ready for review March 24, 2025 14:23
@mmsqe mmsqe requested a review from a team March 24, 2025 14:23
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: 2

🧹 Nitpick comments (12)
x/staking/go.mod (1)

167-170: Update Replace Directives for Local Module Paths
The new replace block now maps cosmossdk.io/store to ../../store and cosmossdk.io/x/bank to ../bank. This aligns with the coordinated dependency management across modules. Please confirm that the relative paths are correct relative to the repository structure. Also, note that the accompanying TODO on line 166 indicates these directives are temporary until the modules are fully spun out.

store/listenkv/store.go (1)

133-137: Update method documentation to match implementation

The documentation above the CacheWrap method still indicates that the method panics, but the implementation has been changed to return a cache-wrapped store instead of panicking.

Update the documentation to accurately reflect the new behavior:

- // CacheWrap implements the KVStore interface. It panics as a Store
- // cannot be cache wrapped.
+ // CacheWrap implements the KVStore interface. It returns a cache-wrapped
+ // version of the store.
func (s *Store) CacheWrap() types.CacheWrap {
	return cachekv.NewStore(s)
}
store/tracekv/store.go (1)

164-166: Updated CacheWrap implementation now delegates to parent store

The method now properly implements the CacheWrapper interface by delegating to the parent store's CacheWrap method instead of panicking. This is a good improvement and aligns with the Store interface requiring CacheWrapper implementation.

However, there's an inconsistency with CacheWrapWithTrace (line 171) which still panics with "cannot CacheWrapWithTrace a TraceKVStore". Consider updating CacheWrapWithTrace to also delegate to the parent for consistency.

 func (tkv *Store) CacheWrapWithTrace(_ io.Writer, _ types.TraceContext) types.CacheWrap {
-	panic("cannot CacheWrapWithTrace a TraceKVStore")
+	return tkv.parent.CacheWrapWithTrace(_, _)
 }
store/tracekv/store_test.go (1)

284-287: Test updated to remove panic expectation

The test has been updated to align with the implementation change in CacheWrap(). However, the test now only verifies that CacheWrap() doesn't panic, but doesn't validate that it correctly delegates to the parent store.

Consider enhancing this test to verify that the method properly delegates to the parent's CacheWrap method, perhaps by using a mock parent store or checking properties of the returned CacheWrap.

func TestTraceKVStoreCacheWrap(t *testing.T) {
	store := newEmptyTraceKVStore(nil)
-	store.CacheWrap()
+	cacheWrap := store.CacheWrap()
+	// Verify cacheWrap is not nil and has expected properties
+	require.NotNil(t, cacheWrap)
+	// Additional verification that it delegates correctly
}
store/internal/btreeadaptor.go (2)

25-28: Incorrect comment format for Has method

The comment for the Has method doesn't follow the standard Go comment format. Function comments should be complete sentences that begin with the function name.

-// Hash Implements GKVStore.
+// Has implements GKVStore. It checks if a key exists in the store.
 func (ts *BTreeStore[V]) Has(key []byte) bool {
   return !ts.isZero(ts.Get(key))
 }

30-44: Iterator methods panic on errors

Both Iterator methods panic when encountering errors from the underlying BTree. While this follows the pattern of other packages in this codebase, consider if this is the desired behavior or if returning an error would be more appropriate to allow for graceful error handling.

Additionally, consider adding validation for the input parameters.

types/context.go (1)

356-359: Fix the comment style for consistency.

The implementation of ObjectStore looks good and properly follows the same pattern as the existing store methods. However, the comment ends with a comma instead of a period, which is inconsistent with other similar method comments.

-// ObjectStore fetches an object store from the MultiStore,
+// ObjectStore fetches an object store from the MultiStore.
runtime/module.go (1)

246-250: Add config.SkipStoreKeys check for consistency.

The ProvideObjectStoreKey function is missing the config.SkipStoreKeys check that exists in the other similar functions (ProvideKVStoreKey, ProvideTransientStoreKey, and ProvideMemoryStoreKey). This creates an inconsistency with the established pattern.

-func ProvideObjectStoreKey(key depinject.ModuleKey, app *AppBuilder) *storetypes.ObjectStoreKey {
+func ProvideObjectStoreKey(
+	config *runtimev1alpha1.Module,
+	key depinject.ModuleKey,
+	app *AppBuilder,
+) *storetypes.ObjectStoreKey {
+	if slices.Contains(config.SkipStoreKeys, key.Name()) {
+		return nil
+	}
+
 	storeKey := storetypes.NewObjectStoreKey(fmt.Sprintf("object:%s", key.Name()))
 	registerStoreKey(app, storeKey)
 	return storeKey
}

Also, the function is missing a comment describing its purpose, unlike other similar provider functions.

store/types/store.go (1)

303-311: Introduction of type aliases for typed vs. object-based stores
The new type aliases (Iterator, BasicKVStore, ObjIterator, ObjKVStore, etc.) neatly wrap the generic interfaces with specialized names. Consider verifying overhead for reflection-based usage in ObjKVStore.

store/prefix/store.go (1)

184-193: Next method and TODO
The TODO comment suggests potentially setting pi to nil after invalidation. Consider whether future refactoring is needed to reflect that behavior or if the current approach suffices.

store/gaskv/store.go (1)

9-10: ObjectValueLength constant
Defining ObjectValueLength as the gas cost basis for object storage is a reasonable approximation. Consider revisiting to ensure the cost remains balanced if object usage expands.

store/cachekv/store.go (1)

326-327: Formatting alert from static analysis.
Consider reformatting around line 326. Running Go format tools will address any spacing or ordering issues.

🧰 Tools
🪛 golangci-lint (1.64.8)

326-326: File is not properly formatted

(gci)

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between da5a74d and 6d22720.

⛔ Files ignored due to path filters (26)
  • client/v2/go.sum is excluded by !**/*.sum
  • go.sum is excluded by !**/*.sum
  • server/v2/cometbft/go.sum is excluded by !**/*.sum
  • simapp/v2/go.sum is excluded by !**/*.sum
  • tests/go.sum is excluded by !**/*.sum
  • tools/benchmark/go.sum is excluded by !**/*.sum
  • x/accounts/defaults/base/go.sum is excluded by !**/*.sum
  • x/accounts/defaults/lockup/go.sum is excluded by !**/*.sum
  • x/accounts/defaults/multisig/go.sum is excluded by !**/*.sum
  • x/accounts/go.sum is excluded by !**/*.sum
  • x/authz/go.sum is excluded by !**/*.sum
  • x/bank/go.sum is excluded by !**/*.sum
  • x/circuit/go.sum is excluded by !**/*.sum
  • x/consensus/go.sum is excluded by !**/*.sum
  • x/distribution/go.sum is excluded by !**/*.sum
  • x/epochs/go.sum is excluded by !**/*.sum
  • x/evidence/go.sum is excluded by !**/*.sum
  • x/feegrant/go.sum is excluded by !**/*.sum
  • x/gov/go.sum is excluded by !**/*.sum
  • x/group/go.sum is excluded by !**/*.sum
  • x/mint/go.sum is excluded by !**/*.sum
  • x/nft/go.sum is excluded by !**/*.sum
  • x/protocolpool/go.sum is excluded by !**/*.sum
  • x/slashing/go.sum is excluded by !**/*.sum
  • x/staking/go.sum is excluded by !**/*.sum
  • x/upgrade/go.sum is excluded by !**/*.sum
📒 Files selected for processing (52)
  • CHANGELOG.md (1 hunks)
  • baseapp/baseapp.go (2 hunks)
  • client/v2/go.mod (3 hunks)
  • go.mod (3 hunks)
  • runtime/module.go (2 hunks)
  • runtime/store.go (1 hunks)
  • server/v2/cometbft/go.mod (3 hunks)
  • simapp/v2/go.mod (3 hunks)
  • store/CHANGELOG.md (1 hunks)
  • store/cachekv/internal/mergeiterator.go (11 hunks)
  • store/cachekv/search_benchmark_test.go (2 hunks)
  • store/cachekv/store.go (11 hunks)
  • store/cachemulti/store.go (4 hunks)
  • store/gaskv/store.go (2 hunks)
  • store/internal/btree/btree.go (3 hunks)
  • store/internal/btree/btree_test.go (4 hunks)
  • store/internal/btree/memiterator.go (6 hunks)
  • store/internal/btree/memiterator_test.go (3 hunks)
  • store/internal/btreeadaptor.go (1 hunks)
  • store/listenkv/store.go (2 hunks)
  • store/listenkv/store_test.go (1 hunks)
  • store/prefix/store.go (9 hunks)
  • store/rootmulti/store.go (17 hunks)
  • store/rootmulti/store_test.go (5 hunks)
  • store/tracekv/store.go (1 hunks)
  • store/tracekv/store_test.go (1 hunks)
  • store/transient/store.go (1 hunks)
  • store/types/store.go (7 hunks)
  • store/types/validity.go (2 hunks)
  • tests/go.mod (3 hunks)
  • tools/benchmark/go.mod (2 hunks)
  • types/context.go (1 hunks)
  • x/accounts/defaults/base/go.mod (3 hunks)
  • x/accounts/defaults/lockup/go.mod (2 hunks)
  • x/accounts/defaults/multisig/go.mod (3 hunks)
  • x/accounts/go.mod (3 hunks)
  • x/authz/go.mod (3 hunks)
  • x/bank/go.mod (3 hunks)
  • x/circuit/go.mod (3 hunks)
  • x/consensus/go.mod (3 hunks)
  • x/distribution/go.mod (3 hunks)
  • x/epochs/go.mod (3 hunks)
  • x/evidence/go.mod (3 hunks)
  • x/feegrant/go.mod (3 hunks)
  • x/gov/go.mod (3 hunks)
  • x/group/go.mod (3 hunks)
  • x/mint/go.mod (3 hunks)
  • x/nft/go.mod (3 hunks)
  • x/protocolpool/go.mod (3 hunks)
  • x/slashing/go.mod (3 hunks)
  • x/staking/go.mod (3 hunks)
  • x/upgrade/go.mod (3 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
`**/*.md`: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

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

  • store/CHANGELOG.md
  • CHANGELOG.md
`**/*.go`: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

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

  • store/internal/btree/memiterator_test.go
  • store/tracekv/store_test.go
  • runtime/module.go
  • store/types/validity.go
  • store/listenkv/store.go
  • store/tracekv/store.go
  • types/context.go
  • store/listenkv/store_test.go
  • store/internal/btreeadaptor.go
  • store/internal/btree/btree_test.go
  • runtime/store.go
  • store/cachekv/search_benchmark_test.go
  • store/cachemulti/store.go
  • store/internal/btree/btree.go
  • store/prefix/store.go
  • store/internal/btree/memiterator.go
  • store/transient/store.go
  • store/rootmulti/store_test.go
  • store/cachekv/internal/mergeiterator.go
  • store/rootmulti/store.go
  • store/gaskv/store.go
  • store/types/store.go
  • store/cachekv/store.go
  • baseapp/baseapp.go
`**/*_test.go`: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

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

  • store/internal/btree/memiterator_test.go
  • store/tracekv/store_test.go
  • store/listenkv/store_test.go
  • store/internal/btree/btree_test.go
  • store/cachekv/search_benchmark_test.go
  • store/rootmulti/store_test.go
`tests/**/*`: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"

tests/**/*: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"

  • tests/go.mod
🧬 Code Definitions (14)
store/tracekv/store_test.go (2)
store/cachekv/store.go (15)
  • store (71-73)
  • store (76-91)
  • store (94-101)
  • store (104-107)
  • store (110-117)
  • store (119-135)
  • store (138-181)
  • store (184-186)
  • store (189-194)
  • store (200-202)
  • store (205-207)
  • store (209-233)
  • store (318-390)
  • store (392-412)
  • store (419-428)
store/types/store.go (1)
  • CacheWrap (336-341)
store/tracekv/store.go (6)
store/cachemulti/store.go (1)
  • Store (24-31)
store/cachekv/store.go (2)
  • Store (30-30)
  • parent (218-218)
store/gaskv/store.go (2)
  • Store (14-14)
  • parent (128-128)
store/types/store.go (2)
  • Store (16-19)
  • CacheWrap (336-341)
store/listenkv/store.go (2)
  • Store (15-19)
  • parent (70-70)
store/transient/store.go (2)
  • Store (29-31)
  • Store (40-42)
store/internal/btreeadaptor.go (3)
store/types/store.go (11)
  • KVStore (306-306)
  • key (449-451)
  • key (453-455)
  • key (471-473)
  • key (476-478)
  • key (494-496)
  • key (499-501)
  • key (513-515)
  • key (518-520)
  • Iterator (304-304)
  • GIterator (275-301)
store/internal/btree/btree.go (1)
  • BTree (25-27)
store/cachekv/store.go (2)
  • err (217-217)
  • NewGStore (59-68)
store/cachekv/search_benchmark_test.go (4)
store/cachekv/store.go (2)
  • cValue (20-23)
  • GStore (43-56)
store/gaskv/store.go (1)
  • GStore (34-41)
store/transient/store.go (1)
  • GStore (19-21)
store/internal/btree/btree.go (1)
  • NewBTree (30-37)
store/cachemulti/store.go (3)
store/types/store.go (5)
  • CacheWrap (336-341)
  • CacheWrapper (343-349)
  • TraceContext (526-526)
  • Store (16-19)
  • KVStore (306-306)
store/cachekv/store.go (17)
  • store (71-73)
  • store (76-91)
  • store (94-101)
  • store (104-107)
  • store (110-117)
  • store (119-135)
  • store (138-181)
  • store (184-186)
  • store (189-194)
  • store (200-202)
  • store (205-207)
  • store (209-233)
  • store (318-390)
  • store (392-412)
  • store (419-428)
  • Store (30-30)
  • NewStore (34-40)
store/tracekv/store.go (2)
  • Store (27-31)
  • NewStore (47-49)
store/internal/btree/memiterator.go (1)
store/internal/btree/btree.go (5)
  • item (84-87)
  • BTree (25-27)
  • newItem (95-97)
  • empty (44-44)
  • empty (53-53)
store/transient/store.go (4)
store/types/store.go (4)
  • Committer (22-32)
  • Store (16-19)
  • KVStore (306-306)
  • StoreType (363-363)
store/gaskv/store.go (3)
  • Store (14-14)
  • ObjStore (23-23)
  • GStore (34-41)
store/internal/btreeadaptor.go (8)
  • BTreeStore (14-18)
  • NewBTreeStore (21-23)
  • ts (26-28)
  • ts (30-36)
  • ts (38-44)
  • ts (47-49)
  • ts (52-54)
  • ts (57-59)
store/internal/btree/btree.go (1)
  • NewBTree (30-37)
store/rootmulti/store_test.go (2)
store/types/store.go (4)
  • CommitKVStore (324-327)
  • NewKVStoreKey (427-434)
  • StoreKey (410-413)
  • CommitStore (45-48)
store/rootmulti/store.go (2)
  • db (1054-1054)
  • NewStore (91-105)
store/cachekv/internal/mergeiterator.go (3)
store/cachekv/store.go (2)
  • parent (218-218)
  • err (217-217)
store/gaskv/store.go (1)
  • parent (128-128)
store/types/store.go (2)
  • GIterator (275-301)
  • Iterator (304-304)
store/rootmulti/store.go (6)
store/types/store.go (17)
  • StoreKey (410-413)
  • CommitStore (45-48)
  • Store (16-19)
  • key (449-451)
  • key (453-455)
  • key (471-473)
  • key (476-478)
  • key (494-496)
  • key (499-501)
  • key (513-515)
  • key (518-520)
  • CommitKVStore (324-327)
  • KVStore (306-306)
  • s (96-101)
  • s (104-109)
  • s (113-123)
  • StoreTypeObject (373-373)
store/iavl/store.go (7)
  • Store (36-40)
  • _ (27-27)
  • _ (28-28)
  • _ (29-29)
  • _ (30-30)
  • _ (31-31)
  • _ (32-32)
store/cachekv/store.go (17)
  • Store (30-30)
  • store (71-73)
  • store (76-91)
  • store (94-101)
  • store (104-107)
  • store (110-117)
  • store (119-135)
  • store (138-181)
  • store (184-186)
  • store (189-194)
  • store (200-202)
  • store (205-207)
  • store (209-233)
  • store (318-390)
  • store (392-412)
  • store (419-428)
  • _ (32-32)
store/gaskv/store.go (3)
  • Store (14-14)
  • ObjStore (23-23)
  • _ (12-12)
store/listenkv/store.go (9)
  • Store (15-19)
  • s (29-32)
  • s (36-40)
  • s (44-47)
  • s (51-53)
  • s (57-59)
  • s (63-65)
  • s (69-79)
  • _ (10-10)
store/transient/store.go (6)
  • Store (29-31)
  • Store (40-42)
  • ObjStore (45-47)
  • ObjStore (56-58)
  • _ (11-11)
  • _ (12-12)
store/gaskv/store.go (9)
store/types/store.go (14)
  • KVStore (306-306)
  • Store (16-19)
  • GKVStore (254-272)
  • key (449-451)
  • key (453-455)
  • key (471-473)
  • key (476-478)
  • key (494-496)
  • key (499-501)
  • key (513-515)
  • key (518-520)
  • Iterator (304-304)
  • GIterator (275-301)
  • TraceContext (526-526)
store/cachekv/store.go (5)
  • Store (30-30)
  • GStore (43-56)
  • parent (218-218)
  • NewGStore (59-68)
  • _ (32-32)
store/prefix/store.go (6)
  • Store (14-14)
  • GStore (42-48)
  • NewGStore (50-61)
  • _ (19-19)
  • _ (20-20)
  • _ (153-153)
store/cachemulti/store.go (2)
  • Store (24-31)
  • _ (33-33)
store/listenkv/store.go (3)
  • Store (15-19)
  • parent (70-70)
  • _ (10-10)
store/tracekv/store.go (2)
  • Store (27-31)
  • parent (96-96)
store/types/validity.go (1)
  • AssertValidValueGeneric (34-39)
store/internal/btree/memiterator.go (1)
  • _ (12-12)
store/internal/btreeadaptor.go (1)
  • _ (11-11)
store/types/store.go (5)
store/prefix/store.go (4)
  • Store (14-14)
  • _ (19-19)
  • _ (20-20)
  • _ (153-153)
store/rootmulti/store.go (3)
  • Store (59-80)
  • _ (83-83)
  • _ (84-84)
store/iavl/store.go (7)
  • Store (36-40)
  • _ (27-27)
  • _ (28-28)
  • _ (29-29)
  • _ (30-30)
  • _ (31-31)
  • _ (32-32)
store/cachemulti/store.go (2)
  • Store (24-31)
  • _ (33-33)
store/transient/store.go (2)
  • Store (29-31)
  • Store (40-42)
store/cachekv/store.go (4)
store/types/store.go (14)
  • CacheKVStore (316-321)
  • Store (16-19)
  • KVStore (306-306)
  • GKVStore (254-272)
  • key (449-451)
  • key (453-455)
  • key (471-473)
  • key (476-478)
  • key (494-496)
  • key (499-501)
  • key (513-515)
  • key (518-520)
  • Iterator (304-304)
  • GIterator (275-301)
store/internal/btree/btree.go (2)
  • BTree (25-27)
  • NewBTree (30-37)
store/types/validity.go (1)
  • AssertValidValueGeneric (34-39)
store/cachekv/internal/mergeiterator.go (1)
  • NewCacheMergeIterator (29-39)
baseapp/baseapp.go (1)
store/types/store.go (10)
  • ObjectStoreKey (481-483)
  • key (449-451)
  • key (453-455)
  • key (471-473)
  • key (476-478)
  • key (494-496)
  • key (499-501)
  • key (513-515)
  • key (518-520)
  • StoreTypeObject (373-373)
🪛 GitHub Check: CodeQL
store/types/validity.go

[warning] 36-36: Panic in BeginBock or EndBlock consensus methods
Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt

store/cachemulti/store.go

[warning] 177-177: Panic in BeginBock or EndBlock consensus methods
Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt

store/rootmulti/store.go

[warning] 697-697: Panic in BeginBock or EndBlock consensus methods
Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt

🪛 golangci-lint (1.64.8)
store/cachekv/store.go

326-326: File is not properly formatted

(gci)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze
  • GitHub Check: Summary
🔇 Additional comments (201)
x/circuit/go.mod (3)

57-57: Update github.com/cosmos/iavl Dependency Version
The dependency version has been upgraded to v1.3.5 consistently with other modules. Please verify that this version is fully compatible with the rest of the codebase.


86-86: Upgrade github.com/hashicorp/go-plugin Dependency
The version update to v1.6.3 aligns with the coordinated dependency changes across the project. Confirm that this update introduces no breaking changes for plugin usage.


164-169: New Replace Directive for cosmossdk.io/store
A new replace directive mapping cosmossdk.io/store to ../../store has been added to facilitate local development. Please verify that the relative path is correct within the project’s module structure.

x/accounts/defaults/lockup/go.mod (2)

58-58: Update github.com/cosmos/iavl Dependency
The dependency update to v1.3.5 is in line with similar changes elsewhere. No further issues were detected.


156-162: New Replace Directives for Module Paths
The replace block now maps cosmossdk.io/store to ../../../../store along with updates for other modules. Ensure that these relative paths correctly reflect the directory layout for proper resolution during builds.

x/nft/go.mod (3)

57-57: Update github.com/cosmos/iavl Dependency Version
The upgrade to v1.3.5 is consistent with the broader dependency updates in the repository.


86-86: Upgrade github.com/hashicorp/go-plugin Dependency
The dependency has been updated to v1.6.3. Please ensure that this change does not introduce incompatibilities with existing plugin interfaces.


162-168: Introduce New Replace Directive for cosmossdk.io/store
Mapping cosmossdk.io/store to ../../store supports local development and testing. Confirm that the provided relative paths (also for x/bank and x/staking) are correct.

x/accounts/defaults/multisig/go.mod (3)

54-54: Update github.com/cosmos/iavl Dependency Version
Upgraded to v1.3.5 to maintain consistency. No issues observed.


80-80: Upgrade github.com/hashicorp/go-plugin Dependency
The version is now v1.6.3; please double-check compatibility with any code utilizing this package.


163-168: New Replace Directives for Module Paths
The new replace block—including the mapping for cosmossdk.io/store to ../../../../store—ensures proper resolution given the module's deeper directory structure. Verify that these relative paths are correct within the project.

x/authz/go.mod (2)

51-51: Update github.com/cosmos/iavl Dependency Version
The dependency now uses v1.3.5, which is consistent with updates across the repository.


170-176: New Replace Directive for cosmossdk.io/store and Related Modules
A new replace block maps cosmossdk.io/store to ../../store (along with adjustments for x/bank and x/staking). Please ensure these relative paths match the intended project layout and work correctly in the build environment.

x/consensus/go.mod (3)

56-56: Dependency Version Update for cosmos/iavl
The dependency github.com/cosmos/iavl is now updated to version v1.3.5. Please verify that this minor version bump is compatible with all dependent components in the consensus module.


85-85: Dependency Version Update for go-plugin
github.com/hashicorp/go-plugin has been updated to v1.6.3. Confirm that this change does not introduce any incompatibilities in the consensus module’s integration with external plugins.


163-167: Local Replace Directive for Store Module
A new replace directive maps cosmossdk.io/store to the local path ../../store, while the bank and staking modules are similarly remapped. Please double-check that these relative paths accurately reflect the repository’s layout and that all modules build correctly with these changes.

x/evidence/go.mod (2)

59-59: Update for cosmos/iavl Dependency
The github.com/cosmos/iavl dependency is now set to version v1.3.5. Ensure that this updated version is fully compatible with the evidence module’s functionality.


165-167: Confirm Replace Directive for Store Module
The replace directive mapping cosmossdk.io/store to ../../store (along with the mappings for cosmossdk.io/x/bank and cosmossdk.io/x/staking) is consistent with our local development flow. Please verify that these relative paths are correct within the evidence module’s context.

x/accounts/go.mod (2)

64-64: Updated Dependency for cosmos/iavl
The accounts module now uses github.com/cosmos/iavl v1.3.5. This version update should harmonize with changes across the repository; please ensure there are no breaking changes for account-related operations.


171-174: Revised Replace Directives for Local Modules
The added replace directives for cosmossdk.io/store, cosmossdk.io/x/bank, and cosmossdk.io/x/staking now point to local paths (../../store, ../bank, and ../staking, respectively). Double-check these paths to ensure they correctly resolve in the accounts module.

x/protocolpool/go.mod (2)

59-59: Dependency Update for cosmos/iavl in Protocol Pool
The protocol pool now depends on github.com/cosmos/iavl v1.3.5. This update aligns with other modules; please confirm that no protocol pool functionality is adversely impacted by this version change.


165-168: Local Path Mapping for Modules in Protocol Pool
The replace directive remaps cosmossdk.io/store to ../../store along with the corresponding bank and staking modules. Verify that these local paths are correct relative to the protocol pool’s location and that they support smooth local development.

client/v2/go.mod (2)

67-67: Updated Dependency for cosmos/iavl
The client/v2 module now updates github.com/cosmos/iavl to v1.3.5, matching the rest of the codebase. Please check that this update does not affect the client functionality.


170-174: Replace Directives for Client Module
In the client module, the replace directive maps cosmossdk.io/store to ../../store and uses relative paths (./../../x/bank and ./../../x/staking) for the bank and staking modules. These paths differ slightly from other modules due to the client’s directory structure. Please confirm that these paths are correct and that they integrate seamlessly during builds and tests.

go.mod (3)

83-83: Dependency Update: cosmos/iavl version bumped to v1.3.5
The update from v1.3.4 to v1.3.5 ensures consistency with other modules. Please verify that no breaking changes are introduced downstream.


108-108: Dependency Update: hashicorp/go-plugin version bumped to v1.6.3
This change aligns with the updates in other modules. Ensure that any integration relying on this dependency has been tested against the new version.


178-178: New Replace Directive: mapping cosmossdk.io/store to ./store
The local replacement helps with development and testing; please confirm that the relative path is correct for all development environments.

x/bank/go.mod (3)

53-53: Dependency Update: cosmos/iavl version updated to v1.3.5
The update is consistent with repository-wide changes. Please verify that the updated version does not cause integration issues.


77-77: Dependency Update: hashicorp/go-plugin version updated to v1.6.3
This bump ensures the module references remain consistent. Double-check that any consumers of this package have been updated accordingly.


170-173: Replace Directive Adjustments in Module Scope
The new replace directives mapping:
 – cosmossdk.io/store to ../../store
 – cosmossdk.io/x/staking to ../staking
appear correct relative to the module’s directory. Please verify these local paths in your development setup.

x/accounts/defaults/base/go.mod (2)

55-55: Dependency Update: cosmos/iavl version bumped to v1.3.5
This version update is in line with changes across the codebase. Please ensure that any API changes from this dependency are fully compatible with this module.


163-168: Replace Directive: Updating cosmossdk.io/store path
The replacement mapping cosmossdk.io/store => ../../../../store appears to be set for local development. Verify that the relative path reflects the correct directory structure for consumers in this module.

x/mint/go.mod (1)

50-50: Dependency Update: cosmos/iavl version bumped to v1.3.5
The dependency update maintains consistency with other modules. Please confirm that this new version works seamlessly with module functionalities.

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

186-189: Temporary Replace Directive for cosmossdk.io/store
The new replace directive
replace cosmossdk.io/store => ../../../store
is marked as temporary (with a TODO note). Verify that this redirection correctly supports integration with the object store functionality and that there is a plan to remove it once the modules are fully spun out.

x/feegrant/go.mod (2)

68-68: Dependency Update: cosmos/iavl to v1.3.5
The cosmos/iavl dependency has been upgraded to v1.3.5. This change is consistent with the coordinated dependency updates across the repository. Please verify that the new version does not introduce any breaking API changes or incompatibilities.


98-98: Dependency Update: hashicorp/go-plugin to v1.6.3
The hashicorp/go-plugin dependency has been updated to v1.6.3. Ensure that this version update is compatible with existing implementations using this package within the module.

tests/go.mod (2)

105-105: Dependency Update in Tests: cosmos/iavl v1.3.5
The cosmos/iavl version in the tests module has been updated to v1.3.5. This aligns with the changes in the main modules. Please double-check that any tests relying on this dependency continue to function as expected.


138-138: Dependency Update in Tests: hashicorp/go-plugin v1.6.3
The hashicorp/go-plugin dependency is now updated to v1.6.3 in the tests module, mirroring the update in the main modules. Confirm that the updated version integrates well with the testing environment.

x/epochs/go.mod (3)

50-50: Dependency Update: cosmos/iavl to v1.3.5 in Epochs
The cosmos/iavl dependency for the epochs module is updated to v1.3.5. Please ensure that any changes in the library’s behaviour are reflected in the module’s functionality.


78-78: Dependency Update: hashicorp/go-plugin to v1.6.3 in Epochs
The hashicorp/go-plugin dependency is bumped to v1.6.3 here. Verify that the plugin interfaces used in this module continue to work as intended after the upgrade.


160-160: Replace Directive Update: cosmossdk.io/store
The replace directive for cosmossdk.io/store has been updated to point to ../../store. Please confirm that this correctly redirects to the new object store implementation and that the local development workflow remains seamless.

x/distribution/go.mod (2)

60-60: Dependency Update: cosmos/iavl to v1.3.5 in Distribution
The cosmos/iavl dependency is updated to v1.3.5 in the distribution module. Ensure that any API changes in this new version are handled appropriately within the module’s logic.


89-89: Dependency Update: hashicorp/go-plugin to v1.6.3 in Distribution
The hashicorp/go-plugin dependency is now set to v1.6.3. Please verify that this update is compatible with the distribution module’s functionality and does not break any integration points.

simapp/v2/go.mod (1)

306-306: Replace Directive Update: cosmossdk.io/store in simapp/v2
The replace directive for cosmossdk.io/store has been changed to point to ../../store. This update should support the new object store functionality introduced in this PR. Please double-check that the path resolution works correctly during local development and integration tests.

tools/benchmark/go.mod (2)

54-54: Dependency Update for cosmos/iavl
The dependency for github.com/cosmos/iavl has been updated to v1.3.5. This minor version bump appears appropriate; please just ensure it is fully compatible with the rest of the codebase.


152-157: New Replace Directive for Local Store Module
A replace directive was added to map cosmossdk.io/store to a local path (../../store). This supports local development of the store module. Verify that the relative path is correct in the context of your project structure and that the change is consistently reflected in all modules.

x/gov/go.mod (2)

57-59: Updated Dependency Versions
The module now uses github.com/cosmos/iavl v1.3.5 and github.com/hashicorp/go-plugin v1.6.3 (as seen in the dependency block). These updates are in line with the coordinated dependency refresh. Please double-check that all breaking changes (if any) are addressed downstream.


33-35: New Replace Directive Verification
According to the PR summary, a new replace directive mapping cosmossdk.io/store is expected in this module as well. Ensure that this directive (e.g. cosmossdk.io/store => ../../store) is present and correctly positioned, aligning with changes in other modules.

x/group/go.mod (2)

64-64: Dependency Update for cosmos/iavl
The version of github.com/cosmos/iavl has been updated to v1.3.5. This change aligns with similar updates elsewhere; please confirm that this upgrade does not affect any dependent code.


170-176: Local Replace Directive for Store Module
A replace block now maps cosmossdk.io/store to ../../store (along with several other local mappings). This should streamline local development. Verify that all relative paths (including those for bank, gov, and staking) are correct and that no unintended consequences occur due to these changes.

x/slashing/go.mod (2)

61-61: Updated Dependency for cosmos/iavl
The dependency github.com/cosmos/iavl has been upgraded to v1.3.5. Please ensure that this update does not break compatibility with any slashing-specific logic.


163-171: Verify Replace Block for Module Dependencies
The replace block now includes a mapping for cosmossdk.io/store to ../../store, along with local replacements for other modules. Confirm that these changes harmonize with the overall dependency management strategy across the repository.

x/upgrade/go.mod (2)

75-75: Dependency Update for cosmos/iavl in Upgrade Module
The dependency github.com/cosmos/iavl is now at v1.3.5 in this module as well. This update is consistent with the other modules; please verify that any functionality relying on iavl continues to operate as expected.


201-207: New Replace Directive for Store Module in Upgrade Module
A new replace directive mapping cosmossdk.io/store to ../../store has been added in this module’s replace block. Ensure that the relative paths for all locally replaced modules (client/v2, bank, gov, staking) are correct and that the migration to the new object store approach is smooth.

x/staking/go.mod (2)

62-62: Dependency Update: Cosmos IAVL Version Bump
The version for github.com/cosmos/iavl has been updated to v1.3.5 as intended. Please ensure compatibility with upstream changes and that the integration tests cover any potential breaking changes from this bump.


91-91: Dependency Update: HashiCorp Go-Plugin Version Upgrade
The update of github.com/hashicorp/go-plugin to version v1.6.3 appears to be in line with the coordinated dependency updates. Please verify that the new version maintains the expected behavior and does not introduce regressions in components that rely on this plugin.

store/listenkv/store.go (2)

6-6: LGTM: Import added to support the new implementation.

The cachekv package import has been correctly added to support the updated implementation of the CacheWrap method.


139-143:

✅ Verification successful

Consider updating CacheWrapWithTrace for consistency

While the CacheWrap method has been updated to return a cache-wrapped store instead of panicking, the CacheWrapWithTrace method still panics. This creates an inconsistency in behavior between these two closely related methods.

Consider updating the CacheWrapWithTrace method to return a cache-wrapped store with trace support, similar to how CacheWrap has been updated:

func (s *Store) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.CacheWrap {
-	panic("cannot CacheWrapWithTrace a ListenKVStore")
+	return cachekv.NewStore(s).CacheWrapWithTrace(w, tc)
}

🏁 Script executed:

#!/bin/bash
# Check if cachekv.Store implements CacheWrapWithTrace correctly

# Look for the CacheWrapWithTrace method implementation in cachekv store
echo "Checking if cachekv.Store implements CacheWrapWithTrace..."
grep -A 10 "func .* CacheWrapWithTrace" store/cachekv/store.go

Length of output: 517


Update CacheWrapWithTrace for Consistency

The current implementation of CacheWrapWithTrace in store/listenkv/store.go panics, which is inconsistent with the updated cache wrapping behavior observed in cachekv.Store. The verification confirms that cachekv.Store implements the method as follows:

func (store *GStore[V]) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.CacheWrap {
	if store, ok := any(store).(*GStore[[]byte]); ok {
		return NewStore(tracekv.NewStore(store, w, tc))
	}
	return store.CacheWrap()
}

To align the behavior between these related methods, update the CacheWrapWithTrace in ListenKVStore to return a cache-wrapped store with trace support:

func (s *Store) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.CacheWrap {
-    panic("cannot CacheWrapWithTrace a ListenKVStore")
+    return cachekv.NewStore(s).CacheWrapWithTrace(w, tc)
}
CHANGELOG.md (1)

1-3161: Well-maintained and comprehensive changelog

The CHANGELOG.md is comprehensive and well-organized, following a consistent structure throughout. Each version is properly documented with categorized changes (Features, Improvements, Bug Fixes, etc.) and appropriate PR links.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

91-91: Unordered list indentation
Expected: 4; Actual: 2

(MD007, ul-indent)


92-92: Unordered list indentation
Expected: 4; Actual: 2

(MD007, ul-indent)


93-93: Unordered list indentation
Expected: 4; Actual: 2

(MD007, ul-indent)


364-364: Multiple headings with the same content
null

(MD024, no-duplicate-heading)


374-374: Multiple headings with the same content
null

(MD024, no-duplicate-heading)


416-416: Multiple headings with the same content
null

(MD024, no-duplicate-heading)


883-883: Multiple headings with the same content
null

(MD024, no-duplicate-heading)


1333-1333: Multiple headings with the same content
null

(MD024, no-duplicate-heading)


2123-2123: Multiple headings with the same content
null

(MD024, no-duplicate-heading)

store/internal/btree/btree_test.go (2)

1-1: Package name updated to match directory structure

The package name change from internal to btree correctly aligns with the directory structure, making imports more intuitive.


12-12: Generic type parameter specified for NewBTree

The BTree implementation has been updated to use Go generics, and the test code now explicitly provides the value type as []byte. This is a good improvement for type safety and clarity.

Also applies to: 43-43, 174-174

store/internal/btreeadaptor.go (1)

11-23: New BTreeStore implementation with generics

The BTreeStore implementation is well-structured and properly uses Go generics to provide type safety. The implementation pattern follows Go conventions and the constructor function is clean and idiomatic.

store/rootmulti/store_test.go (7)

659-659: Casting to pauseableCommitKVStoreStub seems appropriate.
This explicit cast is acceptable in test code, but please ensure the original store.stores[testStoreKey1] is always a CommitKVStore to avoid possible panic.


905-915: Utility function for hashing store commits looks good.
The approach of aggregating store commit IDs and hashing them is sound for generating a combined hash. No concerns.


960-961: commitStoreStub declaration is clear.
This stub extends CommitStore for testing, which is a coherent approach for tracking commits. No issues found.


965-966: Overriding Commit() to track commit calls is valid.
This wrapper increments the counter and delegates to the embedded store, which is appropriate for testing.


971-977: prepareStoreMap function is straightforward.
Mounting additional store keys (including object store keys) is cleanly done and should not introduce issues.


981-992: Constructing the stub map for multiple keys is correct.
Mapping each test key to its corresponding commitStoreStub is clear. Double-check type assertions at runtime to prevent panics in other contexts beyond testing.


1023-1023: Accessing the commitStoreStub from the map.
This cast is fine for test code. No further issues.

store/internal/btree/memiterator.go (13)

1-1: Renaming package to btree is consistent with the new module layout.
No issues noted.


12-12: Interface assertion for memIterator[[]byte] implements types.Iterator.
Ensures correctness at compile time. Good practice.


17-18: Generic memIterator[V any] definition looks clean.
Storing the internal IterG[item[V]] is a correct approach for typed iteration.


26-30: Generic constructor newMemIterator

  • Properly handles ascending/descending logic.
  • Uses a placeholder empty V for Seek.
  • Checks boundary conditions for start/end keys.
    This is well-organized.

Also applies to: 34-34, 40-40


67-69: Domain() correctly returns iterator boundaries.
Aligns with the required Iterator interface.


71-74: Close() releases the internal iterator.
Straightforward resource cleanup.


76-81: Error() method signals invalid iterator state.
Complies with the interface definition.


83-85: Valid() method check is correct.
No issues; preserves the standard iteration contract.


87-99: Next() advances the iterator.
Handles ascending/descending. The keyInRange check ensures correct iteration edge handling.


101-109: keyInRange relevancy check is well-implemented.
Properly checks boundaries for both ascending and descending iterations.


111-113: Key() returns underlying item key.
Safely accesses the current item.


115-117: Value() now generic.
Returns the typed value, leveraging the item[V].value field.


119-123: assertValid() panics on iterator misuse.
Appropriate for internal usage in this implementation.

store/internal/btree/btree.go (11)

1-1: Renaming package to btree for consistency.
No concerns.


25-27: Generic BTree[V any] struct
Decouples value type from implementation, aligning with the new generics approach.


30-37: NewBTree[V any]() constructor
Creates the internal btree.BTreeG with sensible options. No issues noted.


39-49: Set and Get methods

  • Set properly inserts or updates keyed items.
  • Get returns the type-safe V and a default if not found.
    Implementation is straightforward.

52-55: Delete method
Removes the matching key using a placeholder default value for lookups. Correct approach.


57-69: Iterator and ReverseIterator
Both handle empty key checks and return a generic iterator. No issues noted.


73-77: Copy() method
Returns a shadow copy from the underlying B-tree. Good for copy-on-write semantics.


79-81: Clear() method
Invokes tree.Clear(). Straightforward design.


84-87: Generic item[V any] struct
Holds both key and typed value. Maintains clarity in usage.


90-92: byKeys comparator
Uses byte comparison for ordering. Matches the B-tree’s expected comparator signature.


95-97: newItem constructor
Consistent with the typed item approach.

store/CHANGELOG.md (1)

34-36: LGTM! Clear and properly formatted changelog entry.

The changelog entry follows the guidelines, is properly formatted, and accurately summarizes the new object store feature.

runtime/module.go (1)

102-102: LGTM! Well integrated into the init function.

The addition of ProvideObjectStoreKey in the init function is properly placed with other similar providers.

store/internal/btree/memiterator_test.go (1)

8-8: LGTM! Proper use of generics.

The changes to use NewBTree[[]byte]() instead of NewBTree() properly adapt the tests to the new generic implementation. Using generics improves type safety while maintaining the same test functionality.

Also applies to: 35-35, 63-63

store/types/validity.go (3)

33-39: Good use of generics for enhanced type safety

The new AssertValidValueGeneric function elegantly extends value validation to arbitrary types using Go generics. This approach is more type-safe than using raw byte slices and allows for custom validation logic through the callback functions.

🧰 Tools
🪛 GitHub Check: CodeQL

[warning] 36-36: Panic in BeginBock or EndBlock consensus methods
Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt


41-45: Improved error handling with errors.New

Good refactoring to centralize the length validation in a separate function and use errors.New for the panic message. This improves code organization and provides better error context.


36-36:

❓ Verification inconclusive

Handle potential panic in consensus-critical code paths

This line could potentially cause a chain halt if called during BeginBlock or EndBlock consensus methods.

Consider adding a recovery mechanism if this validation is used in consensus-critical paths, or ensure it's only called in safe contexts. You can verify where this function is called with:


🏁 Script executed:

#!/bin/bash
# Check if AssertValidValueGeneric is called in BeginBlock or EndBlock methods
rg "BeginBlock|EndBlock" -A 10 -B 10 | rg "AssertValidValueGeneric"

# Also check for indirect calls through interfaces that might lead to this function
rg -A 3 "func.*BeginBlock|func.*EndBlock" | rg -A 10 "AssertValid|panic"

Length of output: 3652


Attention: Consensus-Critical Panic Handling

While the search results did not reveal any direct or indirect calls to AssertValidValueGeneric in consensus-critical methods (such as BeginBlock or EndBlock), please remain cautious. Ensure that this panic is never triggered in a context that could halt the chain—if there's any possibility it might be invoked in consensus-critical paths, consider either:

  • Adding a recovery mechanism or a safe wrapper around this validation, or
  • Explicitly documenting that this function is only used in non-critical code paths.

This precaution will help prevent any inadvertent chain halts in production.

🧰 Tools
🪛 GitHub Check: CodeQL

[warning] 36-36: Panic in BeginBock or EndBlock consensus methods
Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt

baseapp/baseapp.go (2)

305-307: Good addition of ObjectStoreKey support

The addition of ObjectStoreKey handling in MountStores follows the existing pattern for other store types, maintaining consistency in the codebase.


346-354: Well-implemented MountObjectStores method

The implementation follows the established pattern of other Mount* methods, ensuring consistent behavior. Using slices.Sorted with maps.Keys for deterministic iteration is a good practice.

runtime/store.go (2)

166-172: Updated Iterator return type for consistency

The change from store.Iterator to storetypes.Iterator aligns with the broader object store implementation, ensuring proper interface compatibility across the codebase.


174-180: Updated ReverseIterator return type for consistency

Similarly to the Iterator method, updating ReverseIterator to return storetypes.Iterator ensures consistency with the new object store interfaces.

store/cachekv/search_benchmark_test.go (1)

25-43: Good adaptation of benchmarks to use generic types

The changes properly update the test to work with the new generic GStore[[]byte] and cValue[[]byte] types. This ensures test coverage of the refactored code with Go generics.

One minor suggestion - consider parameterizing the type in a variable at the top of the function for easier maintenance:

func generateStore() *Store {
+   type storeValueType = []byte
-   cache := map[string]*cValue[[]byte]{}
+   cache := map[string]*cValue[storeValueType]{}
    // ... rest of function
-   return &GStore[[]byte]{
+   return &GStore[storeValueType]{
store/cachemulti/store.go (6)

25-25: Adopting a more general cache interface is beneficial.

Replacing db's type to types.CacheWrap nicely broadens compatibility for various cache store wrappers.


39-43: Flexible function signature update.

Changing from a more specific types.KVStore to a types.CacheWrapper parameter better accommodates different store implementations (e.g., object stores).


50-61: Conditional trace wrapping logic looks good.

The code safely checks for an underlying KVStore before wrapping with tracekv. This aligns with the comment “only support tracing on KVStore.”


164-170: Helper method enhances readability.

Encapsulating store retrieval in getCacheWrap clarifies the logic. The panic handling is consistent with the SDK's pattern.


172-179: Coherent addition of typed getter.

GetKVStore uses a type assertion to retrieve a KVStore. Panicking on mismatch is consistent with the codebase’s approach.

🧰 Tools
🪛 GitHub Check: CodeQL

[warning] 177-177: Panic in BeginBock or EndBlock consensus methods
Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt


181-187: New method for ObjKVStore retrieval.

Introducing GetObjKVStore matches the pattern of typed store access. Same panic pattern on mismatch, so it remains consistent.

store/rootmulti/store.go (5)

69-79: Shifting to a more generalized CommitStore map.

These fields (stores as map[types.StoreKey]types.CommitStore, etc.) establish a generalized approach for commit-capable stores, facilitating object store integration.


177-186: Type assertion ensures CommitKVStore usage.

This newly introduced GetCommitKVStore method panics if the store is not a CommitKVStore. It follows the current SDK style but could lead to chain halts if invoked incorrectly in consensus paths.


695-698: Potential chain halt due to panic on mismatch.

If the store is not a KVStore, the code panics, matching the typical approach but possibly causing a halt in consensus if triggered during BeginBlock/EndBlock.

🧰 Tools
🪛 GitHub Check: CodeQL

[warning] 697-697: Panic in BeginBock or EndBlock consensus methods
Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt


710-722: ObjKVStore retrieval method.

Similar to other typed store getters, this method panics if the store isn't an ObjKVStore. The approach is consistent with the rest of the SDK’s store design.


890-893: Skipping snapshot for non-persistent store variants.

Adding *transient.ObjStore to the case statement ensures object stores are not snapshotted, which aligns with transient/memory store handling.

store/transient/store.go (14)

4-5: Imports for internal B-tree usage.

Bringing in internal/btree is essential for the new generic store approach.


13-15: Ensuring interfaces are satisfied.

Declaring these interface checks for ObjStore demonstrates the new type’s alignment with Committer and ObjKVStore.


19-21: Generic store definition.

Wrapping BTreeStore[V] in GStore[V] introduces a flexible design for transient data of any type.


23-26: Parameterizing GStore creation.

Allowing custom isZero and valueLen functions promotes reusability and robust store logic for different data types.


28-30: Conceptual specialization for byte slices.

Store reuses the same generic logic specialized for raw bytes, maintaining consistency with existing patterns.


34-38: Builder function for byte-based GStore.

Initializes an ephemeral store that treats nil as zero. This is consistent with typical usage patterns.


40-42: Identifying the store type for clarity.

Returning StoreTypeTransient is correct for an ephemeral store.


44-55: Generic object store approach introduced.

ObjStore extends the same design to handle any typed values, broadening usage scenarios.


56-58: Returning object store type.

Declaring StoreTypeObject aligns with the new store classification, enhancing clarity in the multi-store.


62-68: Transient commit logic.

Commit() clears the store, reflecting the transient nature. This approach is valid for ephemeral data.


72-72: No-op pruning retrieval.

Transient stores do not persist or prune data, so returning undefined pruning options is reasonable.


76-76: Empty commit ID is appropriate.

Since transient data is never persisted, returning an empty CommitID is consistent.


80-80: Version always zero.

Ephemeral stores do not retain historical versions, so the returned 0 is accurate.


85-85: No hashing needed.

Returning an empty byte slice reflects the fact that nothing is persisted to hash in a transient store.

store/types/store.go (8)

141-141: Add usage verification for new method
The new GetObjKVStore(StoreKey) ObjKVStore method aligns well with existing specialized getters (e.g., GetKVStore). Please ensure all call-sites are updated accordingly to avoid runtime panics or missed integrations.


238-253: Introduction of generic basic KV store
The GBasicKVStore[V any] interface elegantly extends key-value operations to arbitrary generic types. The design is consistent with the new generics-based approach and looks solid.


254-272: Generic KV store interface
The GKVStore[V any] interface effectively layers iteration capabilities on top of GBasicKVStore[V]. No issues found; it appears to follow established store interface patterns.


274-301: Generic iterator interface
The GIterator[V any] interface for typed iteration looks consistent with the existing iteration pattern. This change should make the code more flexible while retaining familiarity for developers.


373-374: Added StoreTypeObject
Adding StoreTypeObject is a logical extension to the existing set of store types. Make sure all code paths handle this new type to prevent unexpected panics or mismatches.


399-400: String representation for StoreTypeObject
The string resolution for StoreTypeObject neatly matches the existing pattern for store types.


480-501: ObjectStoreKey implementation
The ObjectStoreKey struct and its constructor follow the same pattern used by other store key types such as KVStoreKey and TransientStoreKey. No issues found.


601-613: New factory function for multiple ObjectStoreKeys
NewObjectStoreKeys parallels other functions like NewKVStoreKeys or NewTransientStoreKeys and should ease the creation of object store keys in bulk.

store/prefix/store.go (23)

13-16: Introduced aliased store types
Defining Store = GStore[[]byte] and ObjStore = GStore[any] provides a convenient shorthand for byte-based and object-based prefix stores, respectively.


18-21: Interface compliance assertions
Asserting Store implements types.KVStore and ObjStore implements types.ObjKVStore is a good practice to guarantee interface conformance at compile time.


23-29: NewStore constructor
Creating a prefix store for byte slices via NewStore and passing in custom isZero/valueLen closures ensures robust handling of nil checks and length computations.


31-37: NewObjStore constructor
NewObjStore cleanly abstracts object-based storage in a prefix, reusing the same pattern as NewStore. This should streamline usage of object-based KV operations.


39-48: Generic prefix store struct
GStore[V any] extends a parent types.GKVStore[V] with an additional prefix mechanism and injection points for zero checks and value-length calculations. This is a flexible and modular approach.


70-70: Key prefixing logic
The key(key []byte) helper properly appends the prefix to user-supplied keys. This is essential for scoping data within the parent store.


83-86: CacheWrap integration
Wrapping with cachekv.NewGStore ensures that prefix-based operations inherit proper caching behavior. Implementation and usage appear straightforward.


88-93: Conditional CacheWrapWithTrace
The type assertion to handle tracing for GStore[[]byte] is a nice optimization that avoids unnecessary reflection for typed scenarios.


96-101: Get method for generic store
The Get method straightforwardly obtains the value from the parent store using the prefixed key, maintaining minimal overhead.


102-105: Has method
Using s.key(key) ensures prefix isolation. No concerns regarding correctness or performance in this short method.


107-112: Set method with validation
types.AssertValidKey(key) and types.AssertValidValueGeneric(value, ...) enforce data integrity. This is a welcome improvement over blindly storing arbitrary data.


115-117: Delete method
The Delete implementation is straightforward and consistent with the rest of the prefix store logic.


121-134: Iterator method
Appending the prefix to the start and computing an appropriate end boundary is well aligned with prefix store semantics. Returning newPrefixIterator is consistent with the design.


138-151: ReverseIterator method
Mirrors the forward iterator logic for reversed iteration. Properly increments the prefix if end is nil, ensuring correct iteration domain.


153-153: Interface assertion
Affirming that (*prefixIterator[[]byte])(nil) implements types.Iterator helps catch potential interface mismatch at compile time.


155-161: prefixIterator struct
Encapsulates iterator state, including the parent iterator. Using a valid flag to track validity is a clean approach.


163-171: newPrefixIterator factory
Nicely sets up the prefixIterator by verifying the parent's key has the correct prefix on initialization.


173-176: Domain method
Returns the original start and end range unmodified, ensuring partial prefix iteration semantics remain transparent to the caller.


179-181: Valid method
Combines the local valid flag with the parent iterator's Valid() method to maintain consistent state.


196-205: Key method
Strips the prefix from the parent iterator's key, which aligns with the logic behind prefixIterator. No concerns.


208-214: Value method
Simply returns the parent's value. This is consistent with the prefix store pattern where only the key is prefixed.


217-219: Close method
Delegates resource cleanup to the parent iterator. Straightforward and standard.


223-229: Error method
Returns an error if the iterator is invalid. The direct parent delegation is a simple, clean approach.

store/gaskv/store.go (21)

14-14: Aliased Store type
Store = GStore[[]byte] matches the approach in other store packages, simplifying gas-tracked key/value operations for raw byte slices.


16-21: NewStore constructor
NewStore constructs a gas-tracked store for byte-based values. The closures supplied for isZero and valueLen properly handle nil checks and length calculation.


23-23: Aliased ObjStore type
ObjStore = GStore[any] extends gas tracking to arbitrary typed objects. This is a consistent extension of the generic store concept.


25-30: NewObjStore constructor
Similar to NewStore but specialized for any-typed values with a fixed ObjectValueLength cost. This is a straightforward solution for object-based gas accounting.


32-41: Generic GStore struct
Adds gasMeter, gasConfig, and function pointers isZero/valueLen to the parent store. This neatly centralizes gas logic in one layer.


43-50: NewGStore function
Constructs a GStore[V] with the provided gas meter and config. This design allows flexible injection of gas accounting logic.


62-64: GetStoreType
Defers to the underlying parent store. The implementation is minimal but necessary to satisfy the Store interface.


67-73: Get method with gas consumption
Reading keys and values incurs both flat and per-byte gas costs. This ensures usage-based billing and discourages large unbounded keys/values.


79-86: Set method with validation and gas consumption
Appropriately charges a flat write cost plus a cost proportional to key and value size. The call to types.AssertValidValueGeneric enforces data correctness.


102-107: Iterator method
Wraps the parent iterator with gas accounting that charges for iteration steps. Implementation is consistent with prior singledirectional iteration design.


109-115: ReverseIterator method
As with Iterator, but reversed. The structure fosters consistency in how gas is charged for both ascending and descending access.


117-125: CacheWrap and CacheWrapWithTrace
Gas-tracked stores do not support caching or tracing wraps directly here, preventing nested layering complexities. This matches the typical design in GasKVStore.


127-139: Shared iterator creation
gs.iterator(start, end, ascending) centralizes logic for both forward and reverse iterators, returning a gas-aware iterator instance.


141-146: gasIterator struct
Wraps a parent generic iterator to inject gas consumption calls. This is a clean approach to layering in incremental usage-based fees.


148-155: newGasIterator constructor
Solid constructor that sets references and then returns a gasIterator[V]. Straightforward.


163-165: Valid method
Delegates validity checks to the parent iterator. Correct approach to ensure consistent behavior.


170-173: Next method
Calls consumeSeekGas() before advancing the parent iterator. This design enforces usage-based fees for each iteration step.


184-186: Value method
Returns the parent's typed value. The direct pass-through ensures no overhead beyond normal iteration costs.


189-191: Close method
Safe delegation to the underlying iterator's Close. No code smell here.


194-196: Error method
Again, simply delegates to the parent. This is a consistent pattern.


200-207: consumeSeekGas method
Appropriately charges for key length and value length, then applies a flat cost per iteration step. This ensures fair gas accounting.

store/cachekv/store.go (10)

12-12: No issues with the new import.


20-23: Good use of generics for cValue[V].
This design properly stores any type V and flags when data is dirtied.


25-27: kvPair[V] structure looks fine.
Clear key-value pairing using generics.


30-30: Type alias Store = GStore[[]byte] appears consistent.
This eases migration from the old byte-based store while still adopting generics.


35-40: Bridging to NewGStore is well-structured.
Good job passing lambdas for zero-check and value length for []byte.


42-56: GStore[V] declaration looks solid.
Introducing a sync.Mutex, typed caches, and an isZero func is an effective approach. Just ensure locking remains consistent for all read/write paths.


58-68: NewGStore constructor is well-implemented.
Nice initialization of fields, consistent with the store's design.


75-76: Generically typed Get method is correct.
It properly locks before retrieving and caches as needed.


94-96: Validation using AssertValidValueGeneric.
Ensures type-based checks and disallows zero values if required.


110-116: Deletion mechanism.
Using the “zero value” as a tombstone is consistent with your approach.

store/cachekv/internal/mergeiterator.go (10)

17-19: Introducing cacheMergeIterator[V] with isZero.
This generic approach is consistent with the rest of the refactor; using isZero to detect deletions is clean.

Also applies to: 24-24


27-27: Enforcing interface compliance with (*cacheMergeIterator[[]byte])(nil).
Good practice to ensure at compile time that the iterator satisfies types.Iterator.


29-30: NewCacheMergeIterator: constructor approach is clear.
Pass-through of isZero ensures consistent logic when merging cache and parent iterators.


139-139: Close() with error handling.
Properly closes both iterators and returns any errors found.


151-151: Error() method.
Straightforward approach to reflect invalid iterator state.


160-162: assertValid() defers to Error().
This pattern is consistent and ensures a single source of truth for validity checks.


168-169: compare(a, b []byte) respects ascending vs. descending.
Negating the result for descending is a common solution.


182-183: skipCacheDeletes leverages isZero.
Good clarity: it repeatedly skips deleted items from the cache portion.


193-193: skipUntilExistsOrInvalid
Effectively fast-forwards until a non-deleted key is found or both iterators are exhausted.


217-218: Deletion check with isZero(valueC).
This is the right condition to discard cache entries representing tombstone values.

Also applies to: 229-229

Comment on lines 273 to 276
func TestListenKVStoreCacheWrap(t *testing.T) {
store := newEmptyListenKVStore(nil)
require.Panics(t, func() { store.CacheWrap() })
store.CacheWrap()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Test needs assertions to verify the new behavior

The test has been updated to align with the changed implementation in store.go, where CacheWrap() no longer panics. However, this test is now not very useful as it doesn't verify the actual behavior of the method - it merely checks that it doesn't panic.

Consider enhancing this test to verify that the returned object is of the expected type and behavior:

func TestListenKVStoreCacheWrap(t *testing.T) {
	store := newEmptyListenKVStore(nil)
-	store.CacheWrap()
+	cacheStore := store.CacheWrap()
+	require.NotNil(t, cacheStore, "CacheWrap should return a non-nil store")
+	require.IsType(t, &cachekv.Store{}, cacheStore, "CacheWrap should return a cachekv.Store")
+	
+	// Basic functionality test to ensure it works as expected
+	key, value := []byte("test-key"), []byte("test-value")
+	cacheStore.Set(key, value)
+	require.Equal(t, value, cacheStore.Get(key))
+	
+	// Original store should not be affected until Write is called
+	require.Nil(t, store.Get(key))
}
📝 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 TestListenKVStoreCacheWrap(t *testing.T) {
store := newEmptyListenKVStore(nil)
require.Panics(t, func() { store.CacheWrap() })
store.CacheWrap()
}
func TestListenKVStoreCacheWrap(t *testing.T) {
store := newEmptyListenKVStore(nil)
cacheStore := store.CacheWrap()
require.NotNil(t, cacheStore, "CacheWrap should return a non-nil store")
require.IsType(t, &cachekv.Store{}, cacheStore, "CacheWrap should return a cachekv.Store")
// Basic functionality test to ensure it works as expected
key, value := []byte("test-key"), []byte("test-value")
cacheStore.Set(key, value)
require.Equal(t, value, cacheStore.Get(key))
// Original store should not be affected until Write is called
require.Nil(t, store.Get(key))
}

Comment on lines +56 to +59
// CacheWrapWithTrace branches the underlying store.
func (ts *BTreeStore[V]) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.CacheWrap {
return cachekv.NewGStore(ts, ts.isZero, ts.valueLen)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

CacheWrapWithTrace ignores trace parameters

The CacheWrapWithTrace method doesn't use the provided writer and trace context parameters, making it functionally identical to CacheWrap. This seems inconsistent with the method's purpose.

// CacheWrapWithTrace branches the underlying store.
func (ts *BTreeStore[V]) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.CacheWrap {
-	return cachekv.NewGStore(ts, ts.isZero, ts.valueLen)
+	// Use the writer and trace context to create a trace-enabled cache wrapper
+	return cachekv.NewGStore(tracekv.NewStore(ts, w, tc), ts.isZero, ts.valueLen)
}

Note: The implementation requires verification since it depends on how tracekv.NewStore works with generic stores. The actual implementation may need adjustment.

📝 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
// CacheWrapWithTrace branches the underlying store.
func (ts *BTreeStore[V]) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.CacheWrap {
return cachekv.NewGStore(ts, ts.isZero, ts.valueLen)
}
// CacheWrapWithTrace branches the underlying store.
func (ts *BTreeStore[V]) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.CacheWrap {
// Use the writer and trace context to create a trace-enabled cache wrapper
return cachekv.NewGStore(tracekv.NewStore(ts, w, tc), ts.isZero, ts.valueLen)
}

@aljo242 aljo242 added the v54 label Mar 26, 2025
@aljo242
Copy link
Contributor

aljo242 commented Mar 26, 2025

could you target this against release/v0.53.x?

@mmsqe mmsqe mentioned this pull request Mar 28, 2025
12 tasks
@mmsqe mmsqe closed this Apr 9, 2025
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.

2 participants