| .. | ||
| commitment | ||
| db | ||
| errors | ||
| internal | ||
| metrics | ||
| migration | ||
| proof | ||
| pruning | ||
| root | ||
| snapshots | ||
| storage | ||
| batch.go | ||
| CHANGELOG.md | ||
| database.go | ||
| go.mod | ||
| go.sum | ||
| options.go | ||
| README.md | ||
| sonar-project.properties | ||
| store.go | ||
| trace.go | ||
| validation.go | ||
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
Prune store keys 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
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.
Test Coverage
The test coverage of the following logical components should be over 60%: