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 in backfill sig verification #5120

Merged
merged 2 commits into from
Jan 30, 2024

Conversation

michaelsproul
Copy link
Member

@michaelsproul michaelsproul commented Jan 24, 2024

Issue Addressed

Fix a bug whereby the signature of the very first block in the chain (e.g. slot 1) would not be verified while backfilling. This was due to the break that occurs upon reaching the anchor bypassing the signed_blocks.push(signed_block).

Proposed Changes

  • Reorder the push before the break so that all blocks are added to signed_blocks and subsequently checked.
  • Add a regression test.

Additional Info

This bug was introduced in Deneb and does not impact v4.5.0. It does impact v4.6.0-rc.0.

@michaelsproul michaelsproul added bug Something isn't working ready-for-review The code is ready for review deneb labels Jan 24, 2024
Copy link
Member

@realbigsean realbigsean left a comment

Choose a reason for hiding this comment

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

Nice one!

beacon_node/beacon_chain/tests/store_tests.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@dapplion dapplion left a comment

Choose a reason for hiding this comment

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

Solid regression test, LGTM


// If we've reached genesis, add the genesis block root to the batch for all slots
// between 0 and the first block slot, and set the anchor slot to 0 to indicate
// completion.
if expected_block_root == self.genesis_block_root {
let genesis_slot = self.spec.genesis_slot;
for slot in genesis_slot.as_usize()..block.slot().as_usize() {
for slot in genesis_slot.as_usize()..prev_block_slot.as_usize() {
Copy link
Collaborator

@dapplion dapplion Jan 29, 2024

Choose a reason for hiding this comment

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

Ok, prev_block_slot case is already covered in the previous iteration in lines

// Store block roots, including at all skip slots in the freezer DB.
for slot in (block.slot().as_usize()..prev_block_slot.as_usize()).rev() {
chunk_writer.set(slot, block_root, &mut cold_batch)?;
}

@michaelsproul michaelsproul added ready-for-merge This PR is ready to merge. and removed ready-for-review The code is ready for review labels Jan 29, 2024
@michaelsproul
Copy link
Member Author

@Mergifyio queue

Copy link

mergify bot commented Jan 29, 2024

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at 6f3af67

mergify bot added a commit that referenced this pull request Jan 29, 2024
@mergify mergify bot merged commit 6f3af67 into sigp:unstable Jan 30, 2024
29 checks passed
@michaelsproul michaelsproul deleted the fix-backfill-signature-verif branch January 31, 2024 06:03
danielrachi1 pushed a commit to danielrachi1/lighthouse that referenced this pull request Feb 14, 2024
* Fix off-by-one in backfill sig verification

* Add self-referential PR link
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working deneb ready-for-merge This PR is ready to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants