bsc icon indicating copy to clipboard operation
bsc copied to clipboard

eth/protocols/eth: add `JustifiedNumber` into StatusPacket

Open buddh0 opened this issue 5 months ago • 0 comments

Description

eth/protocols/eth: add JustifiedNumber into StatusPacket

Rationale

Until now, when a node attempts to select a peer for full synchronization, it only compares peers based on td (total difficulty). However, the correct logic should follow the approach in ReorgNeededWithFastFinality:

1. First, compare the justifiedNumber.
2. If the justifiedNumber is equal, then compare td.

Relying solely on td can cause a node to select the wrong peer for synchronization. In certain edge cases, this can split the network and cause the chain to stall, as was observed in the chapel network. To resolve this issue:

1. Introduce an optional JustifiedNumber in the StatusPacket.
2. When updating a peer's head, prioritize the comparison of justifiedNumber before td.

To avoid creating a new version of the Ethereum protocol (e.g., eth70), the fix can be implemented in three phases:

1. Add the optional JustifiedNumber in the client.
2. After a hard fork, once all nodes are able to parse the updated StatusPacket, pass the JustifiedNumber in the StatusMsg during a maintenance release.
3. After a subsequent hard fork, enforce the use of JustifiedNumber in StatusMsg, and reject messages without it in a future maintenance release.

This pull request (PR) covers only the first phase. The following two phases are ready, requiring just one or two lines of code to be uncommented.

Example

add an example CLI or API response...

Changes

Notable changes:

  • add each change in a bullet point here
  • ...

buddh0 avatar Sep 12 '24 10:09 buddh0