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

core/forkid: fix off-by-one bug #22879

Merged
merged 2 commits into from
May 18, 2021
Merged

Conversation

sjb933
Copy link
Contributor

@sjb933 sjb933 commented May 14, 2021

I'm working on the PulseChain fork and encountered an issue with the forkId code implementing EIP-2124.

This is a corner case that can cause Proof-of-Authority chains to deadlock on a fork block as described:

  • In the case of a PoA fork when you have only a single block-producer on the new fork, it will produce a single block and then wait for its peers to sign the next k blocks.
  • When a node is resting exactly on the fork block, this bug causes it to miscalculate its own FORK_HASH, using the pre-fork hash instead.
  • As a result, this node will reject new peers that are behind from joining the network and the PoA network is effectively deadlocked, producing no more blocks.
    • More specifically: Because of the incorrect FORK_HASH, the hash will match that of the new node that is behind. But since our head is >= to the remote id.Next, the peer is rejected.

The fix here is trivial. I added a failing test case then fixed the issue.

Best,
Shane

@VietKing1
Copy link

C C C

@samlavery
Copy link

samlavery commented May 15, 2021 via email

@fjl fjl changed the title forkId: fixed off-by-one bug core/forkid: fix off-by-one bug May 17, 2021
Copy link
Contributor

@fjl fjl left a comment

Choose a reason for hiding this comment

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

Good catch!

@fjl fjl added this to the 1.10.4 milestone May 18, 2021
Copy link
Member

@karalabe karalabe left a comment

Choose a reason for hiding this comment

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

SGTM

@karalabe karalabe merged commit 32c1ed8 into ethereum:master May 18, 2021
@skyisking
Copy link

Decent wallet

atif-konasl pushed a commit to frozeman/pandora-execution-engine that referenced this pull request Oct 15, 2021
* forkid: added failing test

* forkid: fixed off-by-one bug
@wanwiset25 wanwiset25 mentioned this pull request Jun 3, 2024
19 tasks
wanwiset25 pushed a commit to XinFinOrg/XDPoSChain that referenced this pull request Jun 19, 2024
* forkid: added failing test

* forkid: fixed off-by-one bug
wanwiset25 pushed a commit to XinFinOrg/XDPoSChain that referenced this pull request Jun 28, 2024
* forkid: added failing test

* forkid: fixed off-by-one bug
wanwiset25 added a commit to XinFinOrg/XDPoSChain that referenced this pull request Aug 23, 2024
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.

6 participants