[BREAKING & DNM] Consensus > PoS: remove epoch-1 init hack#18699
Draft
glyh wants to merge 3 commits intolyh/nit-improvement-posfrom
Draft
[BREAKING & DNM] Consensus > PoS: remove epoch-1 init hack#18699glyh wants to merge 3 commits intolyh/nit-improvement-posfrom
glyh wants to merge 3 commits intolyh/nit-improvement-posfrom
Conversation
7bb3396 to
0443399
Compare
…resentations Replace the flat `epoch_ledger_uuids` record with a variant `Epoch_ledgers` type (`Epoch_zero | Epoch_one | Epoch_two_or_more`) that makes it impossible to express invalid states (e.g. a staking UUID with no next UUID in early epochs). On startup, if the persisted metadata is missing or belongs to a different genesis, reset cleanly to genesis rather than crashing or using stale data. Co-located changes: - Embed `config` inside `Ledger_snapshot.Ledger_root` so callers no longer need to reconstruct it separately when removing a snapshot - Derive yojson for epoch ledger metadata via ppx instead of hand-rolled converters - Rename snapshot identifiers: `Staking_epoch_snapshot`/`Next_epoch_snapshot` -> `Staking`/`Next` - Pass full ledger + config in `required_snapshot_sync` so `sync_local_state` no longer needs to derive the ledger from the snapshot kind at sync time
f795705 to
388d682
Compare
Member
Author
|
This grows much more complex than what I intended to do in the beginning. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
A previous fix addressed incorrect staking ledger selection on restart in epoch 1 by loading the next epoch ledger first and inferring the staking fallback from its provenance (genesis vs disk). This worked but was fragile and marked as a hack.
Changes
Store epoch number on disk (
epoch_ledger_uuids): adds anepochfield so initialization can reason directly about the persisted state's epoch rather than inferring it indirectly.Replace the hack with explicit case analysis on (epoch, disk backing presence):