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

fix: Return correct latest block number #545

Merged
merged 3 commits into from
Nov 5, 2024
Merged

Conversation

igamigo
Copy link
Collaborator

@igamigo igamigo commented Nov 5, 2024

No description provided.

Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! Thank you!

@@ -99,7 +99,7 @@ struct InnerState {
impl InnerState {
/// Returns the latest block number.
fn latest_block_num(&self) -> BlockNumber {
(self.chain_mmr.forest() + 1).try_into().expect("block number overflow")
(self.chain_mmr.forest() - 1).try_into().expect("block number overflow")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would maybe add a safety comment here saying that chain_mmr always has at least one block (the genesis block) - and so this should be fine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I thought of the potential underflow but realized it was not an issue but did not write a comment. Will add now.

@igamigo igamigo merged commit abed540 into next Nov 5, 2024
8 checks passed
@igamigo igamigo deleted the igamigo-fix-block-num branch November 5, 2024 20:53
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.

2 participants