Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove distinction between fork_db pending_head and head; persist if_irreversible_block_id in fork_db; add fork_db_pending_lib_num #333

Closed
arhag opened this issue Jun 28, 2024 · 1 comment · Fixed by #347 or #350
Assignees
Labels
👍 lgtm OCI Work exclusive to OCI team
Milestone

Comments

@arhag
Copy link
Member

arhag commented Jun 28, 2024

On startup, when loading the fork database from disk, nodeos should either reconstruct the if_irreversible_block_id using the QC data stored in the fork database to what it should have been prior to shutdown, or it should simply restore a saved if_irreversible_block_id.

Prior to #325, we had a function latest_known_lib_num which return the LIB number regardless of whether the node was in a pre-Savanna state or post-Savanna state. But it had a problem during the transition where it would return the dpos_irreversible_block_num (of the legacy consensus algorithm) without capping it to the IF Genesis block number.

Additionally, we still have fork_db_head_irreversible_blocknum which returns the LIB number from the perspective of the best head (whether Savanna or legacy). But this still has the flaw above during the transition and also for a Proper IF block it has the further flaw that it may not be the best known LIB that is tracked by if_irreversible_block_id since it does not include the effect of any integrated QC that was pulled from an invalid block.

We should have a function to complement fork_db_head_block_id that returns the block ID of the block known by the fork database (including the if_irreversible_block_id which can kind of be considered as part of the fork database, and may make sense to officially move into the fork database) to be the best LIB to move towards (this might be called fork_db_pending_lib_id). This is not the same as the current LIB since that is still driven by the root block of the fork database. Once we have fork_db_pending_lib_id (and we could add a convenience function fork_db_pending_lib_num to complement it if we wish), then we can get rid of fork_db_head_irreversible_blocknum.

There is no need for a distinction between pending_head and head in fork database. There is only a single head which can be thought of as the pending head. This means that the chain_head may not be at the head of the fork database. This can be because it is in the middle of advancing the chain_head (or doing a fork switch to it), or it can be because it is in irreversible mode. If nodeos is in irreversible mode, then chain_head is either at the fork_db_pending_lib_id or it is shortly behind it and in the middle of advancing towards it.

@arhag arhag added this to the Savanna: Cusp milestone Jun 28, 2024
@enf-ci-bot enf-ci-bot moved this to Todo in Team Backlog Jun 28, 2024
@arhag arhag added 👍 lgtm and removed triage labels Jun 28, 2024
@heifner heifner added the OCI Work exclusive to OCI team label Jul 2, 2024
@heifner heifner moved this from Todo to In Progress in Team Backlog Jul 2, 2024
heifner added a commit that referenced this issue Jul 3, 2024
heifner added a commit that referenced this issue Jul 3, 2024
…on to avoid confusion with local variables named fork_head
heifner added a commit that referenced this issue Jul 5, 2024
heifner added a commit that referenced this issue Jul 5, 2024
heifner added a commit that referenced this issue Jul 8, 2024
heifner added a commit that referenced this issue Jul 8, 2024
…m pending_head() which will be clearer when renamed to head().
heifner added a commit that referenced this issue Jul 9, 2024
heifner added a commit that referenced this issue Jul 9, 2024
heifner added a commit that referenced this issue Jul 9, 2024
@heifner heifner linked a pull request Jul 9, 2024 that will close this issue
heifner added a commit that referenced this issue Jul 9, 2024
@heifner heifner moved this from In Progress to Awaiting Review in Team Backlog Jul 9, 2024
heifner added a commit that referenced this issue Jul 10, 2024
heifner added a commit that referenced this issue Jul 10, 2024
heifner added a commit that referenced this issue Jul 10, 2024
@github-project-automation github-project-automation bot moved this from Awaiting Review to Done in Team Backlog Jul 10, 2024
@heifner
Copy link
Member

heifner commented Jul 10, 2024

Re-open for additional work of savanna lib calculation moved to forkdb.

@heifner heifner reopened this Jul 10, 2024
@github-project-automation github-project-automation bot moved this from Done to Todo in Team Backlog Jul 10, 2024
@heifner heifner moved this from Todo to In Progress in Team Backlog Jul 10, 2024
heifner added a commit that referenced this issue Jul 10, 2024
Move savanna pending lib calculation to forkdb add()
@github-project-automation github-project-automation bot moved this from In Progress to Done in Team Backlog Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👍 lgtm OCI Work exclusive to OCI team
Projects
Archived in project
3 participants