-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(docs): update store v2 adr (#22794)
(cherry picked from commit f995d0a) # Conflicts: # store/v2/README.md # store/v2/pruning/README.md
- Loading branch information
1 parent
96c4e7a
commit 4984e28
Showing
3 changed files
with
112 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# 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](../../docs/architecture/adr-065-store-v2.md) | ||
and [Store v2 Design](https://docs.google.com/document/d/1l6uXIjTPHOOWM5N4sUUmUfCZvePoa5SNfIEtmgvgQSU/edit#heading=h.nz8dqy6wa4g1) 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 primary constituent components - 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 SC. 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. | ||
|
||
```mermaid | ||
sequenceDiagram | ||
participant S as Store | ||
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 | ||
``` | ||
|
||
`PruneStoreKeys` does not remove the data from the SC instantly. It only | ||
marks the store keys as pruned. The actual data removal is done by the pruning | ||
process of the underlying SC. | ||
|
||
## Migration | ||
|
||
The migration from store/v1 to store/v2 is supported by the `MigrationManager` in | ||
the `migration` package. See [Migration Manager](./migration/README.md) for more details. | ||
|
||
## Pruning | ||
|
||
The `root.Store` is NOT responsible for pruning. Rather, pruning is the responsibility | ||
of the underlying commitment layer. This means pruning can be implementation specific, | ||
such as being synchronous or asynchronous. See [Pruning Manager](./pruning/README.md) for more details. | ||
|
||
|
||
## State Sync | ||
|
||
The `root.Store` is NOT responsible for state sync. See [Snapshots Manager](./snapshots/README.md) | ||
for more details. | ||
|
||
## Test Coverage | ||
|
||
The test coverage of the following logical components should be over 60%: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Pruning Manager | ||
|
||
The `pruning` package defines the `PruningManager` struct which is responsible for | ||
pruning the state commitment (SC) based on the current height of the chain. The `PruningOption` struct defines the configuration for pruning and is passed to the `PruningManager` during initialization. | ||
|
||
## Prune Options | ||
|
||
The `PruningOption` struct includes the following fields: | ||
|
||
* `KeepRecent` (uint64): The number of recent heights to keep in the state. | ||
* `Interval` (uint64): The interval of how often to prune the state. 0 means no pruning. | ||
|
||
## Pausable Pruner | ||
|
||
The `PausablePruner` interface defines the `PausePruning` method, which is used to pause | ||
the pruning process. The `PruningManager` will check if the pruner is a `PausablePruner` | ||
and call the `PausePruning` method before and after `Commit` to pause and resume pruning. | ||
This is useful for when the pruning process is asynchronous and needs to be paused during | ||
a commit to prevent parallel writes. | ||
|
||
## Pruning Flow | ||
|
||
```mermaid | ||
sequenceDiagram | ||
autonumber | ||
participant A as RootStore | ||
participant B as PruningManager | ||
participant C as CommitmentStore | ||
loop Commit | ||
A->>B: SignalCommit(true, height) | ||
alt SC is PausablePruner | ||
B->>C: PausePruning(true) | ||
end | ||
A->>C: Commit Changeset | ||
A->>B: SignalCommit(false, height) | ||
alt SC is PausablePruner | ||
B->>C: PausePruning(false) | ||
end | ||
B->>C: Prune(height) | ||
end | ||
``` |