From 5368857ee874d82038ba5d406529e191a8dac2f9 Mon Sep 17 00:00:00 2001 From: Waclaw Banasik Date: Thu, 7 Nov 2024 11:28:08 +0000 Subject: [PATCH] ShardId Semantics (#572) --- neps/nep-0568.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/neps/nep-0568.md b/neps/nep-0568.md index 285d3524c..98615acf0 100644 --- a/neps/nep-0568.md +++ b/neps/nep-0568.md @@ -143,6 +143,10 @@ supporting smooth transitions without altering storage structures directly. ### ShardId Semantics +Currently, shard IDs are represented as numbers within the range `[0,n)`, where n is the total number of shards. These shard IDs are sorted in the same order as the account ID ranges assigned to them. While this approach is straightforward, it complicates resharding operations, particularly when splitting a shard in the middle of the range. Such a split requires reindexing all subsequent shards with higher IDs, adding complexity to the process. + +In this NEP, we propose updating the ShardId semantics to allow for arbitrary identifiers. Although ShardIds will remain integers, they will no longer be restricted to the `[0,n)` range, and they may appear in any order. The only requirement is that each ShardId must be unique. In practice, during resharding, the ID of a parent shard will be removed from the ShardLayout, and the new child shards will be assigned unique IDs - `max(shard_ids)+1` and `max(shard_ids)+2`. + ## Reference Implementation ```text