Skip to content

Commit

Permalink
Configure network upgrade for each network
Browse files Browse the repository at this point in the history
  • Loading branch information
colltoaction authored and Diego López León committed Jan 3, 2019
1 parent 4c3bacd commit b073f7a
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* This file is part of RskJ
* Copyright (C) 2018 RSK Labs Ltd.
* (derived from ethereumJ library, Copyright (c) 2016 <ether.camp>)
*
* 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 <http://www.gnu.org/licenses/>.
*/

package org.ethereum.config.blockchain.devnet;

public class DevNetOrchid060Config extends DevNetOrchidConfig {
@Override
public boolean isRskip103() {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* This file is part of RskJ
* Copyright (C) 2018 RSK Labs Ltd.
* (derived from ethereumJ library, Copyright (c) 2016 <ether.camp>)
*
* 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 <http://www.gnu.org/licenses/>.
*/

package org.ethereum.config.blockchain.mainnet;

public class MainNetOrchid060Config extends MainNetOrchidConfig {
@Override
public boolean isRskip103() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public boolean isRskip91() {
return true;
}

@Override
public boolean isRskip103() {
return true;
}

@Override
public boolean isRskip87() { return true; }

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* This file is part of RskJ
* Copyright (C) 2018 RSK Labs Ltd.
* (derived from ethereumJ library, Copyright (c) 2016 <ether.camp>)
*
* 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 <http://www.gnu.org/licenses/>.
*/

package org.ethereum.config.blockchain.testnet;

public class TestNetOrchid060Config extends TestNetDifficultyDropEnabledConfig {

@Override
public boolean isRskip103() {
return true;
}
}
15 changes: 10 additions & 5 deletions rskj-core/src/main/java/org/ethereum/config/net/DevNetConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;


/**
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand All @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit b073f7a

Please sign in to comment.