Skip to content

Commit

Permalink
[ETCM-1015] Add Magneto block height to configs (#1067)
Browse files Browse the repository at this point in the history
* [ETCM-1015] Add ECIP-1103 block number to configs

* [ETCM-1015] Add ecip1103 to ForkBlockNumbers

* [ETCM-1015] Init empty ForkBlockNumbers

DRY

* [ETCM-1015] Update the ForkIdSpec

* [ETCM-1015] Format all

* [ETCM-1015] Rename magneto fork
  • Loading branch information
lukasz-golebiewski authored Jul 19, 2021
1 parent 1b0ac2b commit ced069a
Show file tree
Hide file tree
Showing 16 changed files with 94 additions and 138 deletions.
3 changes: 2 additions & 1 deletion src/it/scala/io/iohk/ethereum/txExecTest/ECIP1017Test.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class ECIP1017Test extends AnyFlatSpec with Matchers {
ecip1098BlockNumber = Long.MaxValue,
ecip1097BlockNumber = Long.MaxValue,
ecip1099BlockNumber = Long.MaxValue,
ecip1049BlockNumber = None
ecip1049BlockNumber = None,
magnetoBlockNumber = Long.MaxValue
),
customGenesisFileOpt = None,
customGenesisJsonOpt = None,
Expand Down
20 changes: 2 additions & 18 deletions src/it/scala/io/iohk/ethereum/txExecTest/ForksTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,12 @@ class ForksTest extends AnyFlatSpec with Matchers {

trait TestSetup extends ScenarioSetup {
implicit override lazy val blockchainConfig: BlockchainConfig = BlockchainConfig(
forkBlockNumbers = ForkBlockNumbers(
forkBlockNumbers = ForkBlockNumbers.Empty.copy(
frontierBlockNumber = 0,
homesteadBlockNumber = 3,
eip150BlockNumber = 5,
eip160BlockNumber = 7,
eip155BlockNumber = 0,
eip106BlockNumber = Long.MaxValue,
eip161BlockNumber = Long.MaxValue,
difficultyBombPauseBlockNumber = Long.MaxValue,
difficultyBombContinueBlockNumber = Long.MaxValue,
difficultyBombRemovalBlockNumber = Long.MaxValue,
byzantiumBlockNumber = Long.MaxValue,
constantinopleBlockNumber = Long.MaxValue,
istanbulBlockNumber = Long.MaxValue,
atlantisBlockNumber = Long.MaxValue,
aghartaBlockNumber = Long.MaxValue,
phoenixBlockNumber = Long.MaxValue,
petersburgBlockNumber = Long.MaxValue,
ecip1098BlockNumber = Long.MaxValue,
ecip1097BlockNumber = Long.MaxValue,
ecip1099BlockNumber = Long.MaxValue,
ecip1049BlockNumber = None
eip155BlockNumber = 0
),
chainId = 0x3d.toByte,
monetaryPolicyConfig = MonetaryPolicyConfig(5000000, 0.2, 5000000000000000000L, 3000000000000000000L),
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/conf/chains/etc-chain.conf
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@
# https://ecips.ethereumclassic.org/ECIPs/ecip-1099
ecip1099-block-number = "11700000"

# Magneto EVM and Protocol Upgrades
# https://ecips.ethereumclassic.org/ECIPs/ecip-1103
magneto-block-number = "13189133"

# ECIP-1049 soft fork block number
# https://ecips.ethereumclassic.org/ECIPs/ecip-1049
# https://github.com/ethereumclassic/ECIPs/issues/394
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/conf/chains/eth-chain.conf
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@
# https://ecips.ethereumclassic.org/ECIPs/ecip-1099
ecip1099-block-number = "1000000000000000000"

# Magneto EVM and Protocol Upgrades
# https://ecips.ethereumclassic.org/ECIPs/ecip-1103
magneto-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/conf/chains/mordor-chain.conf
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@
# https://ecips.ethereumclassic.org/ECIPs/ecip-1099
ecip1099-block-number = "2520000"

# Magneto EVM and Protocol Upgrades
# https://ecips.ethereumclassic.org/ECIPs/ecip-1103
magneto-block-number = "3985893"

# DAO fork configuration (Ethereum HF/Classic split)
# https://blog.ethereum.org/2016/07/20/hard-fork-completed/
dao = null
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/conf/chains/ropsten-chain.conf
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@
# https://ecips.ethereumclassic.org/ECIPs/ecip-1099
ecip1099-block-number = "1000000000000000000"

# Magneto EVM and Protocol Upgrades
# https://ecips.ethereumclassic.org/ECIPs/ecip-1103
magneto-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/conf/chains/test-chain.conf
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@
# https://ecips.ethereumclassic.org/ECIPs/ecip-1099
ecip1099-block-number = "1000000000000000000"

# Magneto EVM and Protocol Upgrades
# https://ecips.ethereumclassic.org/ECIPs/ecip-1103
magneto-block-number = "1000000000000000000"

# DAO fork configuration (Ethereum HF/Classic split)
# https://blog.ethereum.org/2016/07/20/hard-fork-completed/
dao {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@
# https://ecips.ethereumclassic.org/ECIPs/ecip-1099
ecip1099-block-number = "1000000000000000000"

# Magneto EVM and Protocol Upgrades
# https://ecips.ethereumclassic.org/ECIPs/ecip-1103
magneto-block-number = "1000000000000000000"

# DAO fork configuration (Ethereum HF/Classic split)
# https://blog.ethereum.org/2016/07/20/hard-fork-completed/
dao = null
Expand Down
26 changes: 9 additions & 17 deletions src/main/scala/io/iohk/ethereum/jsonrpc/TestService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -207,35 +207,27 @@ class TestService(
SetChainParamsResponse().rightNow
}

val neverOccuringBlock: Int = Int.MaxValue
val neverOccurringBlock: Int = Int.MaxValue

private def buildNewConfig(blockchainParams: BlockchainParams) = {
val byzantiumBlockNumber: BigInt = blockchainParams.byzantiumForkBlock.getOrElse(neverOccuringBlock)
val istanbulForkBlockNumber: BigInt = blockchainParams.istanbulForkBlock.getOrElse(neverOccuringBlock)
val byzantiumBlockNumber: BigInt = blockchainParams.byzantiumForkBlock.getOrElse(neverOccurringBlock)
val istanbulForkBlockNumber: BigInt = blockchainParams.istanbulForkBlock.getOrElse(neverOccurringBlock)

// For block number which are not specified by retesteth, we try to align the number to another fork
node.blockchainConfig.copy(
forkBlockNumbers = ForkBlockNumbers(
frontierBlockNumber = 0,
homesteadBlockNumber = blockchainParams.homesteadForkBlock.getOrElse(neverOccuringBlock),
eip106BlockNumber = neverOccuringBlock,
eip150BlockNumber = blockchainParams.EIP150ForkBlock.getOrElse(neverOccuringBlock),
forkBlockNumbers = ForkBlockNumbers.Empty.copy(
homesteadBlockNumber = blockchainParams.homesteadForkBlock.getOrElse(neverOccurringBlock),
eip150BlockNumber = blockchainParams.EIP150ForkBlock.getOrElse(neverOccurringBlock),
eip155BlockNumber = byzantiumBlockNumber,
eip160BlockNumber = byzantiumBlockNumber,
eip161BlockNumber = byzantiumBlockNumber,
difficultyBombPauseBlockNumber = neverOccuringBlock,
difficultyBombContinueBlockNumber = neverOccuringBlock,
difficultyBombRemovalBlockNumber = neverOccuringBlock,
byzantiumBlockNumber = byzantiumBlockNumber,
ecip1049BlockNumber = None,
ecip1097BlockNumber = neverOccuringBlock,
ecip1098BlockNumber = neverOccuringBlock,
constantinopleBlockNumber = blockchainParams.constantinopleForkBlock.getOrElse(neverOccuringBlock),
constantinopleBlockNumber = blockchainParams.constantinopleForkBlock.getOrElse(neverOccurringBlock),
petersburgBlockNumber = istanbulForkBlockNumber,
aghartaBlockNumber = istanbulForkBlockNumber,
istanbulBlockNumber = istanbulForkBlockNumber,
atlantisBlockNumber = istanbulForkBlockNumber,
phoenixBlockNumber = istanbulForkBlockNumber,
ecip1099BlockNumber = neverOccuringBlock
phoenixBlockNumber = istanbulForkBlockNumber
),
accountStartNonce = UInt256(blockchainParams.accountStartNonce),
networkId = 1,
Expand Down
39 changes: 35 additions & 4 deletions src/main/scala/io/iohk/ethereum/utils/BlockchainConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,47 @@ case class ForkBlockNumbers(
ecip1098BlockNumber: BigInt,
ecip1097BlockNumber: BigInt,
ecip1049BlockNumber: Option[BigInt],
ecip1099BlockNumber: BigInt
ecip1099BlockNumber: BigInt,
magnetoBlockNumber: BigInt
) {
def all: List[BigInt] = this.productIterator.toList.flatMap {
case i: BigInt => Some(i)
case i: Option[_] =>
i.flatMap {
case n if n.isInstanceOf[BigInt] => Some(n.asInstanceOf[BigInt])
case n => None
case _ => None
}
case default => None
case _ => None
}
}

object ForkBlockNumbers {
val Empty: ForkBlockNumbers = ForkBlockNumbers(
frontierBlockNumber = 0,
homesteadBlockNumber = Long.MaxValue,
difficultyBombPauseBlockNumber = Long.MaxValue,
difficultyBombContinueBlockNumber = Long.MaxValue,
difficultyBombRemovalBlockNumber = Long.MaxValue,
eip106BlockNumber = Long.MaxValue,
eip150BlockNumber = Long.MaxValue,
eip160BlockNumber = Long.MaxValue,
eip155BlockNumber = Long.MaxValue,
eip161BlockNumber = Long.MaxValue,
byzantiumBlockNumber = Long.MaxValue,
constantinopleBlockNumber = Long.MaxValue,
istanbulBlockNumber = Long.MaxValue,
atlantisBlockNumber = Long.MaxValue,
aghartaBlockNumber = Long.MaxValue,
phoenixBlockNumber = Long.MaxValue,
petersburgBlockNumber = Long.MaxValue,
ecip1098BlockNumber = Long.MaxValue,
ecip1097BlockNumber = Long.MaxValue,
ecip1099BlockNumber = Long.MaxValue,
ecip1049BlockNumber = None,
magnetoBlockNumber = Long.MaxValue
)
}

object BlockchainConfig {

// scalastyle:off method.length
Expand Down Expand Up @@ -139,6 +167,8 @@ object BlockchainConfig {
val allowedMinersPublicKeys = readPubKeySet(blockchainConfig, "allowed-miners")

val ecip1099BlockNumber: BigInt = BigInt(blockchainConfig.getString("ecip1099-block-number"))
val magnetoBlockNumber: BigInt = BigInt(blockchainConfig.getString("magneto-block-number"))

val capabilities: List[Capability] =
blockchainConfig.getStringList("capabilities").asScala.toList.map(Capability.parseUnsafe)

Expand All @@ -165,7 +195,8 @@ object BlockchainConfig {
ecip1098BlockNumber = ecip1098BlockNumber,
ecip1097BlockNumber = ecip1097BlockNumber,
ecip1049BlockNumber = ecip1049BlockNumber,
ecip1099BlockNumber = ecip1099BlockNumber
ecip1099BlockNumber = ecip1099BlockNumber,
magnetoBlockNumber = magnetoBlockNumber
),
treasuryAddress = treasuryAddress,
maxCodeSize = maxCodeSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,28 +224,12 @@ class BlockGeneratorSpec extends AnyFlatSpec with Matchers with ScalaCheckProper
gasTieBreaker = false,
ethCompatibleStorage = true,
treasuryAddress = Address(0),
forkBlockNumbers = ForkBlockNumbers(
forkBlockNumbers = ForkBlockNumbers.Empty.copy(
frontierBlockNumber = 0,
homesteadBlockNumber = 1150000,
difficultyBombPauseBlockNumber = 3000000,
difficultyBombContinueBlockNumber = 5000000,
difficultyBombRemovalBlockNumber = 5900000,
eip155BlockNumber = Long.MaxValue,
eip106BlockNumber = Long.MaxValue,
byzantiumBlockNumber = Long.MaxValue,
constantinopleBlockNumber = Long.MaxValue,
istanbulBlockNumber = Long.MaxValue,
eip160BlockNumber = Long.MaxValue,
eip150BlockNumber = Long.MaxValue,
eip161BlockNumber = Long.MaxValue,
atlantisBlockNumber = Long.MaxValue,
aghartaBlockNumber = Long.MaxValue,
phoenixBlockNumber = Long.MaxValue,
petersburgBlockNumber = Long.MaxValue,
ecip1098BlockNumber = Long.MaxValue,
ecip1097BlockNumber = Long.MaxValue,
ecip1099BlockNumber = Long.MaxValue,
ecip1049BlockNumber = None
difficultyBombRemovalBlockNumber = 5900000
)
)

Expand Down Expand Up @@ -292,28 +276,13 @@ class BlockGeneratorSpec extends AnyFlatSpec with Matchers with ScalaCheckProper

it should "generate correct block with (without empty accounts) after EIP-161" in new TestSetup {
implicit override lazy val blockchainConfig = BlockchainConfig(
forkBlockNumbers = ForkBlockNumbers(
forkBlockNumbers = ForkBlockNumbers.Empty.copy(
frontierBlockNumber = 0,
homesteadBlockNumber = 1150000,
eip155BlockNumber = Long.MaxValue,
eip106BlockNumber = Long.MaxValue,
difficultyBombPauseBlockNumber = 3000000,
difficultyBombContinueBlockNumber = 5000000,
difficultyBombRemovalBlockNumber = 5900000,
byzantiumBlockNumber = Long.MaxValue,
constantinopleBlockNumber = Long.MaxValue,
istanbulBlockNumber = Long.MaxValue,
eip160BlockNumber = Long.MaxValue,
eip150BlockNumber = Long.MaxValue,
eip161BlockNumber = 0,
atlantisBlockNumber = Long.MaxValue,
aghartaBlockNumber = Long.MaxValue,
phoenixBlockNumber = Long.MaxValue,
petersburgBlockNumber = Long.MaxValue,
ecip1098BlockNumber = Long.MaxValue,
ecip1097BlockNumber = Long.MaxValue,
ecip1099BlockNumber = Long.MaxValue,
ecip1049BlockNumber = None
eip161BlockNumber = 0
),
chainId = 0x3d.toByte,
networkId = 1,
Expand Down Expand Up @@ -674,28 +643,12 @@ class BlockGeneratorSpec extends AnyFlatSpec with Matchers with ScalaCheckProper
SignedTransactionWithSender(signedTransaction, Address(keyPair))

val baseBlockchainConfig: BlockchainConfig = BlockchainConfig(
forkBlockNumbers = ForkBlockNumbers(
frontierBlockNumber = 0,
forkBlockNumbers = ForkBlockNumbers.Empty.copy(
homesteadBlockNumber = 1150000,
eip155BlockNumber = 0,
eip106BlockNumber = Long.MaxValue,
byzantiumBlockNumber = Long.MaxValue,
difficultyBombPauseBlockNumber = 3000000,
difficultyBombContinueBlockNumber = 5000000,
difficultyBombRemovalBlockNumber = 5900000,
constantinopleBlockNumber = Long.MaxValue,
istanbulBlockNumber = Long.MaxValue,
eip160BlockNumber = Long.MaxValue,
eip150BlockNumber = Long.MaxValue,
eip161BlockNumber = Long.MaxValue,
atlantisBlockNumber = Long.MaxValue,
aghartaBlockNumber = Long.MaxValue,
phoenixBlockNumber = Long.MaxValue,
petersburgBlockNumber = Long.MaxValue,
ecip1098BlockNumber = Long.MaxValue,
ecip1097BlockNumber = Long.MaxValue,
ecip1099BlockNumber = Long.MaxValue,
ecip1049BlockNumber = None
difficultyBombRemovalBlockNumber = 5900000
),
chainId = 0x3d.toByte,
networkId = 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ class EthashBlockHeaderValidatorSpec
def createBlockchainConfig(supportsDaoFork: Boolean = false): BlockchainConfig = {
import Fixtures.Blocks._
BlockchainConfig(
forkBlockNumbers = ForkBlockNumbers(
forkBlockNumbers = ForkBlockNumbers.Empty.copy(
frontierBlockNumber = 0,
homesteadBlockNumber = 1150000,
difficultyBombPauseBlockNumber = 3000000,
Expand All @@ -388,19 +388,7 @@ class EthashBlockHeaderValidatorSpec
byzantiumBlockNumber = 4370000,
constantinopleBlockNumber = 7280000,
istanbulBlockNumber = 9069000,
eip155BlockNumber = Long.MaxValue,
eip160BlockNumber = Long.MaxValue,
eip161BlockNumber = Long.MaxValue,
eip150BlockNumber = Long.MaxValue,
eip106BlockNumber = 0,
atlantisBlockNumber = Long.MaxValue,
aghartaBlockNumber = Long.MaxValue,
phoenixBlockNumber = Long.MaxValue,
petersburgBlockNumber = Long.MaxValue,
ecip1098BlockNumber = Long.MaxValue,
ecip1097BlockNumber = Long.MaxValue,
ecip1099BlockNumber = Long.MaxValue,
ecip1049BlockNumber = None
eip106BlockNumber = 0
),
daoForkConfig = Some(new DaoForkConfig {
override val blockExtraData: Option[ByteString] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class RestrictedEthashBlockHeaderValidatorSpec
)
def createBlockchainConfig(allowedMiners: Set[ByteString]): BlockchainConfig =
BlockchainConfig(
forkBlockNumbers = ForkBlockNumbers(
forkBlockNumbers = ForkBlockNumbers.Empty.copy(
frontierBlockNumber = 0,
homesteadBlockNumber = 1150000,
difficultyBombPauseBlockNumber = 3000000,
Expand All @@ -86,19 +86,7 @@ class RestrictedEthashBlockHeaderValidatorSpec
byzantiumBlockNumber = 4370000,
constantinopleBlockNumber = 7280000,
istanbulBlockNumber = 9069000,
eip155BlockNumber = Long.MaxValue,
eip160BlockNumber = Long.MaxValue,
eip161BlockNumber = Long.MaxValue,
eip150BlockNumber = Long.MaxValue,
eip106BlockNumber = 0,
atlantisBlockNumber = Long.MaxValue,
aghartaBlockNumber = Long.MaxValue,
phoenixBlockNumber = Long.MaxValue,
petersburgBlockNumber = Long.MaxValue,
ecip1098BlockNumber = Long.MaxValue,
ecip1097BlockNumber = Long.MaxValue,
ecip1099BlockNumber = Long.MaxValue,
ecip1049BlockNumber = None
eip106BlockNumber = 0
),
daoForkConfig = None,
// unused
Expand Down
Loading

0 comments on commit ced069a

Please sign in to comment.