[ETCM-355] Send fork id to peers#1030
Conversation
ad1ac51 to
6f2b08e
Compare
| Capability.negotiate(hello.capabilities.toList, handshakerConfiguration.capabilities) match { | ||
| Capability.negotiate(hello.capabilities.toList, handshakerConfiguration.blockchainConfig.capabilities) match { | ||
| case Some(ProtocolVersions.ETC64) => EtcNodeStatus64ExchangeState(handshakerConfiguration) | ||
| case Some(ProtocolVersions.ETH63) => EtcNodeStatus63ExchangeState(handshakerConfiguration) |
There was a problem hiding this comment.
request: do you mind changing this to Eth? I missed it and it's confusing this way.
|
overall looks good to me. question: would you be able to deploy to staging to see how it behaves? I guess running it locally against ETC mainnet would also be a good idea. |
6f2b08e to
ac6bd58
Compare
leo-bogastry
left a comment
There was a problem hiding this comment.
I thinks it's looking good
|
Waiting before merging for #1029 |
f877897 to
9f6194a
Compare
199ece7 to
43c8eef
Compare
This also fixes a bug in NewBlock message creation, where only protocol version was taken into account
4438dfb to
b0ec96e
Compare
| val remoteStatus = peers(peer.id).peerInfo.remoteStatus | ||
|
|
||
| val message: MessageSerializable = remoteStatus.protocolFamily match { | ||
| case ETH => blockToBroadcast.as63 |
There was a problem hiding this comment.
would be so cool to have this fail if a new block type is introduced. just a thought, no great ideas.
There was a problem hiding this comment.
Not sure what you mean here
There was a problem hiding this comment.
thinking out loud:
private def broadcastNewBlock(blockToBroadcast: BlockToBroadcast, peers: Map[PeerId, PeerWithInfo]): Unit =
obtainRandomPeerSubset(peers.values.map(_.peer).toSet).foreach { peer =>
val remoteStatus = peers(peer.id).peerInfo.remoteStatus
val message: MessageSerializable = {
val capOpt = Capabilities.of(remoteStatus.protocolFamily, remoteStatus.protocolVersion)
capOpt match {
case Capabilities.Eth63Capability => blockToBroadcast.as63
case Capabilities.Eth64Capability => blockToBroadcast.as63
case Capabilities.Etc64Capability => blockToBroadcast.as64
case None => throw new RuntimeException("Unknown capability, cannot broadcast block")
}
}
...
def of(pf: ProtocolFamily, v: Int): Option[Capability] =
(pf, v) match {
case (ProtocolFamily.ETH, 63) => Some(Eth63Capability)
case (ProtocolFamily.ETH, 64) => Some(Eth64Capability)
case (ProtocolFamily.ETC, 64) => Some(Etc64Capability)
case _ => None
}and an ADT out of the capabilities?
| case Some(ProtocolVersions.ETH64) => { | ||
| case Some(ProtocolVersions.ETH64) => | ||
| log.debug("Negotiated protocol version with client {} is eth/64", hello.clientId) | ||
| EthNodeStatus64ExchangeState(handshakerConfiguration) |
There was a problem hiding this comment.
could you also fix the 'orElse' clause that I introduced (orElse(WireDecoder))
There was a problem hiding this comment.
I would like to do this in a follow up PR, this one has become quite old and heavy
Description
First part of https://eips.ethereum.org/EIPS/eip-2364. Extends the ETH64 protocol Status by a fork id field and broadcasts it to peers during handshake
Does not yet contain peer fork id validation