Skip to content

Commit 5f7ea24

Browse files
rtkaczykpslaski
authored andcommitted
etcm-402 added negotiating protocol version in message codec
1 parent 417848a commit 5f7ea24

File tree

67 files changed

+350
-193
lines changed

Some content is hidden

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

67 files changed

+350
-193
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.PV60.SignedTransactions._
88
import io.iohk.ethereum.utils.Logger
99
import org.scalacheck.Gen
1010
import org.bouncycastle.util.encoders.Hex

src/ets/scala/io/iohk/ethereum/ets/blockchain/BlockchainTestConfig.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ object BlockchainTestConfig {
3030
difficultyBombRemovalBlockNumber = 5900000,
3131
chainId = 0x1.toByte,
3232
networkId = 1,
33+
protocolVersion = 63,
3334
customGenesisFileOpt = Some("test-genesis.json"),
3435
monetaryPolicyConfig =
3536
MonetaryPolicyConfig(5000000, 0.2, BigInt("5000000000000000000"), BigInt("3000000000000000000")),

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

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ import akka.actor.{ActorRef, ActorSystem}
77
import akka.testkit.TestProbe
88
import akka.util.{ByteString, Timeout}
99
import io.iohk.ethereum.blockchain.sync.regular.BlockBroadcast.BlockToBroadcast
10-
import io.iohk.ethereum.blockchain.sync.regular.{BlockBroadcast, BlockBroadcasterActor}
1110
import io.iohk.ethereum.blockchain.sync.regular.BlockBroadcasterActor.BroadcastBlock
11+
import io.iohk.ethereum.blockchain.sync.regular.{BlockBroadcast, BlockBroadcasterActor}
1212
import io.iohk.ethereum.blockchain.sync.{BlockchainHostActor, TestSyncConfig}
1313
import io.iohk.ethereum.db.components.{RocksDbDataSourceComponent, Storages}
1414
import io.iohk.ethereum.db.dataSource.{RocksDbConfig, RocksDbDataSource}
1515
import io.iohk.ethereum.db.storage.pruning.{ArchivePruning, PruningMode}
1616
import io.iohk.ethereum.db.storage.{AppStateStorage, Namespaces}
1717
import io.iohk.ethereum.domain.{Block, Blockchain, BlockchainImpl, ChainWeight}
18-
import io.iohk.ethereum.security.SecureRandomBuilder
1918
import io.iohk.ethereum.ledger.InMemoryWorldStateProxy
2019
import io.iohk.ethereum.mpt.MerklePatriciaTrie
2120
import io.iohk.ethereum.network.EtcPeerManagerActor.PeerInfo
@@ -24,17 +23,13 @@ import io.iohk.ethereum.network.discovery.PeerDiscoveryManager.DiscoveredNodesIn
2423
import io.iohk.ethereum.network.discovery.{DiscoveryConfig, Node}
2524
import io.iohk.ethereum.network.handshaker.{EtcHandshaker, EtcHandshakerConfiguration, Handshaker}
2625
import io.iohk.ethereum.network.p2p.EthereumMessageDecoder
26+
import io.iohk.ethereum.network.p2p.Message.Version
27+
import io.iohk.ethereum.network.p2p.messages.ProtocolNegotiator
2728
import io.iohk.ethereum.network.rlpx.AuthHandshaker
2829
import io.iohk.ethereum.network.rlpx.RLPxConnectionHandler.RLPxConfiguration
29-
import io.iohk.ethereum.network.{
30-
EtcPeerManagerActor,
31-
ForkResolver,
32-
KnownNodesManager,
33-
PeerEventBusActor,
34-
PeerManagerActor,
35-
ServerActor
36-
}
30+
import io.iohk.ethereum.network.{EtcPeerManagerActor, ForkResolver, KnownNodesManager, PeerEventBusActor, PeerManagerActor, ServerActor}
3731
import io.iohk.ethereum.nodebuilder.PruningConfigBuilder
32+
import io.iohk.ethereum.security.SecureRandomBuilder
3833
import io.iohk.ethereum.sync.util.SyncCommonItSpec._
3934
import io.iohk.ethereum.sync.util.SyncCommonItSpecUtils._
4035
import io.iohk.ethereum.utils.ServerStatus.Listening
@@ -160,10 +155,12 @@ abstract class CommonFakePeer(peerName: String, fakePeerCustomConfig: FakePeerCu
160155
override val peerConfiguration: PeerConfiguration = peerConf
161156
override val blockchain: Blockchain = bl
162157
override val appStateStorage: AppStateStorage = storagesInstance.storages.appStateStorage
163-
override val protocolVersion: Int = Config.Network.protocolVersion
158+
override val protocolVersion: Version = blockchainConfig.protocolVersion
164159
}
165160

166-
lazy val handshaker: Handshaker[PeerInfo] = EtcHandshaker(handshakerConfiguration)
161+
val protocolNegotiator = new ProtocolNegotiator(handshakerConfiguration.protocolVersion)
162+
163+
lazy val handshaker: Handshaker[PeerInfo] = EtcHandshaker(handshakerConfiguration, protocolNegotiator)
167164

168165
lazy val authHandshaker: AuthHandshaker = AuthHandshaker(nodeKey, secureRandom)
169166

@@ -177,7 +174,7 @@ abstract class CommonFakePeer(peerName: String, fakePeerCustomConfig: FakePeerCu
177174
authHandshaker,
178175
EthereumMessageDecoder,
179176
discoveryConfig,
180-
Config.Network.protocolVersion
177+
protocolNegotiator
181178
),
182179
"peer-manager"
183180
)

src/it/scala/io/iohk/ethereum/txExecTest/ECIP1017Test.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class ECIP1017Test extends AnyFlatSpec with Matchers {
2222
maxCodeSize = None,
2323
chainId = 0x3d.toByte,
2424
networkId = 1,
25+
protocolVersion = 63,
2526
frontierBlockNumber = 0,
2627
homesteadBlockNumber = 1150000,
2728
eip106BlockNumber = Long.MaxValue,

src/it/scala/io/iohk/ethereum/txExecTest/ForksTest.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class ForksTest extends AnyFlatSpec with Matchers {
2727
// unused
2828
bootstrapNodes = Set(),
2929
networkId = 1,
30+
protocolVersion = 63,
3031
maxCodeSize = None,
3132
eip161BlockNumber = Long.MaxValue,
3233
customGenesisFileOpt = None,

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import io.iohk.ethereum.network.PeerManagerActor.PeerConfiguration
2121
import io.iohk.ethereum.network.discovery.DiscoveryConfig
2222
import io.iohk.ethereum.network.handshaker.{EtcHandshaker, EtcHandshakerConfiguration, Handshaker}
2323
import io.iohk.ethereum.network.p2p.EthereumMessageDecoder
24+
import io.iohk.ethereum.network.p2p.Message.Version
25+
import io.iohk.ethereum.network.p2p.messages.ProtocolNegotiator
2426
import io.iohk.ethereum.network.rlpx.RLPxConnectionHandler.RLPxConfiguration
2527
import io.iohk.ethereum.network.{ForkResolver, PeerEventBusActor, PeerManagerActor}
2628
import io.iohk.ethereum.nodebuilder.{AuthHandshakerBuilder, NodeKeyBuilder}
@@ -84,10 +86,12 @@ object DumpChainApp extends App with NodeKeyBuilder with SecureRandomBuilder wit
8486
override val peerConfiguration: PeerConfiguration = peerConfig
8587
override val blockchain: Blockchain = DumpChainApp.blockchain
8688
override val appStateStorage: AppStateStorage = storagesInstance.storages.appStateStorage
87-
override val protocolVersion: Int = Config.Network.protocolVersion
89+
override val protocolVersion: Version = blockchainConfig.protocolVersion
8890
}
8991

90-
lazy val handshaker: Handshaker[PeerInfo] = EtcHandshaker(handshakerConfiguration)
92+
val protocolNegotiator = new ProtocolNegotiator(handshakerConfiguration.protocolVersion)
93+
94+
lazy val handshaker: Handshaker[PeerInfo] = EtcHandshaker(handshakerConfiguration, protocolNegotiator)
9195

9296
val peerMessageBus = actorSystem.actorOf(PeerEventBusActor.props)
9397

@@ -101,7 +105,7 @@ object DumpChainApp extends App with NodeKeyBuilder with SecureRandomBuilder wit
101105
authHandshaker = authHandshaker,
102106
messageDecoder = EthereumMessageDecoder,
103107
discoveryConfig,
104-
Config.Network.protocolVersion
108+
protocolNegotiator
105109
),
106110
"peer-manager"
107111
)

src/main/resources/application.conf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ mantis {
3737
}
3838

3939
network {
40-
# Ethereum protocol version
41-
# Supported versions:
42-
# 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)
43-
protocol-version = 63
44-
4540
server-address {
4641
# Listening interface for Ethereum protocol connections
4742
interface = "0.0.0.0"

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

Lines changed: 5 additions & 0 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+
# Ethereum protocol version
7+
# Supported versions:
8+
# 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)
9+
network.protocol-version = 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

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

Lines changed: 5 additions & 0 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+
# Ethereum protocol version
7+
# Supported versions:
8+
# 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)
9+
network.protocol-version = 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

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

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

6+
# Ethereum protocol version
7+
# Supported versions:
8+
# 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)
9+
network.protocol-version = 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

0 commit comments

Comments
 (0)