From b073f7ac9028054d772f76e96b8ec6e4ca43a227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Coll?= Date: Wed, 2 Jan 2019 15:48:07 -0300 Subject: [PATCH] Configure network upgrade for each network --- .../blockchain/HardForkActivationConfig.java | 18 ++++++++++-- .../devnet/DevNetOrchid060Config.java | 27 ++++++++++++++++++ .../mainnet/MainNetOrchid060Config.java | 27 ++++++++++++++++++ .../regtest/RegTestOrchidConfig.java | 5 ++++ .../testnet/TestNetOrchid060Config.java | 28 +++++++++++++++++++ .../org/ethereum/config/net/DevNetConfig.java | 15 ++++++---- .../ethereum/config/net/MainNetConfig.java | 2 ++ .../ethereum/config/net/TestNetConfig.java | 3 ++ .../mine/ParameterizedNetworkUpgradeTest.java | 5 ++-- 9 files changed, 121 insertions(+), 9 deletions(-) create mode 100644 rskj-core/src/main/java/org/ethereum/config/blockchain/devnet/DevNetOrchid060Config.java create mode 100644 rskj-core/src/main/java/org/ethereum/config/blockchain/mainnet/MainNetOrchid060Config.java create mode 100644 rskj-core/src/main/java/org/ethereum/config/blockchain/testnet/TestNetOrchid060Config.java diff --git a/rskj-core/src/main/java/org/ethereum/config/blockchain/HardForkActivationConfig.java b/rskj-core/src/main/java/org/ethereum/config/blockchain/HardForkActivationConfig.java index ff5e787f727..2bee0daec4c 100644 --- a/rskj-core/src/main/java/org/ethereum/config/blockchain/HardForkActivationConfig.java +++ b/rskj-core/src/main/java/org/ethereum/config/blockchain/HardForkActivationConfig.java @@ -21,20 +21,34 @@ public class HardForkActivationConfig { private final int orchidActivationHeight; + private final int orchid060ActivationHeight; private static final String PROPERTY_ORCHID_NAME = "orchid"; + private static final String PROPERTY_ORCHID_060_NAME = "orchid060"; public HardForkActivationConfig(Config config) { // If I don't have any config for orchidActivationHeight I will set it to 0 - this(config.hasPath(PROPERTY_ORCHID_NAME) ? config.getInt(PROPERTY_ORCHID_NAME) : 0); + this( + config.hasPath(PROPERTY_ORCHID_NAME) ? config.getInt(PROPERTY_ORCHID_NAME) : 0, + config.hasPath(PROPERTY_ORCHID_060_NAME) ? config.getInt(PROPERTY_ORCHID_060_NAME) : 0 + ); } - public HardForkActivationConfig(int orchidActivationHeight) { + public HardForkActivationConfig(int orchidActivationHeight, int orchid060ActivationHeight) { this.orchidActivationHeight = orchidActivationHeight; + this.orchid060ActivationHeight = orchid060ActivationHeight; } public int getOrchidActivationHeight() { return orchidActivationHeight; } + /** + * TODO(mc): Only Devnet knows about Orchid060 activation config. + * This is a quick solution but the whole HF activation needs work. + * E.g. we don't handle the case where Orchid060 < Orchid (fails at runtime). + */ + public int getOrchid060ActivationHeight() { + return orchid060ActivationHeight; + } } diff --git a/rskj-core/src/main/java/org/ethereum/config/blockchain/devnet/DevNetOrchid060Config.java b/rskj-core/src/main/java/org/ethereum/config/blockchain/devnet/DevNetOrchid060Config.java new file mode 100644 index 00000000000..32c6c86b1f7 --- /dev/null +++ b/rskj-core/src/main/java/org/ethereum/config/blockchain/devnet/DevNetOrchid060Config.java @@ -0,0 +1,27 @@ +/* + * This file is part of RskJ + * Copyright (C) 2018 RSK Labs Ltd. + * (derived from ethereumJ library, Copyright (c) 2016 ) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package org.ethereum.config.blockchain.devnet; + +public class DevNetOrchid060Config extends DevNetOrchidConfig { + @Override + public boolean isRskip103() { + return true; + } +} diff --git a/rskj-core/src/main/java/org/ethereum/config/blockchain/mainnet/MainNetOrchid060Config.java b/rskj-core/src/main/java/org/ethereum/config/blockchain/mainnet/MainNetOrchid060Config.java new file mode 100644 index 00000000000..2bd7ef13636 --- /dev/null +++ b/rskj-core/src/main/java/org/ethereum/config/blockchain/mainnet/MainNetOrchid060Config.java @@ -0,0 +1,27 @@ +/* + * This file is part of RskJ + * Copyright (C) 2018 RSK Labs Ltd. + * (derived from ethereumJ library, Copyright (c) 2016 ) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package org.ethereum.config.blockchain.mainnet; + +public class MainNetOrchid060Config extends MainNetOrchidConfig { + @Override + public boolean isRskip103() { + return true; + } +} diff --git a/rskj-core/src/main/java/org/ethereum/config/blockchain/regtest/RegTestOrchidConfig.java b/rskj-core/src/main/java/org/ethereum/config/blockchain/regtest/RegTestOrchidConfig.java index df3fe0a76b5..9f7fcbd43ef 100644 --- a/rskj-core/src/main/java/org/ethereum/config/blockchain/regtest/RegTestOrchidConfig.java +++ b/rskj-core/src/main/java/org/ethereum/config/blockchain/regtest/RegTestOrchidConfig.java @@ -44,6 +44,11 @@ public boolean isRskip91() { return true; } + @Override + public boolean isRskip103() { + return true; + } + @Override public boolean isRskip87() { return true; } diff --git a/rskj-core/src/main/java/org/ethereum/config/blockchain/testnet/TestNetOrchid060Config.java b/rskj-core/src/main/java/org/ethereum/config/blockchain/testnet/TestNetOrchid060Config.java new file mode 100644 index 00000000000..ae2dbea31b5 --- /dev/null +++ b/rskj-core/src/main/java/org/ethereum/config/blockchain/testnet/TestNetOrchid060Config.java @@ -0,0 +1,28 @@ +/* + * This file is part of RskJ + * Copyright (C) 2018 RSK Labs Ltd. + * (derived from ethereumJ library, Copyright (c) 2016 ) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package org.ethereum.config.blockchain.testnet; + +public class TestNetOrchid060Config extends TestNetDifficultyDropEnabledConfig { + + @Override + public boolean isRskip103() { + return true; + } +} diff --git a/rskj-core/src/main/java/org/ethereum/config/net/DevNetConfig.java b/rskj-core/src/main/java/org/ethereum/config/net/DevNetConfig.java index 77fd62db030..297e8499b5a 100644 --- a/rskj-core/src/main/java/org/ethereum/config/net/DevNetConfig.java +++ b/rskj-core/src/main/java/org/ethereum/config/net/DevNetConfig.java @@ -20,8 +20,9 @@ package org.ethereum.config.net; import org.ethereum.config.blockchain.HardForkActivationConfig; -import org.ethereum.config.blockchain.devnet.DevNetOrchidConfig; import org.ethereum.config.blockchain.devnet.DevNetGenesisConfig; +import org.ethereum.config.blockchain.devnet.DevNetOrchid060Config; +import org.ethereum.config.blockchain.devnet.DevNetOrchidConfig; /** @@ -45,11 +46,15 @@ public static DevNetConfig getFromConfig(HardForkActivationConfig hardForkActiva return getDefaultDevNetConfig(); } DevNetConfig customConfig = new DevNetConfig(); - if (hardForkActivationConfig.getOrchidActivationHeight() != 0) { - // Only add genesis config if the fork configs are set - customConfig.add(0, new DevNetGenesisConfig()); + if (hardForkActivationConfig.getOrchid060ActivationHeight() != 0) { + if (hardForkActivationConfig.getOrchidActivationHeight() != 0) { + customConfig.add(0, new DevNetGenesisConfig()); + } + + customConfig.add(hardForkActivationConfig.getOrchidActivationHeight(), new DevNetOrchidConfig()); } - customConfig.add(hardForkActivationConfig.getOrchidActivationHeight(), new DevNetOrchidConfig()); + + customConfig.add(hardForkActivationConfig.getOrchid060ActivationHeight(), new DevNetOrchid060Config()); return customConfig; } } diff --git a/rskj-core/src/main/java/org/ethereum/config/net/MainNetConfig.java b/rskj-core/src/main/java/org/ethereum/config/net/MainNetConfig.java index adcdda69f0c..38ad0d56f5a 100644 --- a/rskj-core/src/main/java/org/ethereum/config/net/MainNetConfig.java +++ b/rskj-core/src/main/java/org/ethereum/config/net/MainNetConfig.java @@ -21,6 +21,7 @@ import org.ethereum.config.blockchain.mainnet.MainNetAfterBridgeSyncConfig; import org.ethereum.config.blockchain.mainnet.MainNetBeforeBridgeSyncConfig; +import org.ethereum.config.blockchain.mainnet.MainNetOrchid060Config; import org.ethereum.config.blockchain.mainnet.MainNetOrchidConfig; @@ -34,5 +35,6 @@ public MainNetConfig() { // On blockchain launch blocks will be faster until difficulty is adjusted to available hashing power. add(370_000, new MainNetAfterBridgeSyncConfig()); add(729_000, new MainNetOrchidConfig()); + add(1_052_700, new MainNetOrchid060Config()); } } diff --git a/rskj-core/src/main/java/org/ethereum/config/net/TestNetConfig.java b/rskj-core/src/main/java/org/ethereum/config/net/TestNetConfig.java index 386ae1d12cc..44b7ece6e7a 100644 --- a/rskj-core/src/main/java/org/ethereum/config/net/TestNetConfig.java +++ b/rskj-core/src/main/java/org/ethereum/config/net/TestNetConfig.java @@ -22,6 +22,7 @@ import org.ethereum.config.blockchain.testnet.TestNetBeforeBridgeSyncConfig; import org.ethereum.config.blockchain.testnet.TestNetDifficultyDropEnabledConfig; +import org.ethereum.config.blockchain.testnet.TestNetOrchid060Config; public class TestNetConfig extends AbstractNetConfig { public static final TestNetConfig INSTANCE = new TestNetConfig(); @@ -31,5 +32,7 @@ public TestNetConfig() { // 21 days of 1 block every 14 seconds. // On blockchain launch blocks will be faster until difficulty is adjusted to available hashing power. add(114_000, new TestNetDifficultyDropEnabledConfig()); + // Static call fix. + add(233_000, new TestNetOrchid060Config()); } } diff --git a/rskj-core/src/test/java/co/rsk/mine/ParameterizedNetworkUpgradeTest.java b/rskj-core/src/test/java/co/rsk/mine/ParameterizedNetworkUpgradeTest.java index e8db75fae03..02b759034af 100644 --- a/rskj-core/src/test/java/co/rsk/mine/ParameterizedNetworkUpgradeTest.java +++ b/rskj-core/src/test/java/co/rsk/mine/ParameterizedNetworkUpgradeTest.java @@ -42,7 +42,7 @@ public static Object[] data() { TestSystemProperties bambooConfig = new TestSystemProperties() { @Override protected BlockchainNetConfig buildBlockchainConfig() { - return RegTestConfig.getFromConfig(new HardForkActivationConfig(Integer.MAX_VALUE)); + return RegTestConfig.getFromConfig(new HardForkActivationConfig(Integer.MAX_VALUE, Integer.MAX_VALUE)); } @Override @@ -53,7 +53,8 @@ public String toString() { TestSystemProperties orchidConfig = new TestSystemProperties() { @Override protected BlockchainNetConfig buildBlockchainConfig() { - return RegTestConfig.getFromConfig(new HardForkActivationConfig(0)); + // this method ignores the orchid060 activation height configuration + return RegTestConfig.getFromConfig(new HardForkActivationConfig(0, Integer.MAX_VALUE)); } @Override