feat(dynamic-resharding): allow dynamic shard layout in genesis - #16148
feat(dynamic-resharding): allow dynamic shard layout in genesis#16148jancionear wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #16148 +/- ##
==========================================
- Coverage 73.46% 73.45% -0.02%
==========================================
Files 861 861
Lines 190324 190453 +129
Branches 190324 190453 +129
==========================================
+ Hits 139820 139893 +73
- Misses 46059 46107 +48
- Partials 4445 4453 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Greptile SummaryThis PR allows genesis initialization to use the shard layout declared in genesis when the epoch configuration uses dynamic resharding.
Confidence Score: 5/5The PR appears safe to merge, with no concrete correctness or security failures identified in the changed paths. The epoch manager and genesis-state initializer consistently prefer an authoritative static epoch layout and fall back to the same concrete genesis-declared layout only when dynamic configuration omits one; all updated constructors supply matching layouts.
|
There was a problem hiding this comment.
Pull request overview
Enables genesis initialization and genesis epoch creation to work when the genesis protocol version uses dynamic resharding (i.e., the epoch config no longer defines a static shard layout), by falling back to the shard layout declared in the genesis config.
Changes:
- Use
genesis.config.shard_layoutas a fallback when the genesis epoch config has no static shard layout during store genesis initialization. - Extend
AllEpochConfigto carry the genesis-declared shard layout and expose a helper to obtain the correct genesis shard layout (static-from-epoch-config vs fallback-from-genesis-config). - Update epoch-manager genesis logic and unit tests to use the new
AllEpochConfigconstructor signature and genesis shard layout accessor.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| core/store/src/genesis/initialization.rs | Falls back to genesis-declared shard layout when epoch config has no static layout. |
| core/primitives/src/epoch_manager.rs | Stores genesis shard layout in AllEpochConfig and adds genesis_shard_layout() accessor. |
| chain/epoch-manager/src/tests/mod.rs | Updates tests to provide genesis_shard_layout to AllEpochConfig. |
| chain/epoch-manager/src/test_utils.rs | Threads a test shard layout into AllEpochConfig::from_epoch_config_store. |
| chain/epoch-manager/src/lib.rs | Passes genesis_config.shard_layout into AllEpochConfig during construction. |
| chain/epoch-manager/src/genesis.rs | Uses self.config.genesis_shard_layout() for genesis epoch creation instead of requiring a static layout. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
VanBarbascu
left a comment
There was a problem hiding this comment.
LGTM but I'd ask @Wiezzel to review on this too.
Wiezzel
left a comment
There was a problem hiding this comment.
A couple of comments:
- We should clean up the fork tool as well.
override_epoch_configsshould stop forcing Static for versions where the base config is dynamic (tools/fork-network/src/cli.rs:955-962),and make_and_write_genesisshould take the target layout as a parameter instead of extracting it from the epoch config (cli.rs:1596-1598). Tt already hastarget_shard_layoutat both call sites and already writes it intogenesis.config.shard_layout. GenesisConfig::shard_layout istagged with#[serde(default = "default_shard_layout")]which results in a single-shard layout and it's never validated. That could lead to some silent unwanted fallback – can we improve it?proposals_to_epochinfo silently drops the layout ifDynamicReshardingprotocol feature is not enabled. I'd add a check inmake_genesis_epoch_info– if dynamic resharding is not enabled on genesis protocol version, require that epoch config contains static shard layout.
Currently the code expects genesis to have a static shard layout. This causes trouble on forknets which start from the latest mainnet state, which has a dynamic shard layout. Let's allow having a genesis with dynamic shard layout.