Skip to content

Conversation

@mraszyk
Copy link
Contributor

@mraszyk mraszyk commented Jan 19, 2026

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:

  • introduces a new field states.certifications storing certifications delivered optimistically by consensus for future heights (to be used when catching up);
  • take_tip uses the state hash from a certification in states.certifications if a certification at the tip height is available;
  • commit_and_certify reuses the certification from states.certification if a certification at the committed height is available;
  • remove_inmemory_states_below and remove_states_below prunes states.certifications at heights less than latest_state_height and latest_subnet_certified_height (this way, we have at most MAX_CONSECUTIVE_ROUNDS_WITHOUT_STATE_CLONING + MAX_FUTURE_HEIGHTS_TO_CERTIFY = 30 plus the certification lag - the difference between the latest resident and the latest certified height - many certifications stored in states.certifications at any time);
  • a new method list_state_heights_to_certify is 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.

@github-actions github-actions bot added the feat label Jan 19, 2026
@mraszyk mraszyk marked this pull request as ready for review January 19, 2026 19:30
@mraszyk mraszyk requested review from a team as code owners January 19, 2026 19:30
@mraszyk mraszyk marked this pull request as draft January 20, 2026 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants