Skip to content

Commit bfb2bef

Browse files
authored
[ETCM-841] Replace PV64 with ETC64 (#1004)
* [ETCM-841] Change protocol version to a full name * [ETCM-841] Remove general purpose protocol version, replace with capabilities list * [ETCM-841] Introduce a simple Capability.best selection algorithm * [ETCM-841] Add simple protocol negotiation * [ETCM-841] Introduce negotiated protocol version to EtcHelloExchangeState * [ETCM-841] Reorganise RLPxConnectionHandler 'processHandshakeResult' * [ETCM-841] Rename CommonMessages to BaseETH6XMessages * [ETCM-841] Align unit tests to changes in flow of protocol negotiation * [ETCM-841] Rename PV6X elements to ETX6X scheme * [ETCM-841] Apply scalafmt * [ETCM-841] Handle 'Hello' negotiation as a connection stage * [ETCM-841] Apply scalafmt * [ETCM-841] Add a mechanism for notifying PeerActor about 'negotiated protocol' * [ETCM-841] Apply PR remarks * [ETCM-841] Apply PR remarks
1 parent ced3375 commit bfb2bef

File tree

104 files changed

+717
-526
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+717
-526
lines changed

src/benchmark/scala/io/iohk/ethereum/rlp/RLPSpeedSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import akka.util.ByteString
44
import io.iohk.ethereum.ObjectGenerators
55
import io.iohk.ethereum.domain.Block._
66
import io.iohk.ethereum.domain._
7-
import io.iohk.ethereum.network.p2p.messages.CommonMessages.SignedTransactions._
7+
import io.iohk.ethereum.network.p2p.messages.BaseETH6XMessages.SignedTransactions._
88
import io.iohk.ethereum.utils.Logger
99
import io.iohk.ethereum.utils.Hex
1010
import org.scalacheck.Gen

src/it/scala/io/iohk/ethereum/sync/util/CommonFakePeer.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package io.iohk.ethereum.sync.util
33
import java.nio.file.Files
44
import java.time.Clock
55
import java.util.concurrent.atomic.AtomicReference
6-
76
import akka.actor.{ActorRef, ActorSystem}
87
import akka.testkit.TestProbe
98
import akka.util.{ByteString, Timeout}
@@ -25,6 +24,7 @@ import io.iohk.ethereum.network.discovery.PeerDiscoveryManager.DiscoveredNodesIn
2524
import io.iohk.ethereum.network.discovery.{DiscoveryConfig, Node}
2625
import io.iohk.ethereum.network.handshaker.{EtcHandshaker, EtcHandshakerConfiguration, Handshaker}
2726
import io.iohk.ethereum.network.p2p.EthereumMessageDecoder
27+
import io.iohk.ethereum.network.p2p.messages.Capability
2828
import io.iohk.ethereum.network.rlpx.AuthHandshaker
2929
import io.iohk.ethereum.network.rlpx.RLPxConnectionHandler.RLPxConfiguration
3030
import io.iohk.ethereum.network.{
@@ -169,7 +169,7 @@ abstract class CommonFakePeer(peerName: String, fakePeerCustomConfig: FakePeerCu
169169
override val peerConfiguration: PeerConfiguration = peerConf
170170
override val blockchain: Blockchain = bl
171171
override val appStateStorage: AppStateStorage = storagesInstance.storages.appStateStorage
172-
override val protocolVersion: Int = Config.Network.protocolVersion
172+
override val capabilities: List[Capability] = blockchainConfig.capabilities
173173
}
174174

175175
lazy val handshaker: Handshaker[PeerInfo] = EtcHandshaker(handshakerConfiguration)
@@ -193,7 +193,7 @@ abstract class CommonFakePeer(peerName: String, fakePeerCustomConfig: FakePeerCu
193193
EthereumMessageDecoder,
194194
discoveryConfig,
195195
blacklist,
196-
Config.Network.protocolVersion
196+
blockchainConfig.capabilities
197197
),
198198
"peer-manager"
199199
)

src/it/scala/io/iohk/ethereum/sync/util/RegularSyncItSpecUtils.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import io.iohk.ethereum.crypto
2525
import io.iohk.ethereum.domain._
2626
import io.iohk.ethereum.ledger._
2727
import io.iohk.ethereum.network.PeerId
28-
import io.iohk.ethereum.network.p2p.messages.CommonMessages.NewBlock
28+
import io.iohk.ethereum.network.p2p.messages.BaseETH6XMessages.NewBlock
2929
import io.iohk.ethereum.nodebuilder.VmSetup
3030
import io.iohk.ethereum.ommers.OmmersPool
3131
import io.iohk.ethereum.sync.util.SyncCommonItSpecUtils.FakePeerCustomConfig.defaultConfig

src/it/scala/io/iohk/ethereum/txExecTest/util/DumpChainActor.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import io.iohk.ethereum.network.PeerEventBusActor.SubscriptionClassifier.Message
1515
import io.iohk.ethereum.network.PeerEventBusActor.{PeerSelector, Subscribe}
1616
import io.iohk.ethereum.network.PeerManagerActor.{GetPeers, Peers}
1717
import io.iohk.ethereum.network.p2p.messages.Codes
18-
import io.iohk.ethereum.network.p2p.messages.PV62._
19-
import io.iohk.ethereum.network.p2p.messages.PV63.MptNodeEncoders._
20-
import io.iohk.ethereum.network.p2p.messages.PV63.ReceiptImplicits._
21-
import io.iohk.ethereum.network.p2p.messages.PV63._
18+
import io.iohk.ethereum.network.p2p.messages.ETH62._
19+
import io.iohk.ethereum.network.p2p.messages.ETH63.MptNodeEncoders._
20+
import io.iohk.ethereum.network.p2p.messages.ETH63.ReceiptImplicits._
21+
import io.iohk.ethereum.network.p2p.messages.ETH63._
2222
import io.iohk.ethereum.network.{Peer, PeerManagerActor}
2323
import io.iohk.ethereum.txExecTest.util.DumpChainActor._
2424
import org.bouncycastle.util.encoders.Hex

src/it/scala/io/iohk/ethereum/txExecTest/util/DumpChainApp.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package io.iohk.ethereum.txExecTest.util
22

33
import java.time.Clock
44
import java.util.concurrent.atomic.AtomicReference
5-
65
import akka.actor.ActorSystem
76
import akka.util.ByteString
87
import com.typesafe.config.ConfigFactory
@@ -25,6 +24,7 @@ import io.iohk.ethereum.network.PeerStatisticsActor
2524
import io.iohk.ethereum.network.discovery.DiscoveryConfig
2625
import io.iohk.ethereum.network.handshaker.{EtcHandshaker, EtcHandshakerConfiguration, Handshaker}
2726
import io.iohk.ethereum.network.p2p.EthereumMessageDecoder
27+
import io.iohk.ethereum.network.p2p.messages.Capability
2828
import io.iohk.ethereum.network.rlpx.RLPxConnectionHandler.RLPxConfiguration
2929
import io.iohk.ethereum.network.{ForkResolver, PeerEventBusActor, PeerManagerActor}
3030
import io.iohk.ethereum.nodebuilder.{AuthHandshakerBuilder, NodeKeyBuilder}
@@ -93,7 +93,7 @@ object DumpChainApp extends App with NodeKeyBuilder with SecureRandomBuilder wit
9393
override val peerConfiguration: PeerConfiguration = peerConfig
9494
override val blockchain: Blockchain = DumpChainApp.blockchain
9595
override val appStateStorage: AppStateStorage = storagesInstance.storages.appStateStorage
96-
override val protocolVersion: Int = Config.Network.protocolVersion
96+
override val capabilities: List[Capability] = blockchainConfig.capabilities
9797
}
9898

9999
lazy val handshaker: Handshaker[PeerInfo] = EtcHandshaker(handshakerConfiguration)
@@ -116,7 +116,7 @@ object DumpChainApp extends App with NodeKeyBuilder with SecureRandomBuilder wit
116116
messageDecoder = EthereumMessageDecoder,
117117
discoveryConfig = discoveryConfig,
118118
blacklist = blacklist,
119-
bestProtocolVersion = Config.Network.protocolVersion
119+
capabilities = blockchainConfig.capabilities
120120
),
121121
"peer-manager"
122122
)

src/it/scala/io/iohk/ethereum/txExecTest/util/FixtureProvider.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import io.iohk.ethereum.db.storage._
77
import io.iohk.ethereum.domain._
88
import io.iohk.ethereum.domain.BlockHeaderImplicits._
99
import io.iohk.ethereum.domain.BlockBody._
10-
import io.iohk.ethereum.network.p2p.messages.PV63._
10+
import io.iohk.ethereum.network.p2p.messages.ETH63._
1111
import MptNodeEncoders._
1212
import ReceiptImplicits._
1313
import io.iohk.ethereum.db.cache.{AppCaches, LruCache}

src/main/resources/conf/base.conf

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ mantis {
3434
}
3535

3636
network {
37-
# Ethereum protocol version
38-
# Supported versions:
39-
# 63, 64 (experimental version which enables usage of messages with checkpointing information. In the future after ETCM-355, ETCM-356, it will be 66 probably)
40-
protocol-version = 63
41-
4237
server-address {
4338
# Listening interface for Ethereum protocol connections
4439
interface = "0.0.0.0"
@@ -328,15 +323,15 @@ mantis {
328323

329324
mordor {include required("chains/mordor-chain.conf")}
330325

326+
pottery {include required("chains/pottery-chain.conf")}
327+
331328
ropsten {include required("chains/ropsten-chain.conf")}
332329

333330
test {include required("chains/test-chain.conf")}
334331

335-
testnet-internal-nomad {include required("chains/testnet-internal-nomad-chain.conf")}
336-
337332
testnet-internal-gac {include required("chains/testnet-internal-gac-chain.conf")}
338333

339-
pottery {include required("chains/pottery-chain.conf")}
334+
testnet-internal-nomad {include required("chains/testnet-internal-nomad-chain.conf")}
340335
}
341336

342337
sync {

src/main/resources/conf/chains/etc-chain.conf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
# 1 - mainnet, 3 - ropsten, 7 - mordor
44
network-id = 1
55

6+
# The ID of the accepted chain
7+
chain-id = "0x3d"
8+
9+
capabilities = ["eth/63"]
10+
611
# Possibility to set Proof of Work target time for testing purposes.
712
# null means that the standard difficulty calculation rules are used
813
pow-target-time = null
@@ -126,9 +131,6 @@
126131
# Starting nonce of an empty account. Some networks (like Morden) use different values.
127132
account-start-nonce = "0"
128133

129-
# The ID of the accepted chain
130-
chain-id = "0x3d"
131-
132134
# Custom genesis JSON file path
133135
# null value indicates using default genesis definition that matches the main network
134136
custom-genesis-file = null

src/main/resources/conf/chains/eth-chain.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# 1 - mainnet, 3 - ropsten, 7 - mordor
44
network-id = 1
55

6+
capabilities = ["eth/63"]
7+
68
# Possibility to set Proof of Work target time for testing purposes.
79
# null means that the standard difficulty calculation rules are used
810
pow-target-time = null

src/main/resources/conf/chains/mordor-chain.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# 1 - mainnet, 3 - ropsten, 7 - mordor
44
network-id = 7
55

6+
capabilities = ["eth/63"]
7+
68
# Possibility to set Proof of Work target time for testing purposes.
79
# null means that the standard difficulty calculation rules are used
810
pow-target-time = null

src/main/resources/conf/chains/pottery-chain.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ include "mordor-chain.conf"
22
# 1 - mainnet, 3 - ropsten, 7 - mordor, 9 - pottery
33
network-id = 9
44

5+
capabilities = ["etc/64"]
6+
57
ecip1098-block-number = "0"
68

79
ecip1097-block-number = "0"

src/main/resources/conf/chains/ropsten-chain.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# 1 - mainnet, 3 - ropsten, 7 - mordor
44
network-id = 3
55

6+
capabilities = ["eth/63"]
7+
68
# Possibility to set Proof of Work target time for testing purposes.
79
# null means that the standard difficulty calculation rules are used
810
pow-target-time = null

src/main/resources/conf/chains/test-chain.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# 1 - mainnet, 7 - mordor
44
network-id = 1
55

6+
capabilities = ["eth/63"]
7+
68
# Possibility to set Proof of Work target time for testing purposes.
79
# null means that the standard difficulty calculation rules are used
810
pow-target-time = null

src/main/resources/conf/chains/testnet-internal-gac-chain.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# 1 - mainnet, 3 - ropsten, 7 - mordor
44
network-id = 42
55

6+
capabilities = ["eth/63"]
7+
68
# Possibility to set Proof of Work target time for testing purposes.
79
# null means that the standard difficulty calculation rules are used
810
pow-target-time = null

src/main/resources/conf/chains/testnet-internal-nomad-chain.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# 1 - mainnet, 3 - ropsten, 7 - mordor
44
network-id = 42
55

6+
capabilities = ["etc/64"]
7+
68
# Possibility to set Proof of Work target time for testing purposes.
79
# null means that the standard difficulty calculation rules are used
810
pow-target-time = 15 seconds

src/main/resources/conf/pottery.conf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ mantis {
66
}
77

88
network {
9-
protocol-version = 64
10-
119
discovery {
1210
discovery-enabled = true
1311
}

src/main/resources/conf/testnet-internal-nomad.conf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ mantis {
66
}
77

88
network {
9-
protocol-version = 64
10-
119
discovery {
1210
discovery-enabled = true
1311
}

src/main/scala/io/iohk/ethereum/blockchain/sync/BlockchainHostActor.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import io.iohk.ethereum.network.PeerEventBusActor.SubscriptionClassifier.Message
88
import io.iohk.ethereum.network.PeerEventBusActor.{PeerSelector, Subscribe}
99
import io.iohk.ethereum.network.PeerManagerActor.PeerConfiguration
1010
import io.iohk.ethereum.network.p2p.{Message, MessageSerializable}
11-
import io.iohk.ethereum.network.p2p.messages.PV62.{BlockBodies, BlockHeaders, GetBlockBodies, GetBlockHeaders}
12-
import io.iohk.ethereum.network.p2p.messages.PV63.{GetNodeData, GetReceipts, NodeData, Receipts}
13-
import io.iohk.ethereum.network.p2p.messages.PV63.MptNodeEncoders._
11+
import io.iohk.ethereum.network.p2p.messages.ETH62.{BlockBodies, BlockHeaders, GetBlockBodies, GetBlockHeaders}
12+
import io.iohk.ethereum.network.p2p.messages.ETH63.{GetNodeData, GetReceipts, NodeData, Receipts}
13+
import io.iohk.ethereum.network.p2p.messages.ETH63.MptNodeEncoders._
1414
import io.iohk.ethereum.network.EtcPeerManagerActor
1515
import io.iohk.ethereum.network.p2p.messages.Codes
1616

src/main/scala/io/iohk/ethereum/blockchain/sync/PeersClient.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import io.iohk.ethereum.blockchain.sync.PeerListSupportNg.PeerWithInfo
66
import io.iohk.ethereum.network.EtcPeerManagerActor.PeerInfo
77
import io.iohk.ethereum.network.p2p.messages.Codes
88
import io.iohk.ethereum.network.{Peer, PeerId}
9-
import io.iohk.ethereum.network.p2p.messages.PV62._
10-
import io.iohk.ethereum.network.p2p.messages.PV63.{GetNodeData, NodeData}
9+
import io.iohk.ethereum.network.p2p.messages.ETH62._
10+
import io.iohk.ethereum.network.p2p.messages.ETH63.{GetNodeData, NodeData}
1111
import io.iohk.ethereum.network.p2p.{Message, MessageSerializable}
1212
import io.iohk.ethereum.utils.Config.SyncConfig
1313

src/main/scala/io/iohk/ethereum/blockchain/sync/fast/DownloaderState.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import io.iohk.ethereum.blockchain.sync.fast.SyncStateSchedulerActor.{
1111
UsefulData
1212
}
1313
import io.iohk.ethereum.crypto.kec256
14-
import io.iohk.ethereum.network.p2p.messages.PV63.NodeData
14+
import io.iohk.ethereum.network.p2p.messages.ETH63.NodeData
1515
import io.iohk.ethereum.network.{Peer, PeerId}
1616

1717
import scala.annotation.tailrec

src/main/scala/io/iohk/ethereum/blockchain/sync/fast/FastSync.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import io.iohk.ethereum.mpt.MerklePatriciaTrie
2626
import io.iohk.ethereum.network.EtcPeerManagerActor.PeerInfo
2727
import io.iohk.ethereum.network.Peer
2828
import io.iohk.ethereum.network.p2p.messages.Codes
29-
import io.iohk.ethereum.network.p2p.messages.PV62._
30-
import io.iohk.ethereum.network.p2p.messages.PV63._
29+
import io.iohk.ethereum.network.p2p.messages.ETH62._
30+
import io.iohk.ethereum.network.p2p.messages.ETH63._
3131
import io.iohk.ethereum.utils.ByteStringUtils
3232
import io.iohk.ethereum.utils.Config.SyncConfig
3333
import org.bouncycastle.util.encoders.Hex

src/main/scala/io/iohk/ethereum/blockchain/sync/fast/FastSyncBranchResolverActor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import io.iohk.ethereum.db.storage.AppStateStorage
1010
import io.iohk.ethereum.domain.{BlockHeader, Blockchain}
1111
import io.iohk.ethereum.network.Peer
1212
import io.iohk.ethereum.network.p2p.messages.Codes
13-
import io.iohk.ethereum.network.p2p.messages.PV62.{BlockHeaders, GetBlockHeaders}
13+
import io.iohk.ethereum.network.p2p.messages.ETH62.{BlockHeaders, GetBlockHeaders}
1414
import io.iohk.ethereum.utils.Config.SyncConfig
1515

1616
import scala.concurrent.ExecutionContext.Implicits.global

src/main/scala/io/iohk/ethereum/blockchain/sync/fast/PivotBlockSelector.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import io.iohk.ethereum.network.PeerEventBusActor.PeerEvent.MessageFromPeer
1414
import io.iohk.ethereum.network.PeerEventBusActor.SubscriptionClassifier.MessageClassifier
1515
import io.iohk.ethereum.network.PeerEventBusActor.{PeerSelector, Subscribe, Unsubscribe}
1616
import io.iohk.ethereum.network.p2p.messages.Codes
17-
import io.iohk.ethereum.network.p2p.messages.PV62.{BlockHeaders, GetBlockHeaders}
17+
import io.iohk.ethereum.network.p2p.messages.ETH62.{BlockHeaders, GetBlockHeaders}
1818
import io.iohk.ethereum.network.{EtcPeerManagerActor, Peer, PeerId}
1919
import io.iohk.ethereum.utils.Config.SyncConfig
2020

src/main/scala/io/iohk/ethereum/blockchain/sync/fast/SyncStateScheduler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import io.iohk.ethereum.blockchain.sync.fast.LoadableBloomFilter.BloomFilterLoad
88
import io.iohk.ethereum.blockchain.sync.fast.SyncStateScheduler._
99
import io.iohk.ethereum.domain.{Account, Blockchain}
1010
import io.iohk.ethereum.mpt.{BranchNode, ExtensionNode, HashNode, LeafNode, MerklePatriciaTrie, MptNode}
11-
import io.iohk.ethereum.network.p2p.messages.PV63.MptNodeEncoders.MptNodeDec
11+
import io.iohk.ethereum.network.p2p.messages.ETH63.MptNodeEncoders.MptNodeDec
1212
import io.vavr.collection.PriorityQueue
1313
import monix.eval.Task
1414

src/main/scala/io/iohk/ethereum/blockchain/sync/fast/SyncStateSchedulerActor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import io.iohk.ethereum.blockchain.sync.fast.SyncStateSchedulerActor._
1919
import io.iohk.ethereum.blockchain.sync.{Blacklist, PeerListSupportNg, PeerRequestHandler}
2020
import io.iohk.ethereum.network.Peer
2121
import io.iohk.ethereum.network.p2p.messages.Codes
22-
import io.iohk.ethereum.network.p2p.messages.PV63.{GetNodeData, NodeData}
22+
import io.iohk.ethereum.network.p2p.messages.ETH63.{GetNodeData, NodeData}
2323
import io.iohk.ethereum.utils.ByteStringUtils
2424
import io.iohk.ethereum.utils.Config.SyncConfig
2525
import monix.eval.Task

src/main/scala/io/iohk/ethereum/blockchain/sync/regular/BlockBroadcast.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import io.iohk.ethereum.blockchain.sync.regular.BlockBroadcast.BlockToBroadcast
66
import io.iohk.ethereum.domain.{Block, ChainWeight}
77
import io.iohk.ethereum.network.EtcPeerManagerActor.PeerInfo
88
import io.iohk.ethereum.network.p2p.MessageSerializable
9-
import io.iohk.ethereum.network.p2p.messages.PV62.BlockHash
10-
import io.iohk.ethereum.network.p2p.messages.{CommonMessages, PV62, PV64, ProtocolVersions}
9+
import io.iohk.ethereum.network.p2p.messages.ETH62.BlockHash
10+
import io.iohk.ethereum.network.p2p.messages.{BaseETH6XMessages, ETH62, ETC64, ProtocolVersions}
1111
import io.iohk.ethereum.network.{EtcPeerManagerActor, Peer, PeerId}
1212

1313
import scala.util.Random
@@ -40,15 +40,16 @@ class BlockBroadcast(val etcPeerManager: ActorRef) {
4040
private def broadcastNewBlock(blockToBroadcast: BlockToBroadcast, peers: Map[PeerId, PeerWithInfo]): Unit =
4141
obtainRandomPeerSubset(peers.values.map(_.peer).toSet).foreach { peer =>
4242
val message: MessageSerializable =
43-
if (peers(peer.id).peerInfo.remoteStatus.protocolVersion == ProtocolVersions.PV64) blockToBroadcast.as64
43+
if (peers(peer.id).peerInfo.remoteStatus.protocolVersion.toByte == ProtocolVersions.ETC64.version)
44+
blockToBroadcast.as64
4445
else blockToBroadcast.as63
4546
etcPeerManager ! EtcPeerManagerActor.SendMessage(message, peer.id)
4647
}
4748

4849
private def broadcastNewBlockHash(blockToBroadcast: BlockToBroadcast, peers: Set[Peer]): Unit = peers.foreach {
4950
peer =>
5051
val newBlockHeader = blockToBroadcast.block.header
51-
val newBlockHashMsg = PV62.NewBlockHashes(Seq(BlockHash(newBlockHeader.hash, newBlockHeader.number)))
52+
val newBlockHashMsg = ETH62.NewBlockHashes(Seq(BlockHash(newBlockHeader.hash, newBlockHeader.number)))
5253
etcPeerManager ! EtcPeerManagerActor.SendMessage(newBlockHashMsg, peer.id)
5354
}
5455

@@ -72,7 +73,7 @@ object BlockBroadcast {
7273
* (they are different versions of NewBlock msg)
7374
*/
7475
case class BlockToBroadcast(block: Block, chainWeight: ChainWeight) {
75-
def as63: CommonMessages.NewBlock = CommonMessages.NewBlock(block, chainWeight.totalDifficulty)
76-
def as64: PV64.NewBlock = PV64.NewBlock(block, chainWeight)
76+
def as63: BaseETH6XMessages.NewBlock = BaseETH6XMessages.NewBlock(block, chainWeight.totalDifficulty)
77+
def as64: ETC64.NewBlock = ETC64.NewBlock(block, chainWeight)
7778
}
7879
}

src/main/scala/io/iohk/ethereum/blockchain/sync/regular/BlockFetcher.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ import io.iohk.ethereum.network.PeerEventBusActor.SubscriptionClassifier.Message
2323
import io.iohk.ethereum.network.PeerEventBusActor.{PeerSelector, Subscribe}
2424
import io.iohk.ethereum.network.{Peer, PeerEventBusActor, PeerId}
2525
import io.iohk.ethereum.network.p2p.Message
26-
import io.iohk.ethereum.network.p2p.messages.{Codes, CommonMessages, PV64}
27-
import io.iohk.ethereum.network.p2p.messages.PV62._
28-
import io.iohk.ethereum.network.p2p.messages.PV63.NodeData
26+
import io.iohk.ethereum.network.p2p.messages.{Codes, BaseETH6XMessages, ETC64}
27+
import io.iohk.ethereum.network.p2p.messages.ETH62._
28+
import io.iohk.ethereum.network.p2p.messages.ETH63.NodeData
2929
import io.iohk.ethereum.utils.ByteStringUtils
3030
import io.iohk.ethereum.utils.Config.SyncConfig
3131
import io.iohk.ethereum.utils.FunctorOps._
@@ -214,10 +214,10 @@ class BlockFetcher(
214214
supervisor ! ProgressProtocol.GotNewBlock(newState.knownTop)
215215
fetchBlocks(newState)
216216

217-
case AdaptedMessageFromEventBus(CommonMessages.NewBlock(block, _), peerId) =>
217+
case AdaptedMessageFromEventBus(BaseETH6XMessages.NewBlock(block, _), peerId) =>
218218
handleNewBlock(block, peerId, state)
219219

220-
case AdaptedMessageFromEventBus(PV64.NewBlock(block, _), peerId) =>
220+
case AdaptedMessageFromEventBus(ETC64.NewBlock(block, _), peerId) =>
221221
handleNewBlock(block, peerId, state)
222222

223223
case BlockImportFailed(blockNr, reason) =>

src/main/scala/io/iohk/ethereum/blockchain/sync/regular/BlockFetcherState.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import io.iohk.ethereum.blockchain.sync.regular.BlockFetcherState._
99
import io.iohk.ethereum.consensus.validators.BlockValidator
1010
import io.iohk.ethereum.domain.{Block, BlockBody, BlockHeader, HeadersSeq}
1111
import io.iohk.ethereum.network.PeerId
12-
import io.iohk.ethereum.network.p2p.messages.PV62.BlockHash
12+
import io.iohk.ethereum.network.p2p.messages.ETH62.BlockHash
1313

1414
import scala.annotation.tailrec
1515
import scala.collection.immutable.Queue

0 commit comments

Comments
 (0)