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: detect invalid buffered block when insert fails #10217

Merged
merged 2 commits into from
Aug 8, 2024

Conversation

Rjected
Copy link
Member

@Rjected Rjected commented Aug 8, 2024

This progresses us further in the Invalid Missing Ancestor Syncing ReOrg test, and allows us to actually detect the invalid ancestor block. Instead of just debug logging on each insert block error, we now perform the on_insert_block_error check whenever we get an error. This will inspect the error and insert it into the invalid headers cache if it was an actual invalid block.

@Rjected Rjected added C-bug An unexpected or incorrect behavior A-consensus Related to the consensus engine A-blockchain-tree Related to sidechains, reorgs and pending blocks labels Aug 8, 2024
@@ -1391,11 +1391,14 @@ where
}
Err(err) => {
debug!(target: "engine", ?err, "failed to connect buffered block to tree");
if let Err(fatal) = self.on_insert_block_error(err) {
warn!(target: "engine", ?fatal, "fatal error occurred while connecting buffered blocks");
Copy link
Collaborator

Choose a reason for hiding this comment

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

fatal is mislead here imo because fatal means that this block is invalid not that a fatal error happened?
could we rephrase this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Validation errors should be filtered out and handled in insert_block_error, the type in the Err is an InsertBlockFatalError

Copy link
Collaborator

@mattsse mattsse Aug 8, 2024

Choose a reason for hiding this comment

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

yeah, my point is how should "fatal" be interpreted if a user sees this on the terminal

fatal error occurred while connecting buffered blocks

this lacks context that this means only the insert routine was fatal, but I'd like to avoid logging "fatal" here

Copy link
Collaborator

Choose a reason for hiding this comment

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

because we don't terminate the task here, right? so it's not fatal, but maybe it should?

Copy link
Member Author

Choose a reason for hiding this comment

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

because we don't terminate the task here, right? so it's not fatal, but maybe it should?

Yeah, I guess we should bubble these up, since it would be an error that we can't otherwise do anything with

Copy link
Collaborator

Choose a reason for hiding this comment

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

okay, no I fully understood it, this is indeed a fatal internal error but can don't have an easy way to terminate the service, since we don't really expect this case under normal ops, this is appropriate until we find a way to either terminate the task or emit an error message

@@ -1391,11 +1391,14 @@ where
}
Err(err) => {
debug!(target: "engine", ?err, "failed to connect buffered block to tree");
if let Err(fatal) = self.on_insert_block_error(err) {
warn!(target: "engine", ?fatal, "fatal error occurred while connecting buffered blocks");
Copy link
Collaborator

Choose a reason for hiding this comment

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

this impls display I believe?

Suggested change
warn!(target: "engine", ?fatal, "fatal error occurred while connecting buffered blocks");
warn!(target: "engine", %fatal, "fatal error occurred while connecting buffered blocks");

Comment on lines 1640 to 1642
if let Err(fatal) = self.on_insert_block_error(err) {
warn!(target: "engine", ?fatal, "fatal error occurred while inserting downloaded block");
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

same

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 think we should consider adding an error variant to engineapievent so that we bubble up this info.

since this is indeed fatal, this makes sense for now

@Rjected Rjected added this pull request to the merge queue Aug 8, 2024
Merged via the queue into main with commit 0ee689f Aug 8, 2024
33 checks passed
@Rjected Rjected deleted the dan/invalid-block-checks branch August 8, 2024 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-blockchain-tree Related to sidechains, reorgs and pending blocks 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.

2 participants