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

Validator Snapshot bug fix #164

Merged
merged 5 commits into from
Mar 25, 2024
Merged

Conversation

goran-ethernal
Copy link
Collaborator

@goran-ethernal goran-ethernal commented Mar 22, 2024

Description

This PR fixes the issue on validator snapshot, where an incorrect snapshot can be returned for some earlier epochs.

Basically the issue was discovered by running a network with 5 validators, which produced a number of epochs. In the newest epoch, two more validators were added, and the network finalized the ending block on that newest epoch, and a new snapshot was saved that contained those new validators (5 old + 2 new), meaning that will be the new active validator set from the next block.
After that epoch ending block was finalized (which carried validator set update), network experienced communication issues, and all validators were down, which cleared the memory cache in the validator_set_snapshot.go. Validators were started again, but, while validating a proposal for the new block (first block of the new epoch that contains 5 + 2 validators), parent signatures from the previous block, to be more precise, validator_snapshot returned the newest snapshot from db, which was the one updated with 2 new validators, instead of returning a snapshot from the previous epoch, since we are validating signatures from the previous block, which was in previous epoch.
This caused a constant round change on building a new block, because it returned a doesn't have quorum error, since the parent block had 4 signatures, and the returned snapshot had 7 validators, which was not enough.

The solution is, if we are querying a validator snapshot from an eariler epoch, and if we don't find it in memory, we should try to iterate in the db as well, and not just returned the last one we have in db, which might not be correct.

Changes include

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)

Checklist

  • I have assigned this PR to myself
  • I have added at least 1 reviewer
  • I have added the relevant labels
  • I have updated the official documentation
  • I have added sufficient documentation in code

Testing

  • I have tested this code with the official test suite
  • I have tested this code manually

@goran-ethernal goran-ethernal added the bug-fix Fix for a bug label Mar 22, 2024
@goran-ethernal goran-ethernal self-assigned this Mar 22, 2024
@goran-ethernal goran-ethernal requested a review from a team March 22, 2024 14:35
@goran-ethernal goran-ethernal force-pushed the validator-snapshot-bug-fix branch from f0759e6 to b66163a Compare March 22, 2024 14:37
@goran-ethernal goran-ethernal merged commit badef47 into develop Mar 25, 2024
9 of 10 checks passed
@goran-ethernal goran-ethernal deleted the validator-snapshot-bug-fix branch March 25, 2024 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-fix Fix for a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants