core: split same-td blocks on block height#15470
Merged
Merged
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.
Our reorg logic currently is as follows:
There's a subtle issue in the above algo when it comes to the Clique PoA consensus engine.
In clique, if a node signs a block in-turn, the block's difficulty is
2, whereas if it signs out-of-turn, the resulting difficulty is1. This means that a chain consisting of 1 in-turn block will weigh the same as a chain consisting of 2 out-of-turn blocks.This is a rare scenario, but if it occurs, nodes will select the correct chain by flipping a coin, resulting in half the signers on one chain, and half on the other. If there are an odd number of signers, the majority chain will continue. If however the number of signers is even, the two competing chains will get stuck, as neither has the majority to move forward.
This PR adds an extra splitting clause for same-td chains, where the one with the fewer blocks is considered heavier, and only if both are of the same height is the coin flipping done.