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(engine): is_fork header traversal #11368

Merged
merged 3 commits into from
Oct 1, 2024
Merged

Conversation

rkrasiuk
Copy link
Member

@rkrasiuk rkrasiuk commented Oct 1, 2024

Description

If the header does not extend the canonical chain, on is_fork method invocation the engine might start traversing all of headers in the database and hit transaction timeout.

@rkrasiuk rkrasiuk force-pushed the rkrasiuk/fix-is-fork-logic branch 2 times, most recently from d1ed0a2 to 8fedc6b Compare October 1, 2024 14:34
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

nit,

checking against the canon hash and then the height is correct

crates/engine/tree/src/tree/mod.rs Outdated Show resolved Hide resolved
Comment on lines 946 to +934
while let Some(current_block) = self.sealed_header_by_hash(current_hash)? {
if current_block.hash() == self.state.tree_state.canonical_block_hash() {
if current_block.hash() == canonical_head.hash {
return Ok(false)
}
// We already passed the canonical head
if current_block.number <= canonical_head.number {
break
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

this loop is now safe and cuts off at the canonical head which is correct because this is the section we need to check here.

Copy link
Member

@Rjected Rjected left a comment

Choose a reason for hiding this comment

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

lgtm pending removing the finalized hash

@rkrasiuk rkrasiuk marked this pull request as ready for review October 1, 2024 19:02
@rkrasiuk rkrasiuk requested a review from mattsse October 1, 2024 19:02
@rkrasiuk rkrasiuk added C-bug An unexpected or incorrect behavior A-consensus Related to the consensus engine labels Oct 1, 2024
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

I see

lgtm

@rkrasiuk rkrasiuk added this pull request to the merge queue Oct 1, 2024
Merged via the queue into main with commit 408d793 Oct 1, 2024
35 checks passed
@rkrasiuk rkrasiuk deleted the rkrasiuk/fix-is-fork-logic branch October 1, 2024 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-consensus Related to the consensus engine C-bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants