feat: no state hashing during catch-up (state manager) #8424
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 PR optimizes the state manager to not hash the state at tip while catching up if consensus could deliver a certification for the tip height.
In more detail, the PR performs the following changes:
states.certificationsstoring certifications delivered optimistically by consensus for future heights (to be used when catching up);take_tipuses the state hash from a certification instates.certificationsif a certification at the tip height is available;commit_and_certifyreuses the certification fromstates.certificationif a certification at the committed height is available;remove_inmemory_states_belowandremove_states_belowprunesstates.certificationsat heights less thanlatest_state_heightandlatest_subnet_certified_height(this way, we have at mostMAX_CONSECUTIVE_ROUNDS_WITHOUT_STATE_CLONING + MAX_FUTURE_HEIGHTS_TO_CERTIFY = 30plus the certification lag - the difference between the latest resident and the latest certified height - many certifications stored instates.certificationsat any time);list_state_heights_to_certifyis used by consensus to determine heights for which certifications should be delivered:[tip_height..min(tip_height + MAX_FUTURE_HEIGHTS_TO_CERTIFY, latest_subnet_certified_height)] \ {heights for which we already have certifications}.The new functionality of the state manager is not yet invoked by consensus and thus the functionality is not yet effectively enabled by this PR.