Skip to content

[ETCM-41] Add Istanbul fork configuration #651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ trait BlockchainTestConfig extends BlockchainConfig {
val eip161BlockNumber: BigInt = Long.MaxValue
val byzantiumBlockNumber: BigInt = Long.MaxValue
val constantinopleBlockNumber: BigInt = Long.MaxValue
val istanbulBlockNumber: BigInt = Long.MaxValue
// unused
override val maxCodeSize: Option[BigInt] = None
override val difficultyBombPauseBlockNumber: BigInt = 3000000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class ECIP1017Test extends FlatSpec with Matchers {
override val eip161BlockNumber: BigInt = Long.MaxValue
override val byzantiumBlockNumber: BigInt = Long.MaxValue
override val constantinopleBlockNumber: BigInt = Long.MaxValue
override val istanbulBlockNumber: BigInt = Long.MaxValue
override val customGenesisFileOpt: Option[String] = None
override val daoForkConfig: Option[DaoForkConfig] = None
override val difficultyBombPauseBlockNumber: BigInt = Long.MaxValue
Expand Down
1 change: 1 addition & 0 deletions src/it/scala/io/iohk/ethereum/txExecTest/ForksTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ForksTest extends FlatSpec with Matchers {
override val difficultyBombRemovalBlockNumber: BigInt = Long.MaxValue
override val byzantiumBlockNumber: BigInt = Long.MaxValue
override val constantinopleBlockNumber: BigInt = Long.MaxValue
override val istanbulBlockNumber: BigInt = Long.MaxValue
override val accountStartNonce: UInt256 = UInt256.Zero
override val daoForkConfig: Option[DaoForkConfig] = None
override val gasTieBreaker: Boolean = false
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/chains/base.conf
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
# https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1716.md
petersburg-block-number = "1000000000000000000"

# Istanbul fork block number (ETH only)
# https://eips.ethereum.org/EIPS/eip-1679
istanbul-block-number = "1000000000000000000"

# DAO fork configuration (Ethereum HF/Classic split)
# https://blog.ethereum.org/2016/07/20/hard-fork-completed/
dao {
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/chains/eth.conf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
# https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1716.md
petersburg-block-number = "7280000"

# Istanbul fork block number (ETH only)
# https://eips.ethereum.org/EIPS/eip-1679
istanbul-block-number = "9069000"

monetary-policy {

# Setting era-duration for eth and ropsten chain to big number is necessery to ensure
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/io/iohk/ethereum/extvm/VMServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ class VMServer(messageHandler: MessageHandler)
eip161BlockNumber = conf.eip161BlockNumber,
byzantiumBlockNumber = BigInt(4370000), //TODO include byzantium block number in protobuf
constantinopleBlockNumber = BigInt(10000000), //TODO include constantinople block number in protobuf
istanbulBlockNumber = BigInt(10000000), //TODO include istanbul block number in protobuf
maxCodeSize = if (conf.maxCodeSize.isEmpty) None else Some(bigintFromGByteString(conf.maxCodeSize)),
accountStartNonce = conf.accountStartNonce,
atlantisBlockNumber = BigInt(8772000), //TODO include atlantis block number in protobuf
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/io/iohk/ethereum/jsonrpc/TestService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class TestService(
override val eip161BlockNumber: BigInt = testLedgerWrapper.blockchainConfig.eip161BlockNumber
override val byzantiumBlockNumber: BigInt = testLedgerWrapper.blockchainConfig.byzantiumBlockNumber
override val constantinopleBlockNumber: BigInt = testLedgerWrapper.blockchainConfig.constantinopleBlockNumber
override val istanbulBlockNumber: BigInt = testLedgerWrapper.blockchainConfig.istanbulBlockNumber
override val maxCodeSize: Option[BigInt] = testLedgerWrapper.blockchainConfig.maxCodeSize
override val difficultyBombPauseBlockNumber: BigInt = testLedgerWrapper.blockchainConfig.difficultyBombPauseBlockNumber
override val difficultyBombContinueBlockNumber: BigInt = testLedgerWrapper.blockchainConfig.difficultyBombContinueBlockNumber
Expand Down
2 changes: 2 additions & 0 deletions src/main/scala/io/iohk/ethereum/utils/Config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ trait BlockchainConfig {
val eip161BlockNumber: BigInt
val byzantiumBlockNumber: BigInt
val constantinopleBlockNumber: BigInt
val istanbulBlockNumber: BigInt
val maxCodeSize: Option[BigInt]
val difficultyBombPauseBlockNumber: BigInt
val difficultyBombContinueBlockNumber: BigInt
Expand Down Expand Up @@ -389,6 +390,7 @@ object BlockchainConfig {
override val eip161BlockNumber: BigInt = BigInt(blockchainConfig.getString("eip161-block-number"))
override val byzantiumBlockNumber: BigInt = BigInt(blockchainConfig.getString("byzantium-block-number"))
override val constantinopleBlockNumber: BigInt = BigInt(blockchainConfig.getString("constantinople-block-number"))
override val istanbulBlockNumber: BigInt = BigInt(blockchainConfig.getString("istanbul-block-number"))
override val maxCodeSize: Option[BigInt] = Try(BigInt(blockchainConfig.getString("max-code-size"))).toOption
override val difficultyBombPauseBlockNumber: BigInt = BigInt(blockchainConfig.getString("difficulty-bomb-pause-block-number"))
override val difficultyBombContinueBlockNumber: BigInt = BigInt(blockchainConfig.getString("difficulty-bomb-continue-block-number"))
Expand Down
11 changes: 8 additions & 3 deletions src/main/scala/io/iohk/ethereum/vm/BlockchainConfigForEvm.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,27 @@ package io.iohk.ethereum.vm
import io.iohk.ethereum.domain.UInt256
import io.iohk.ethereum.utils.BlockchainConfig
import io.iohk.ethereum.vm.BlockchainConfigForEvm.EtcForks.{Agharta, Atlantis, BeforeAtlantis, EtcFork, Phoenix}
import io.iohk.ethereum.vm.BlockchainConfigForEvm.EthForks.{BeforeByzantium, Byzantium, Constantinople, Petersburg}
import io.iohk.ethereum.vm.BlockchainConfigForEvm.EthForks.{BeforeByzantium, Byzantium, Constantinople, Istanbul, Petersburg}

/**
* A subset of [[io.iohk.ethereum.utils.BlockchainConfig]] that is required for instantiating an [[EvmConfig]]
* Note that `accountStartNonce` is required for a [[WorldStateProxy]] implementation that is used
* by a given VM
*/
// FIXME manage etc/eth forks in a more sophisticated way
case class BlockchainConfigForEvm(
// ETH forks
frontierBlockNumber: BigInt,
homesteadBlockNumber: BigInt,
eip150BlockNumber: BigInt,
eip160BlockNumber: BigInt,
eip161BlockNumber: BigInt,
byzantiumBlockNumber: BigInt,
constantinopleBlockNumber: BigInt,
istanbulBlockNumber: BigInt,
maxCodeSize: Option[BigInt],
accountStartNonce: UInt256,
// ETC forks
atlantisBlockNumber: BigInt,
aghartaBlockNumber: BigInt,
petersburgBlockNumber: BigInt,
Expand All @@ -37,8 +41,8 @@ case class BlockchainConfigForEvm(
case _ if blockNumber < byzantiumBlockNumber => BeforeByzantium
case _ if blockNumber < constantinopleBlockNumber => Byzantium
case _ if blockNumber < petersburgBlockNumber => Constantinople
case _ if blockNumber >= petersburgBlockNumber => Petersburg
// TODO add Istanbul
case _ if blockNumber < istanbulBlockNumber => Petersburg
case _ if blockNumber >= istanbulBlockNumber => Istanbul
}
}

Expand All @@ -65,6 +69,7 @@ object BlockchainConfigForEvm {
eip161BlockNumber = eip161BlockNumber,
byzantiumBlockNumber = byzantiumBlockNumber,
constantinopleBlockNumber = constantinopleBlockNumber,
istanbulBlockNumber = istanbulBlockNumber,
maxCodeSize = maxCodeSize,
accountStartNonce = accountStartNonce,
atlantisBlockNumber = atlantisBlockNumber,
Expand Down
3 changes: 3 additions & 0 deletions src/main/scala/io/iohk/ethereum/vm/EvmConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ object EvmConfig {
blockchainConfig.eip161BlockNumber -> PostEIP161ConfigBuilder,
blockchainConfig.byzantiumBlockNumber -> ByzantiumConfigBuilder,
blockchainConfig.constantinopleBlockNumber -> ConstantinopleConfigBuilder,
blockchainConfig.istanbulBlockNumber -> IstanbulConfigBuilder,
blockchainConfig.atlantisBlockNumber -> AtlantisConfigBuilder,
blockchainConfig.aghartaBlockNumber -> AghartaConfigBuilder,
blockchainConfig.petersburgBlockNumber -> PetersburgConfigBuilder,
Expand Down Expand Up @@ -99,6 +100,8 @@ object EvmConfig {

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

val IstanbulConfigBuilder: EvmConfigBuilder = config => PhoenixConfigBuilder(config)

// Ethereum classic forks only
val AtlantisConfigBuilder: EvmConfigBuilder = config => PostEIP160ConfigBuilder(config).copy(
feeSchedule = new FeeSchedule.AtlantisFeeSchedule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class BlockGeneratorSpec extends FlatSpec with Matchers with PropertyChecks with
override val eip106BlockNumber: BigInt = Long.MaxValue
override val byzantiumBlockNumber: BigInt = Long.MaxValue
override val constantinopleBlockNumber: BigInt = Long.MaxValue
override val istanbulBlockNumber: BigInt = Long.MaxValue
override val chainId: Byte = 0x3d.toByte
override val networkId: Int = 1
override val customGenesisFileOpt: Option[String] = Some("test-genesis.json")
Expand Down Expand Up @@ -321,6 +322,7 @@ class BlockGeneratorSpec extends FlatSpec with Matchers with PropertyChecks with
override val eip106BlockNumber: BigInt = Long.MaxValue
override val byzantiumBlockNumber: BigInt = Long.MaxValue
override val constantinopleBlockNumber: BigInt = Long.MaxValue
override val istanbulBlockNumber: BigInt = Long.MaxValue
override val chainId: Byte = 0x3d.toByte
override val customGenesisFileOpt: Option[String] = Some("test-genesis.json")
override val monetaryPolicyConfig: MonetaryPolicyConfig =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@ class BlockHeaderValidatorSpec
override val difficultyBombContinueBlockNumber: BigInt = 5000000
override val difficultyBombRemovalBlockNumber: BigInt = 5900000
override val byzantiumBlockNumber: BigInt = 4370000
override val constantinopleBlockNumber: BigInt = 10000000 //todo
override val constantinopleBlockNumber: BigInt = 7280000
override val istanbulBlockNumber: BigInt = 9069000

override val daoForkConfig: Option[DaoForkConfig] = Some(new DaoForkConfig {
override val blockExtraData: Option[ByteString] = if(supportsDaoFork) Some(ProDaoForkBlock.header.extraData) else None
Expand Down
1 change: 1 addition & 0 deletions src/test/scala/io/iohk/ethereum/extvm/VMClientSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ class VMClientSpec extends FlatSpec with Matchers with MockFactory {
eip161BlockNumber = 0,
byzantiumBlockNumber = 0,
constantinopleBlockNumber = 0,
istanbulBlockNumber = 0,
maxCodeSize = None,
accountStartNonce = 0,
atlantisBlockNumber = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,7 @@ class EthServiceSpec extends FlatSpec with Matchers with ScalaFutures with MockF
override val eip106BlockNumber: BigInt = 0
override val byzantiumBlockNumber: BigInt = 0
override val constantinopleBlockNumber: BigInt = 0
override val istanbulBlockNumber: BigInt = 0
override val difficultyBombPauseBlockNumber: BigInt = 0
override val difficultyBombContinueBlockNumber: BigInt = 0
override val difficultyBombRemovalBlockNumber: BigInt = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ class PersonalServiceSpec extends FlatSpec with Matchers with MockFactory with S
override val eip106BlockNumber: BigInt = 0
override val byzantiumBlockNumber: BigInt = 0
override val constantinopleBlockNumber: BigInt = 0
override val istanbulBlockNumber: BigInt = 0
override val difficultyBombPauseBlockNumber: BigInt = 0
override val difficultyBombContinueBlockNumber: BigInt = 0
override val difficultyBombRemovalBlockNumber: BigInt = Long.MaxValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ trait DaoForkTestSetup extends TestSetup with MockFactory {
override val eip150BlockNumber: BigInt = blockchainConfig.eip150BlockNumber
override val byzantiumBlockNumber: BigInt = blockchainConfig.byzantiumBlockNumber
override val constantinopleBlockNumber: BigInt = blockchainConfig.constantinopleBlockNumber
override val istanbulBlockNumber: BigInt = blockchainConfig.istanbulBlockNumber
override val chainId: Byte = 0x01.toByte
override val networkId: Int = 1
override val difficultyBombContinueBlockNumber: BigInt = blockchainConfig.difficultyBombContinueBlockNumber
Expand Down
1 change: 1 addition & 0 deletions src/test/scala/io/iohk/ethereum/ledger/StxLedgerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ trait ScenarioSetup extends EphemBlockchainTestSetup {
override val eip106BlockNumber: BigInt = 0
override val byzantiumBlockNumber: BigInt = 0
override val constantinopleBlockNumber: BigInt = 0
override val istanbulBlockNumber: BigInt = 0
override val difficultyBombPauseBlockNumber: BigInt = 0
override val difficultyBombContinueBlockNumber: BigInt = 0
override val difficultyBombRemovalBlockNumber: BigInt = Long.MaxValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ class EtcHandshakerSpec extends FlatSpec with Matchers {
override val eip106BlockNumber: BigInt = 0
override val byzantiumBlockNumber: BigInt = 0
override val constantinopleBlockNumber: BigInt = 0
override val istanbulBlockNumber: BigInt = 0
override val difficultyBombPauseBlockNumber: BigInt = 0
override val difficultyBombContinueBlockNumber: BigInt = 0
override val difficultyBombRemovalBlockNumber: BigInt = Long.MaxValue
Expand Down
2 changes: 2 additions & 0 deletions src/test/scala/io/iohk/ethereum/vm/Fixtures.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ object Fixtures {
val ConstantinopleBlockNumber = 200
val PetersburgBlockNumber = 400
val PhoenixBlockNumber = 600
val IstanbulBlockNumber = 600

val blockchainConfig = BlockchainConfigForEvm(
// block numbers are irrelevant
Expand All @@ -15,6 +16,7 @@ object Fixtures {
eip161BlockNumber = 0,
byzantiumBlockNumber = 0,
constantinopleBlockNumber = ConstantinopleBlockNumber,
istanbulBlockNumber = IstanbulBlockNumber,
maxCodeSize = None,
accountStartNonce = 0,
atlantisBlockNumber = 0,
Expand Down
1 change: 1 addition & 0 deletions src/test/scala/io/iohk/ethereum/vm/VMSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class VMSpec extends WordSpec with PropertyChecks with Matchers {
eip161BlockNumber = Long.MaxValue,
byzantiumBlockNumber = Long.MaxValue,
constantinopleBlockNumber = Long.MaxValue,
istanbulBlockNumber = Long.MaxValue,
maxCodeSize = Some(16),
accountStartNonce = 0,
atlantisBlockNumber = Long.MaxValue,
Expand Down