Repository navigation
Conversation
| when(other.getInetSocketAddress()).thenReturn(otherAddress); | ||
| when(other.getNodeId()).thenReturn(nodeId); | ||
| when(other.getStartTime()).thenReturn(200L); | ||
| Map<InetSocketAddress, Channel> channels = ChannelManager.getChannels(); |
There was a problem hiding this comment.
[SHOULD] Duplicate-connection regression test does not establish the intended connection state.
HandshakeHeadCheckTest.java (line 282) still uses clear() and put() on ChannelManager.getChannels(). However, after the merge, ChannelManager.java (line 110) returns an independent copy.
As a result, these operations do not populate the actual connection registry, so the assertion that other connections remain open does not exercise the intended scenario. The merge also removed the original assertions verifying that the test setup was valid.
Please set up and clean up the test connections through the actual registry, and first assert that both connections are registered before testing duplicate-connection handling.
|
To avoid conflicts with other changes to |
What does this PR do?
Require a validated application-layer HELLO before processing peer traffic, enforce a handshake deadline, and keep invalid HELLO diagnostic logs bounded.
BAD_PROTOCOLbefore parsing or PBFT dispatch, and reject null or empty frames safely.TIME_OUTdisconnect, while retaining synchronization and request timeout checks. MakehelloMessageReceivevolatile for visibility to the status-check thread.ByteString.size()to avoid copying untrusted fields for logging.Why are these changes required?
Peers could reach business handlers, including PBFT, before completing the application handshake, while handshake timeout depended indirectly on synchronization state. Oversized hashes could also produce excessive warning output.
Handshake admission retains the existing version, genesis, and solid-block compatibility checks without adding a main-chain membership requirement for the peer's unfinalized head. This avoids rejecting otherwise compatible peers during a temporary fork, including reconnection after a disconnect or restart. Subsequent fork handling remains with the existing synchronization and broadcast logic.
This PR has been tested by:
HelloMessageTest,HandShakeServiceTest,HandshakeHeadCheckTest,P2pHelloGateTest, andPeerStatusCheckMockTestafter removing the endpoint format checks.HandShakeServiceTest; HELLO timeout scenarios are consolidated intoPeerStatusCheckMockTest.HelloMessageTest.testValidAddressLogFormatwas verified on an actual Java 8 runtime after fixing its JDK-dependent IPv6 formatting expectation../gradlew :framework:checkstyleMain :framework:checkstyleTest :plugins:checkstyleMain,bash .github/scripts/check_math_usage.sh, andgit diff --checkpassed locally.The full repository test suite and manual multi-node network testing were not run locally.
Follow up
The planned libp2p v2.3.0 fixes will be integrated into java-tron separately. This PR covers java-tron's application-layer HELLO handling and does not update the libp2p dependency.
Extra details