Fix off-by-one bug in missed block detection#5012
Merged
michaelsproul merged 2 commits intosigp:unstablefrom Dec 15, 2023
Merged
Fix off-by-one bug in missed block detection#5012michaelsproul merged 2 commits intosigp:unstablefrom
michaelsproul merged 2 commits intosigp:unstablefrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue Addressed
Fix an issue reported by @antondlr and diagnosed by @pawanjay176 whereby the missed block reporting (#4731) was producing false positives.
The false positives were occurring under the following conditions:
Pawan worked this out from the logs, which took the form:
The bug occurred because the cache update logic was only running when a missed block was detected (
block_root == prev_block_root) and theslotwas at an epoch boundary. If there was no missed slot on the epoch boundary, then the cache would not get updated correctly (most of the time).Proposed Changes
Fix the cache update logic by keeping track of the cached epoch, and updating the cache whenever the missed block epoch is different from the cached epoch. This retains the intended performance characteristics of the original logic (don't bounce the cache lock too much).
Additional Info
If you checkout this branch at commit 1b0e6c9 and run the regression test with
cargo test --release -p beacon_chain -- missed_blocks_across_epochsthen it will fail. Applying the bugfix makes the test pass.