Skip to content

The light node incorrectly reports a FORKED disconnection #6336

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

Open
317787106 opened this issue May 30, 2025 · 1 comment
Open

The light node incorrectly reports a FORKED disconnection #6336

317787106 opened this issue May 30, 2025 · 1 comment
Assignees

Comments

@317787106
Copy link
Contributor

Software Versions

OS : Linux
JVM : Oracle Corporation 1.8.0_161 amd64
Version : 4.7.6
Code : 18306

Expected behaviour

When a light node disconnects from a peer or is disconnected by a peer, it should provide the correct reason for the disconnection.

Actual behaviour

Node A (IP_A) is a full node on the mainnet, syncing from block height 0. Node B (IP_B) is a light node on the mainnet.

The following is Node B’s log, including it and Node A.

09:06:29.419 INFO  [peerWorker-6] [net](PeerConnection.java:184) Send peer /IP_A:63577 message type: P2P_HELLO
from: /IP_B:18888
timestamp: 1733907989415
headBlockId: Num:65574487,ID:0000000003e8965718a4d51d2efcdefcdd5aa52b3cc0a46e0cf42bb3d6a99113
nodeType: 1
lowestBlockNum: 5376487
codeVersion:4.7.6

09:06:29.825 INFO  [peerWorker-6] [net](P2pEventHandlerImpl.java:169) Receive message from  peer: /IP_A:63577, type: P2P_HELLO
from: /IP_A:18888
timestamp: 1733907987872
headBlockId: Num:61750,ID:000000000000f1361ade00d9bd8147a39412b6a1f3afd3bce3137b6035cbee28
nodeType: 0
lowestBlockNum: 0
codeVersion:4.7.7

09:06:29.825 INFO  [peerWorker-6] [net](HandshakeService.java:100) Peer /IP_A:63577 different solid block, peer->Num:61732,ID:000000000000f124236a6a8758c2950a0789f61685ae21011f29833460379549, me->Num:65574470,ID:0000000003e896465618a62d1c46ef8b82e5e6b1b3cbb3020702b3fe74eb7b29
09:06:29.825 INFO  [peerWorker-6] [net](PeerConnection.java:184) Send peer /IP_A:63577 message type: P2P_DISCONNECT
reason: FORKED

09:06:29.826 INFO  [peerWorker-6] [net](P2pChannelInitializer.java:45) Close channel:/IP_A:63577

09:06:29.826 WARN  [peerWorker-6] [net](P2pEventHandlerImpl.java:124) Receive msg from unknown peer /IP_A:63577

When processing the HelloMessage received from full node A, light node B failed the validation and disconnected with the reason FORKED. The validation failed because B's lowest block height was higher than A's highest block height, making synchronization impossible. However, both nodes are actually on the same chain, so the disconnection reason is incorrect.

The interaction between the local light node and its peer falls into two scenarios:

  1. The local node's head block number is lower than the peer's lowest block number. In this case, if the peer is also a light node, the handshake fails and the error LIGHT_NODE_SYNC_FAIL is reported.

  2. The local node's lowest block number is higher than the peer's highest finalized block. In this case, the handshake also fails and should report LIGHT_NODE_SYNC_FAIL. However, the actual disconnection reason reported is FORKED.

In the current implementation, if the peer's highest finalized block is not on the local node's main chain, it is immediately treated as a fork.However, the local node should first determine whether it is a light node. For light nodes, it is possible that the peer's finalized block is not on the local main chain, and this alone should not be treated as a fork.

Frequency

The reproduction rate is approximately 50%, depending on the order of HelloMessage exchange — whether B sends the HelloMessage to A first or vice versa.

Steps to reproduce the behaviour

As described above.

Backtrace

[backtrace]

When submitting logs: please submit them as text and not screenshots.

@lxcmyf
Copy link
Contributor

lxcmyf commented May 31, 2025

@317787106
What could be the actual cause of this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: To Do
Development

No branches or pull requests

3 participants