Skip to content

Commit 3c20e01

Browse files
Fix: Use negotiated protocol version in Status message
Previously, EthNodeStatus64ExchangeState hardcoded protocolVersion to 64 in the Status message, even when higher versions (ETH65-ETH68) were negotiated. This caused peers to reject our Status messages and disconnect with reason 0x10 (Other). Changes: - Added negotiatedCapability parameter to EthNodeStatus64ExchangeState - Modified createStatusMsg() to use negotiatedCapability.version instead of hardcoded Capability.ETH64.version - Updated EtcHelloExchangeState to pass negotiated capability and log the actual negotiated version instead of generic "eth/64+" - All existing tests pass Co-authored-by: realcodywburns <13103499+realcodywburns@users.noreply.github.com>
1 parent 82bf231 commit 3c20e01

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/main/scala/com/chipprbots/ethereum/network/handshaker/EtcHelloExchangeState.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ case class EtcHelloExchangeState(handshakerConfiguration: EtcHandshakerConfigura
3636
case Some(Capability.ETH63) =>
3737
log.debug("Negotiated protocol version with client {} is eth/63", hello.clientId)
3838
EthNodeStatus63ExchangeState(handshakerConfiguration)
39-
case Some(Capability.ETH64 | Capability.ETH65 | Capability.ETH66 | Capability.ETH67 | Capability.ETH68) =>
40-
log.debug("Negotiated protocol version with client {} is eth/64+", hello.clientId)
41-
EthNodeStatus64ExchangeState(handshakerConfiguration)
39+
case Some(negotiated @ (Capability.ETH64 | Capability.ETH65 | Capability.ETH66 | Capability.ETH67 | Capability.ETH68)) =>
40+
log.debug("Negotiated protocol version with client {} is {}", hello.clientId, negotiated)
41+
EthNodeStatus64ExchangeState(handshakerConfiguration, negotiated)
4242
case _ =>
4343
log.debug(
4444
s"Connected peer does not support eth/63-68 or etc/64 protocol. Disconnecting."

src/main/scala/com/chipprbots/ethereum/network/handshaker/EthNodeStatus64ExchangeState.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import com.chipprbots.ethereum.network.p2p.messages.ETH64
1414
import com.chipprbots.ethereum.network.p2p.messages.WireProtocol.Disconnect
1515

1616
case class EthNodeStatus64ExchangeState(
17-
handshakerConfiguration: EtcHandshakerConfiguration
17+
handshakerConfiguration: EtcHandshakerConfiguration,
18+
negotiatedCapability: Capability
1819
) extends EtcNodeStatusExchangeState[ETH64.Status] {
1920

2021
import handshakerConfiguration._
@@ -43,7 +44,7 @@ case class EthNodeStatus64ExchangeState(
4344
val genesisHash = blockchainReader.genesisHeader.hash
4445

4546
val status = ETH64.Status(
46-
protocolVersion = Capability.ETH64.version,
47+
protocolVersion = negotiatedCapability.version,
4748
networkId = peerConfiguration.networkId,
4849
totalDifficulty = chainWeight.totalDifficulty,
4950
bestHash = bestBlockHeader.hash,

0 commit comments

Comments
 (0)