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 off-by-one bug in missed block detection #5012

Merged
merged 2 commits into from
Dec 15, 2023

Conversation

michaelsproul
Copy link
Member

@michaelsproul michaelsproul commented Dec 15, 2023

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:

  1. There is at least one missed block in epoch $N$.
  2. This is a missed block in epoch $N + 1$ at offset $k$.
  3. The validator monitor is monitoring the validator that proposed (successfully) at the same offset $k$ in epoch $N$, i.e. at the slot 32 slots prior to the slot missed by another validator.

Pawan worked this out from the logs, which took the form:

Dec 14 00:02:49.296 ERRO Validator missed a block parent block root: 0x7b3d561ea177b3b5bfee86033bb8b5d3934f32bfc75e7659d6c277c4c216b965, slot: 7167010, index: 110237, service: val_mon, service: beacon

  • Validator index 110237 is one of our Goerli validators.
  • Slot 7167010 was indeed missed, but not by validator 110237.
  • Validator 110237 proposed at the same offset in the epoch prior: 7166978.

The bug occurred because the cache update logic was only running when a missed block was detected (block_root == prev_block_root) and the slot was 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_epochs then it will fail. Applying the bugfix makes the test pass.

@michaelsproul michaelsproul added bug Something isn't working ready-for-review The code is ready for review UX-and-logs v4.6.0 ETA Q1 2024 labels Dec 15, 2023
Copy link
Member

@paulhauner paulhauner left a comment

Choose a reason for hiding this comment

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

Nice diagnosis and fix! 🎉

@michaelsproul michaelsproul added ready-for-merge This PR is ready to merge. and removed ready-for-review The code is ready for review labels Dec 15, 2023
@michaelsproul michaelsproul merged commit f111354 into sigp:unstable Dec 15, 2023
28 checks passed
@michaelsproul michaelsproul deleted the missed-block-off-by-one branch December 15, 2023 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready-for-merge This PR is ready to merge. UX-and-logs v4.6.0 ETA Q1 2024
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants