Skip to content

Commit

Permalink
resharding: cold storage (#580)
Browse files Browse the repository at this point in the history
  • Loading branch information
staffik authored Dec 13, 2024
1 parent d889993 commit 0ae4721
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions neps/nep-0568.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ Splitting a shard's Flat State is performed in multiple steps:

### State Storage - State

// TODO Describe integration with cold storage once design is ready

Each shard’s Trie is stored in the `State` column of the database, with keys prefixed by `ShardUId`, followed by a node's hash.
This structure uniquely identifies each shard’s data. To avoid copying all entries under a new `ShardUId` during resharding,
a mapping strategy allows child shards to access ancestor shard data without directly creating new entries.
Expand All @@ -155,11 +153,18 @@ This allows child shards to access and update state data under the ancestor shar
Initially, `ShardUIdMapping` is empty, as existing shards map to themselves. During resharding, a mapping entry is added to `ShardUIdMapping`,
pointing each child shard’s `ShardUId` to the appropriate ancestor. Mappings persist as long as any descendant shard references the ancestor’s data.
Once a node stops tracking all children and descendants of a shard, the entry for that shard can be removed, allowing its data to be garbage collected.
For archival nodes, mappings are retained indefinitely to maintain access to the full historical state.

This mapping strategy enables efficient shard management during resharding events,
supporting smooth transitions without altering storage structures directly.

#### Integration with cold storage (archival nodes)

Cold storage uses the same mapping strategy to manage shard state during resharding:
* When state data is migrated from hot to cold storage, it retains the parent shard’s `ShardUId` prefix, ensuring consistency with the mapping strategy.

Check failure on line 163 in neps/nep-0568.md

View workflow job for this annotation

GitHub Actions / markdown-lint

Lists should be surrounded by blank lines [Context: "* When state data is migrated ..."]

neps/nep-0568.md:163 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "* When state data is migrated ..."]
* While copying data for the last block of the epoch where resharding occured, the `DBCol::StateShardUIdMapping` column is copied into cold storage. This ensures that mappings are updated alongside the shard state data.
* These mappings are permanent in cold storage, aligning with its role in preserving historical state.

This approach minimizes complexity while maintaining consistency across hot and cold storage.

### Stateless Validation

Expand Down

0 comments on commit 0ae4721

Please sign in to comment.