Skip to content

core: split same-td blocks on block height#15470

Merged
karalabe merged 1 commit into
ethereum:masterfrom
karalabe:clique-sametd-splitter
Nov 15, 2017
Merged

core: split same-td blocks on block height#15470
karalabe merged 1 commit into
ethereum:masterfrom
karalabe:clique-sametd-splitter

Conversation

@karalabe
Copy link
Copy Markdown
Member

Our reorg logic currently is as follows:

  • If a new block has a larger TD than our existing head, reorg
  • If a new block and our own head have the same TD, flip a coin.

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 is 1. 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.

@karalabe karalabe added this to the 1.7.3 milestone Nov 13, 2017
Copy link
Copy Markdown
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants