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

Update block_log and fork_db to return empty std::optional when requested data not present #1289

Closed
greg7mdp opened this issue Jun 14, 2023 · 1 comment · Fixed by #1351
Closed
Assignees
Labels
👍 lgtm OCI Work exclusive to OCI team tech debt

Comments

@greg7mdp
Copy link
Contributor

We can have empty block_logs and fork_db, and when that happens APIs like fork_db.root() and blog.first_block_num() make up credible values that are not always consistent. For example, in controller.cpp::log_irreversible(), we retrieve the blog head with:

block_id_type log_head_id = blog.head_id(); which always return a sha256, and the we check if it is valid by checking if it is all zeros.

And if it is invalid, then we check that fork_db.root()->block_num == blog.first_block_num() - 1.

It seems to me that if we had blog.head_id() returning an empty std::optional to mean that the blog is empty, then maybe the only think we would need to check in the assert is that fork_db.root() also return std::nullopt.

PS: If I messed up the explanation, Kevin understands what I mean and is welcome to fix it.

@heifner
Copy link
Member

heifner commented Jun 14, 2023

The odd invariant we are currently maintaining is first_block_num() returning a block number for a block that is actually not in the block log. This clearly looks like a hack.

@bhazzard bhazzard added 👍 lgtm and removed triage labels Jun 15, 2023
@heifner heifner self-assigned this Jun 28, 2023
@heifner heifner added the OCI Work exclusive to OCI team label Jun 28, 2023
heifner added a commit that referenced this issue Jun 28, 2023
@heifner heifner added this to the Leap v5.0.0-rc1 milestone Jun 28, 2023
heifner added a commit that referenced this issue Jun 29, 2023
heifner added a commit that referenced this issue Jun 29, 2023
Blocklog: Return std::optional for head_id
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 tech debt
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants