feat: make epoch length dynamic and add protocol param for it#138
Merged
matthias-wright merged 6 commits intomainfrom Mar 9, 2026
Merged
feat: make epoch length dynamic and add protocol param for it#138matthias-wright merged 6 commits intomainfrom
matthias-wright merged 6 commits intomainfrom
Conversation
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.
This makes the epoch length dynamic and introduces a new protocol param for it.
The epocher trait is fairly generic:
There are no restrictions or contracts that stop an actor from calling
firstorlastwith a future epoch. Similarly, nothing is stopping an actor from callingcontainingwith a future height.This is tricky, because with the dynamic epocher, the length of future epochs can change if a protocol param change is submitted. We have to avoid a scenario where
epocher.first(n)returns different values for the samenat different times.Therefore, the dynamic epocher keeps track of the current epoch. The finalizer actor updates the epocher after every epoch change.
If one of the methods is called for an epoch larger than
current_epoch + 1, the dynamic epocher will returnNone.When a protocol param request updates the epoch length, it will be updated starting from
current_epoch + 2. This is because the epocher could've already answered a query forcurrent_epoch + 1.These are all the places where these methods are called:
All of these are for the current epoch (or past epochs during syncing), so the return value will never be
None.Only the application and the orchestrator would panic on a
Nonevalue, but the queries are always for the current epoch.Changes: