-
Notifications
You must be signed in to change notification settings - Fork 672
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: single shard tracking State cleanup (#12734)
Cleanup parent shard State if neither child was tracked for GC window epochs. That also implements shards garbage collection in general, see #11883. TODO: add more tests #### Summary * We cleanup the unused shards State with the delay of GC window epochs. One reason is that GC modifies the State, and removing the State earlier would result at least in negative refcounts, if not more serious problems. * For that, we need to know if a shard was not tracked since GC window epochs. One caveat is that validator operator could potentially changed the validator key in this period, so we should not rely on the current validator key (or even tracking config) to tell what shards were tracked in past. * We use `TrieChanges` column, to determine what shards were tracked at the given epoch. We rely on `TrieChanges` being saved to the last block of an epoch, for all shards that were tracked at given epoch. TODO: add a test that focuses on that * The cleanup for shards is only triggered when we gc-ed the last block of an epoch, always a final block and in canonical chain. * For each shard that we cleaned up, we remove State mapping for it, as the shard being deleted means we do not have the State for any descendant shard too. * Of course we should not remove the State of shards that are currently tracked. And we do not remove State of shards that we care about in the next epoch. ## Testing GC num epochs to keep set to **3**. #### Notation **P** - parent shard **C** - child shard **U** - unrelated shard Schedule: _(epoch before resharding) | (epoch after resharding) | ... next epochs_ #### Tested scenarios - P | C | U ... `test_resharding_v3_state_cleanup` - P | U ... `test_resharding_v3_do_not_track_children_after_resharding` - P | C | U | U | U | U | U | C ... `test_resharding_v3_stop_track_child_for_5_epochs` (in the end we do not map to parent) - P | C1 | U | U | C2 | U | U | C1 ... `test_resharding_v3_stop_track_child_for_5_epochs_with_sibling_in_between` (in the end we map to parent) - P | U | C ... `test_resharding_v3_shard_shuffling_untrack_then_track` - U | U | C ... `test_resharding_v3_sync_child`
- Loading branch information
Showing
21 changed files
with
449 additions
and
143 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
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
Oops, something went wrong.