parlia urgent: BEP-131 bug. Cause new validators on blockNumber%Epoch = 11 are slashed often. #1145
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.
Please review and merge this PR ASAP. It continually makes mistake for all validators.
Description
Inside parlia snapshot, BEP-131 validator set is updated at
number%s.config.Epoch == uint64(len(snap.Validators)/2)
.Simplify it is
blockNumber%200 = 10
parlia.SignRecently()
is the first function be called whenminer.worker
getting NewChainHead signal, which controls the starting of the packing tasks.But there is bug inside the
parlia.SignRecently()
causes the newValidatorSet is not updated onblockNumber%200 = 10
Obviously we cannot find a block by mismatched blockNumber and blockHash. In the line above they are
parent.Number.Uint64()
andparent.ParentHash
.However the
parent.ParentHash
hits a cache of parlia.Snapshot. The cached snapshot cannotsnap.apply
the latest chain head.Thus the very import part ChangeValidatorSet doesn't run on a RecentSigned validator and new imported validator of current Epoch.
Rationale
BNB48 Club reported some related cases.
Example
recent slash list,
blockNumber%Epoch = 11
occur frequentlyThe slashed validator
This was a new imported validator on Epoch of 22243800, it was a candidate in last Epoch. He was in-turn at 22243811.
But he didn't loaded the newValidatorSet at 22243810 so he missed 22243811.
Changes