cosmos-sdk/store/v2
dependabot[bot] 1f332e1e0b
build(deps): Bump google.golang.org/protobuf from 1.34.2 to 1.35.1 (#22164)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <dependabot[bot]@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
2024-10-08 08:31:22 +00:00
..
commitment docs(store/v2): Add missing documents (#22118) 2024-10-04 08:11:15 +00:00
db docs: fix function comments (#21555) 2024-09-05 09:40:21 +00:00
errors chore: upstream runtime/v2 (#20320) 2024-05-14 12:43:28 +00:00
internal refactor: using unsafe.String and unsafe.SliceData (#21412) 2024-09-04 15:10:47 +00:00
metrics chore: bring back store v1 to main (#20263) 2024-05-03 12:21:16 +00:00
migration docs(store/v2): Add missing documents (#22118) 2024-10-04 08:11:15 +00:00
mock test(store/v2): add the root store unit test (#21208) 2024-08-09 15:11:05 +00:00
proof feat(store/v2): implement the feature to upgrade the store keys (#20453) 2024-08-05 12:34:36 +00:00
pruning chore(store/v2): Increase storev2 tests coverage (#21094) 2024-08-09 16:10:30 +00:00
root chore: remove consensus authority (#21734) 2024-09-16 20:06:21 +00:00
snapshots test(server/v2): Add system-test for store's command (#21357) 2024-09-23 14:49:07 +00:00
storage docs(store/v2): Add missing documents (#22118) 2024-10-04 08:11:15 +00:00
batch.go chore: cleanup store/v2 interface (#20280) 2024-05-13 11:14:01 +00:00
CHANGELOG.md chore: bring back store v1 to main (#20263) 2024-05-03 12:21:16 +00:00
database.go feat(store/v2): implement the feature to upgrade the store keys (#20453) 2024-08-05 12:34:36 +00:00
go.mod build(deps): Bump google.golang.org/protobuf from 1.34.2 to 1.35.1 (#22164) 2024-10-08 08:31:22 +00:00
go.sum build(deps): Bump google.golang.org/protobuf from 1.34.2 to 1.35.1 (#22164) 2024-10-08 08:31:22 +00:00
options.go feat(server/v2) Add prune cmd to serverv2 (#20736) 2024-07-23 16:48:54 +00:00
README.md docs(store/v2): Add missing documents (#22118) 2024-10-04 08:11:15 +00:00
sonar-project.properties build(deps): Bump cosmossdk.io/core from 1.0.0-alpha.2 to 1.0.0-alpha.3 (#21810) 2024-09-19 07:52:56 +00:00
store.go feat(store/v2): implement the feature to upgrade the store keys (#20453) 2024-08-05 12:34:36 +00:00
trace.go chore: bring back store v1 to main (#20263) 2024-05-03 12:21:16 +00:00
validation.go chore(docs): fix comments that do not start with the name of the exported element (#20999) 2024-07-19 16:21:01 +00:00

Store

The store package contains the implementation of store/v2, which is the SDK's abstraction around managing historical and committed state. See ADR-065 and Store v2 Design for a high-level overview of the design and rationale.

Usage

The store package contains a root.Store type which is intended to act as an abstraction layer around it's two primary constituent components - state storage (SS) and state commitment (SC). It acts as the main entry point into storage for an application to use in server/v2. Through root.Store, an application can query and iterate over both current and historical data, commit new state, perform state sync, and fetch commitment proofs.

A root.Store is intended to be initialized with already constructed SS and SC backends (see relevant package documentation for instantiation details). Note, from the perspective of root.Store, there is no notion of multi or single tree/store, rather these are implementation details of SS and SC. For SS, we utilize store keys to namespace raw key/value pairs. For SC, we utilize an abstraction, commitment.CommitStore, to map store keys to a commitment trees.

Upgrades

The LoadVersionAndUpgrade API of the root.store allows for adding or removing store keys. This is useful for upgrading the chain with new modules or removing old ones. The Rename feature is not supported in store/v2.

sequenceDiagram
    participant S as Store
    participant SS as StateStorage
    participant SC as StateCommitment
    alt SC is a UpgradeableStore
        S->>SC: LoadVersionAndUpgrade
        SC->>SC: Mount new store keys
        SC->>SC: Prune removed store keys
    end
    SC->>S: LoadVersion Result
    alt SS is a UpgradableDatabase
        S->>SS: PruneStoreKeys
    end

PruneStoreKeys does not remove the data from the SC and SS instantly. It only marks the store keys as pruned. The actual data removal is done by the pruning process of the underlying SS and SC.

Migration

The migration from store/v1 to store/v2 is supported by the MigrationManager in the migration package. See Migration Manager for more details.

Pruning

The root.Store is NOT responsible for pruning. Rather, pruning is the responsibility of the underlying SS and SC layers. This means pruning can be implementation specific, such as being synchronous or asynchronous. See Pruning Manager for more details.

State Sync

The root.Store is NOT responsible for state sync. See Snapshots Manager for more details.

Test Coverage

The test coverage of the following logical components should be over 60%: