Skip to content

Commit e223485

Browse files
author
Michał Mrożek
authored
Merge pull request #651 from input-output-hk/etcm-41-istanbul-config
[ETCM-41] Add Istanbul fork configuration
2 parents 845350b + 1ebce1d commit e223485

File tree

20 files changed

+39
-4
lines changed

20 files changed

+39
-4
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ trait BlockchainTestConfig extends BlockchainConfig {
1919
val eip161BlockNumber: BigInt = Long.MaxValue
2020
val byzantiumBlockNumber: BigInt = Long.MaxValue
2121
val constantinopleBlockNumber: BigInt = Long.MaxValue
22+
val istanbulBlockNumber: BigInt = Long.MaxValue
2223
// unused
2324
override val maxCodeSize: Option[BigInt] = None
2425
override val difficultyBombPauseBlockNumber: BigInt = 3000000

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

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class ECIP1017Test extends FlatSpec with Matchers {
3232
override val eip161BlockNumber: BigInt = Long.MaxValue
3333
override val byzantiumBlockNumber: BigInt = Long.MaxValue
3434
override val constantinopleBlockNumber: BigInt = Long.MaxValue
35+
override val istanbulBlockNumber: BigInt = Long.MaxValue
3536
override val customGenesisFileOpt: Option[String] = None
3637
override val daoForkConfig: Option[DaoForkConfig] = None
3738
override val difficultyBombPauseBlockNumber: BigInt = Long.MaxValue

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

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class ForksTest extends FlatSpec with Matchers {
3535
override val difficultyBombRemovalBlockNumber: BigInt = Long.MaxValue
3636
override val byzantiumBlockNumber: BigInt = Long.MaxValue
3737
override val constantinopleBlockNumber: BigInt = Long.MaxValue
38+
override val istanbulBlockNumber: BigInt = Long.MaxValue
3839
override val accountStartNonce: UInt256 = UInt256.Zero
3940
override val daoForkConfig: Option[DaoForkConfig] = None
4041
override val gasTieBreaker: Boolean = false

src/main/resources/chains/base.conf

+4
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@
7474
# https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1716.md
7575
petersburg-block-number = "1000000000000000000"
7676

77+
# Istanbul fork block number (ETH only)
78+
# https://eips.ethereum.org/EIPS/eip-1679
79+
istanbul-block-number = "1000000000000000000"
80+
7781
# DAO fork configuration (Ethereum HF/Classic split)
7882
# https://blog.ethereum.org/2016/07/20/hard-fork-completed/
7983
dao {

src/main/resources/chains/eth.conf

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
# https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1716.md
4242
petersburg-block-number = "7280000"
4343

44+
# Istanbul fork block number (ETH only)
45+
# https://eips.ethereum.org/EIPS/eip-1679
46+
istanbul-block-number = "9069000"
47+
4448
monetary-policy {
4549

4650
# Setting era-duration for eth and ropsten chain to big number is necessery to ensure

src/main/scala/io/iohk/ethereum/extvm/VMServer.scala

+1
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ class VMServer(messageHandler: MessageHandler)
184184
eip161BlockNumber = conf.eip161BlockNumber,
185185
byzantiumBlockNumber = BigInt(4370000), //TODO include byzantium block number in protobuf
186186
constantinopleBlockNumber = BigInt(10000000), //TODO include constantinople block number in protobuf
187+
istanbulBlockNumber = BigInt(10000000), //TODO include istanbul block number in protobuf
187188
maxCodeSize = if (conf.maxCodeSize.isEmpty) None else Some(bigintFromGByteString(conf.maxCodeSize)),
188189
accountStartNonce = conf.accountStartNonce,
189190
atlantisBlockNumber = BigInt(8772000), //TODO include atlantis block number in protobuf

src/main/scala/io/iohk/ethereum/jsonrpc/TestService.scala

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class TestService(
7373
override val eip161BlockNumber: BigInt = testLedgerWrapper.blockchainConfig.eip161BlockNumber
7474
override val byzantiumBlockNumber: BigInt = testLedgerWrapper.blockchainConfig.byzantiumBlockNumber
7575
override val constantinopleBlockNumber: BigInt = testLedgerWrapper.blockchainConfig.constantinopleBlockNumber
76+
override val istanbulBlockNumber: BigInt = testLedgerWrapper.blockchainConfig.istanbulBlockNumber
7677
override val maxCodeSize: Option[BigInt] = testLedgerWrapper.blockchainConfig.maxCodeSize
7778
override val difficultyBombPauseBlockNumber: BigInt = testLedgerWrapper.blockchainConfig.difficultyBombPauseBlockNumber
7879
override val difficultyBombContinueBlockNumber: BigInt = testLedgerWrapper.blockchainConfig.difficultyBombContinueBlockNumber

src/main/scala/io/iohk/ethereum/utils/Config.scala

+2
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ trait BlockchainConfig {
348348
val eip161BlockNumber: BigInt
349349
val byzantiumBlockNumber: BigInt
350350
val constantinopleBlockNumber: BigInt
351+
val istanbulBlockNumber: BigInt
351352
val maxCodeSize: Option[BigInt]
352353
val difficultyBombPauseBlockNumber: BigInt
353354
val difficultyBombContinueBlockNumber: BigInt
@@ -389,6 +390,7 @@ object BlockchainConfig {
389390
override val eip161BlockNumber: BigInt = BigInt(blockchainConfig.getString("eip161-block-number"))
390391
override val byzantiumBlockNumber: BigInt = BigInt(blockchainConfig.getString("byzantium-block-number"))
391392
override val constantinopleBlockNumber: BigInt = BigInt(blockchainConfig.getString("constantinople-block-number"))
393+
override val istanbulBlockNumber: BigInt = BigInt(blockchainConfig.getString("istanbul-block-number"))
392394
override val maxCodeSize: Option[BigInt] = Try(BigInt(blockchainConfig.getString("max-code-size"))).toOption
393395
override val difficultyBombPauseBlockNumber: BigInt = BigInt(blockchainConfig.getString("difficulty-bomb-pause-block-number"))
394396
override val difficultyBombContinueBlockNumber: BigInt = BigInt(blockchainConfig.getString("difficulty-bomb-continue-block-number"))

src/main/scala/io/iohk/ethereum/vm/BlockchainConfigForEvm.scala

+8-3
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,27 @@ package io.iohk.ethereum.vm
33
import io.iohk.ethereum.domain.UInt256
44
import io.iohk.ethereum.utils.BlockchainConfig
55
import io.iohk.ethereum.vm.BlockchainConfigForEvm.EtcForks.{Agharta, Atlantis, BeforeAtlantis, EtcFork, Phoenix}
6-
import io.iohk.ethereum.vm.BlockchainConfigForEvm.EthForks.{BeforeByzantium, Byzantium, Constantinople, Petersburg}
6+
import io.iohk.ethereum.vm.BlockchainConfigForEvm.EthForks.{BeforeByzantium, Byzantium, Constantinople, Istanbul, Petersburg}
77

88
/**
99
* A subset of [[io.iohk.ethereum.utils.BlockchainConfig]] that is required for instantiating an [[EvmConfig]]
1010
* Note that `accountStartNonce` is required for a [[WorldStateProxy]] implementation that is used
1111
* by a given VM
1212
*/
13+
// FIXME manage etc/eth forks in a more sophisticated way
1314
case class BlockchainConfigForEvm(
15+
// ETH forks
1416
frontierBlockNumber: BigInt,
1517
homesteadBlockNumber: BigInt,
1618
eip150BlockNumber: BigInt,
1719
eip160BlockNumber: BigInt,
1820
eip161BlockNumber: BigInt,
1921
byzantiumBlockNumber: BigInt,
2022
constantinopleBlockNumber: BigInt,
23+
istanbulBlockNumber: BigInt,
2124
maxCodeSize: Option[BigInt],
2225
accountStartNonce: UInt256,
26+
// ETC forks
2327
atlantisBlockNumber: BigInt,
2428
aghartaBlockNumber: BigInt,
2529
petersburgBlockNumber: BigInt,
@@ -37,8 +41,8 @@ case class BlockchainConfigForEvm(
3741
case _ if blockNumber < byzantiumBlockNumber => BeforeByzantium
3842
case _ if blockNumber < constantinopleBlockNumber => Byzantium
3943
case _ if blockNumber < petersburgBlockNumber => Constantinople
40-
case _ if blockNumber >= petersburgBlockNumber => Petersburg
41-
// TODO add Istanbul
44+
case _ if blockNumber < istanbulBlockNumber => Petersburg
45+
case _ if blockNumber >= istanbulBlockNumber => Istanbul
4246
}
4347
}
4448

@@ -65,6 +69,7 @@ object BlockchainConfigForEvm {
6569
eip161BlockNumber = eip161BlockNumber,
6670
byzantiumBlockNumber = byzantiumBlockNumber,
6771
constantinopleBlockNumber = constantinopleBlockNumber,
72+
istanbulBlockNumber = istanbulBlockNumber,
6873
maxCodeSize = maxCodeSize,
6974
accountStartNonce = accountStartNonce,
7075
atlantisBlockNumber = atlantisBlockNumber,

src/main/scala/io/iohk/ethereum/vm/EvmConfig.scala

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ object EvmConfig {
3636
blockchainConfig.eip161BlockNumber -> PostEIP161ConfigBuilder,
3737
blockchainConfig.byzantiumBlockNumber -> ByzantiumConfigBuilder,
3838
blockchainConfig.constantinopleBlockNumber -> ConstantinopleConfigBuilder,
39+
blockchainConfig.istanbulBlockNumber -> IstanbulConfigBuilder,
3940
blockchainConfig.atlantisBlockNumber -> AtlantisConfigBuilder,
4041
blockchainConfig.aghartaBlockNumber -> AghartaConfigBuilder,
4142
blockchainConfig.petersburgBlockNumber -> PetersburgConfigBuilder,
@@ -99,6 +100,8 @@ object EvmConfig {
99100

100101
val PetersburgConfigBuilder: EvmConfigBuilder = config => ConstantinopleConfigBuilder(config)
101102

103+
val IstanbulConfigBuilder: EvmConfigBuilder = config => PhoenixConfigBuilder(config)
104+
102105
// Ethereum classic forks only
103106
val AtlantisConfigBuilder: EvmConfigBuilder = config => PostEIP160ConfigBuilder(config).copy(
104107
feeSchedule = new FeeSchedule.AtlantisFeeSchedule,

src/test/scala/io/iohk/ethereum/consensus/BlockGeneratorSpec.scala

+2
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ class BlockGeneratorSpec extends FlatSpec with Matchers with PropertyChecks with
150150
override val eip106BlockNumber: BigInt = Long.MaxValue
151151
override val byzantiumBlockNumber: BigInt = Long.MaxValue
152152
override val constantinopleBlockNumber: BigInt = Long.MaxValue
153+
override val istanbulBlockNumber: BigInt = Long.MaxValue
153154
override val chainId: Byte = 0x3d.toByte
154155
override val networkId: Int = 1
155156
override val customGenesisFileOpt: Option[String] = Some("test-genesis.json")
@@ -321,6 +322,7 @@ class BlockGeneratorSpec extends FlatSpec with Matchers with PropertyChecks with
321322
override val eip106BlockNumber: BigInt = Long.MaxValue
322323
override val byzantiumBlockNumber: BigInt = Long.MaxValue
323324
override val constantinopleBlockNumber: BigInt = Long.MaxValue
325+
override val istanbulBlockNumber: BigInt = Long.MaxValue
324326
override val chainId: Byte = 0x3d.toByte
325327
override val customGenesisFileOpt: Option[String] = Some("test-genesis.json")
326328
override val monetaryPolicyConfig: MonetaryPolicyConfig =

src/test/scala/io/iohk/ethereum/consensus/validators/BlockHeaderValidatorSpec.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,8 @@ class BlockHeaderValidatorSpec
358358
override val difficultyBombContinueBlockNumber: BigInt = 5000000
359359
override val difficultyBombRemovalBlockNumber: BigInt = 5900000
360360
override val byzantiumBlockNumber: BigInt = 4370000
361-
override val constantinopleBlockNumber: BigInt = 10000000 //todo
361+
override val constantinopleBlockNumber: BigInt = 7280000
362+
override val istanbulBlockNumber: BigInt = 9069000
362363

363364
override val daoForkConfig: Option[DaoForkConfig] = Some(new DaoForkConfig {
364365
override val blockExtraData: Option[ByteString] = if(supportsDaoFork) Some(ProDaoForkBlock.header.extraData) else None

src/test/scala/io/iohk/ethereum/extvm/VMClientSpec.scala

+1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ class VMClientSpec extends FlatSpec with Matchers with MockFactory {
173173
eip161BlockNumber = 0,
174174
byzantiumBlockNumber = 0,
175175
constantinopleBlockNumber = 0,
176+
istanbulBlockNumber = 0,
176177
maxCodeSize = None,
177178
accountStartNonce = 0,
178179
atlantisBlockNumber = 0,

src/test/scala/io/iohk/ethereum/jsonrpc/EthServiceSpec.scala

+1
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,7 @@ class EthServiceSpec extends FlatSpec with Matchers with ScalaFutures with MockF
884884
override val eip106BlockNumber: BigInt = 0
885885
override val byzantiumBlockNumber: BigInt = 0
886886
override val constantinopleBlockNumber: BigInt = 0
887+
override val istanbulBlockNumber: BigInt = 0
887888
override val difficultyBombPauseBlockNumber: BigInt = 0
888889
override val difficultyBombContinueBlockNumber: BigInt = 0
889890
override val difficultyBombRemovalBlockNumber: BigInt = 0

src/test/scala/io/iohk/ethereum/jsonrpc/PersonalServiceSpec.scala

+1
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ class PersonalServiceSpec extends FlatSpec with Matchers with MockFactory with S
431431
override val eip106BlockNumber: BigInt = 0
432432
override val byzantiumBlockNumber: BigInt = 0
433433
override val constantinopleBlockNumber: BigInt = 0
434+
override val istanbulBlockNumber: BigInt = 0
434435
override val difficultyBombPauseBlockNumber: BigInt = 0
435436
override val difficultyBombContinueBlockNumber: BigInt = 0
436437
override val difficultyBombRemovalBlockNumber: BigInt = Long.MaxValue

src/test/scala/io/iohk/ethereum/ledger/LedgerTestSetup.scala

+1
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ trait DaoForkTestSetup extends TestSetup with MockFactory {
201201
override val eip150BlockNumber: BigInt = blockchainConfig.eip150BlockNumber
202202
override val byzantiumBlockNumber: BigInt = blockchainConfig.byzantiumBlockNumber
203203
override val constantinopleBlockNumber: BigInt = blockchainConfig.constantinopleBlockNumber
204+
override val istanbulBlockNumber: BigInt = blockchainConfig.istanbulBlockNumber
204205
override val chainId: Byte = 0x01.toByte
205206
override val networkId: Int = 1
206207
override val difficultyBombContinueBlockNumber: BigInt = blockchainConfig.difficultyBombContinueBlockNumber

src/test/scala/io/iohk/ethereum/ledger/StxLedgerSpec.scala

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ trait ScenarioSetup extends EphemBlockchainTestSetup {
114114
override val eip106BlockNumber: BigInt = 0
115115
override val byzantiumBlockNumber: BigInt = 0
116116
override val constantinopleBlockNumber: BigInt = 0
117+
override val istanbulBlockNumber: BigInt = 0
117118
override val difficultyBombPauseBlockNumber: BigInt = 0
118119
override val difficultyBombContinueBlockNumber: BigInt = 0
119120
override val difficultyBombRemovalBlockNumber: BigInt = Long.MaxValue

src/test/scala/io/iohk/ethereum/network/handshaker/EtcHandshakerSpec.scala

+1
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ class EtcHandshakerSpec extends FlatSpec with Matchers {
184184
override val eip106BlockNumber: BigInt = 0
185185
override val byzantiumBlockNumber: BigInt = 0
186186
override val constantinopleBlockNumber: BigInt = 0
187+
override val istanbulBlockNumber: BigInt = 0
187188
override val difficultyBombPauseBlockNumber: BigInt = 0
188189
override val difficultyBombContinueBlockNumber: BigInt = 0
189190
override val difficultyBombRemovalBlockNumber: BigInt = Long.MaxValue

src/test/scala/io/iohk/ethereum/vm/Fixtures.scala

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ object Fixtures {
55
val ConstantinopleBlockNumber = 200
66
val PetersburgBlockNumber = 400
77
val PhoenixBlockNumber = 600
8+
val IstanbulBlockNumber = 600
89

910
val blockchainConfig = BlockchainConfigForEvm(
1011
// block numbers are irrelevant
@@ -15,6 +16,7 @@ object Fixtures {
1516
eip161BlockNumber = 0,
1617
byzantiumBlockNumber = 0,
1718
constantinopleBlockNumber = ConstantinopleBlockNumber,
19+
istanbulBlockNumber = IstanbulBlockNumber,
1820
maxCodeSize = None,
1921
accountStartNonce = 0,
2022
atlantisBlockNumber = 0,

src/test/scala/io/iohk/ethereum/vm/VMSpec.scala

+1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ class VMSpec extends WordSpec with PropertyChecks with Matchers {
153153
eip161BlockNumber = Long.MaxValue,
154154
byzantiumBlockNumber = Long.MaxValue,
155155
constantinopleBlockNumber = Long.MaxValue,
156+
istanbulBlockNumber = Long.MaxValue,
156157
maxCodeSize = Some(16),
157158
accountStartNonce = 0,
158159
atlantisBlockNumber = Long.MaxValue,

0 commit comments

Comments
 (0)