diff --git a/ethereumj-core/src/main/java/org/ethereum/config/blockchain/Eip150HFConfig.java b/ethereumj-core/src/main/java/org/ethereum/config/blockchain/Eip150HFConfig.java
index 2cc83fcce5..349b4b1b29 100644
--- a/ethereumj-core/src/main/java/org/ethereum/config/blockchain/Eip150HFConfig.java
+++ b/ethereumj-core/src/main/java/org/ethereum/config/blockchain/Eip150HFConfig.java
@@ -201,4 +201,9 @@ public boolean eip1283() {
public boolean eip1014() {
return false;
}
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName();
+ }
}
diff --git a/ethereumj-core/src/main/java/org/ethereum/config/blockchain/PetersburgConfig.java b/ethereumj-core/src/main/java/org/ethereum/config/blockchain/PetersburgConfig.java
new file mode 100644
index 0000000000..ef64c46a23
--- /dev/null
+++ b/ethereumj-core/src/main/java/org/ethereum/config/blockchain/PetersburgConfig.java
@@ -0,0 +1,26 @@
+package org.ethereum.config.blockchain;
+
+import org.ethereum.config.BlockchainConfig;
+
+/**
+ * A version of Constantinople Hard Fork after removing eip-1283.
+ *
+ * Unofficial name 'Petersburg', includes:
+ *
+ * - 1234 - Constantinople Difficulty Bomb Delay and Block Reward Adjustment (2 ETH)
+ * - 145 - Bitwise shifting instructions in EVM
+ * - 1014 - Skinny CREATE2
+ * - 1052 - EXTCODEHASH opcode
+ *
+ */
+public class PetersburgConfig extends ConstantinopleConfig {
+
+ public PetersburgConfig(BlockchainConfig parent) {
+ super(parent);
+ }
+
+ @Override
+ public boolean eip1283() {
+ return false;
+ }
+}
diff --git a/ethereumj-core/src/main/java/org/ethereum/config/net/JsonNetConfig.java b/ethereumj-core/src/main/java/org/ethereum/config/net/JsonNetConfig.java
index 590902d795..9e6eeb11d8 100644
--- a/ethereumj-core/src/main/java/org/ethereum/config/net/JsonNetConfig.java
+++ b/ethereumj-core/src/main/java/org/ethereum/config/net/JsonNetConfig.java
@@ -17,6 +17,7 @@
*/
package org.ethereum.config.net;
+import com.google.common.base.MoreObjects;
import org.apache.commons.lang3.tuple.Pair;
import org.ethereum.config.BlockchainConfig;
import org.ethereum.config.blockchain.*;
@@ -107,6 +108,11 @@ public JsonNetConfig(GenesisConfig config) throws RuntimeException {
public Integer getChainId() {
return chainId;
}
+
+ @Override
+ public String toString() {
+ return Eip160HFConfig.class.getSimpleName();
+ }
});
} else {
lastCandidate = Pair.of(block, new Eip160HFConfig(lastCandidate.getRight()));
@@ -129,6 +135,11 @@ public Integer getChainId() {
public Integer getChainId() {
return chainId;
}
+
+ @Override
+ public String toString() {
+ return ByzantiumConfig.class.getSimpleName();
+ }
});
} else {
lastCandidate = Pair.of(config.byzantiumBlock, new ByzantiumConfig(lastCandidate.getRight()));
@@ -151,6 +162,11 @@ public Integer getChainId() {
public Integer getChainId() {
return chainId;
}
+
+ @Override
+ public String toString() {
+ return ConstantinopleConfig.class.getSimpleName();
+ }
});
} else {
lastCandidate = Pair.of(config.constantinopleBlock, new ConstantinopleConfig(lastCandidate.getRight()));
@@ -159,6 +175,33 @@ public Integer getChainId() {
logger.debug(logLine.toString());
candidates.add(lastCandidate);
}
+
+ if (config.petersburgBlock != null) {
+ StringBuilder logLine = new StringBuilder();
+ if (logger.isDebugEnabled())
+ logLine.append("Block #").append(config.petersburgBlock).append(" => Petersburg");
+ if (config.chainId != null) {
+ final int chainId = config.chainId;
+ if (logger.isDebugEnabled())
+ logLine.append(", chainId: ").append(chainId);
+ lastCandidate = Pair.of(config.petersburgBlock, new PetersburgConfig(lastCandidate.getRight()) {
+ @Override
+ public Integer getChainId() {
+ return chainId;
+ }
+
+ @Override
+ public String toString() {
+ return PetersburgConfig.class.getSimpleName();
+ }
+ });
+ } else {
+ lastCandidate = Pair.of(config.petersburgBlock, new PetersburgConfig(lastCandidate.getRight()));
+ }
+ if (logger.isDebugEnabled())
+ logger.debug(logLine.toString());
+ candidates.add(lastCandidate);
+ }
}
if (logger.isDebugEnabled())
diff --git a/ethereumj-core/src/main/java/org/ethereum/config/net/MainNetConfig.java b/ethereumj-core/src/main/java/org/ethereum/config/net/MainNetConfig.java
index c2fc30690b..4bc5ce5bd4 100644
--- a/ethereumj-core/src/main/java/org/ethereum/config/net/MainNetConfig.java
+++ b/ethereumj-core/src/main/java/org/ethereum/config/net/MainNetConfig.java
@@ -32,7 +32,6 @@ public MainNetConfig() {
add(2_463_000, new Eip150HFConfig(new DaoHFConfig()));
add(2_675_000, new Eip160HFConfig(new DaoHFConfig()));
add(4_370_000, new ByzantiumConfig(new DaoHFConfig()));
-// FIXME: Delayed until resolving of EIP-1283 bug
-// add(7_080_000, new ConstantinopleConfig(new DaoHFConfig()));
+ add(7_280_000, new PetersburgConfig(new DaoHFConfig()));
}
}
diff --git a/ethereumj-core/src/main/java/org/ethereum/config/net/RopstenNetConfig.java b/ethereumj-core/src/main/java/org/ethereum/config/net/RopstenNetConfig.java
index 8d21edc38b..adc677fcb2 100644
--- a/ethereumj-core/src/main/java/org/ethereum/config/net/RopstenNetConfig.java
+++ b/ethereumj-core/src/main/java/org/ethereum/config/net/RopstenNetConfig.java
@@ -29,5 +29,6 @@ public RopstenNetConfig() {
add(10, new RopstenConfig(new HomesteadConfig()));
add(1_700_000, new RopstenConfig(new ByzantiumConfig(new DaoHFConfig())));
add(4_230_000, new RopstenConfig(new ConstantinopleConfig(new DaoHFConfig())));
+ add(4_939_394, new RopstenConfig(new PetersburgConfig(new DaoHFConfig())));
}
}
diff --git a/ethereumj-core/src/main/java/org/ethereum/core/genesis/GenesisConfig.java b/ethereumj-core/src/main/java/org/ethereum/core/genesis/GenesisConfig.java
index 9b5f24e755..b90c52938f 100644
--- a/ethereumj-core/src/main/java/org/ethereum/core/genesis/GenesisConfig.java
+++ b/ethereumj-core/src/main/java/org/ethereum/core/genesis/GenesisConfig.java
@@ -31,6 +31,7 @@ public class GenesisConfig {
public Integer eip158Block;
public Integer byzantiumBlock;
public Integer constantinopleBlock;
+ public Integer petersburgBlock;
public Integer chainId;
// EthereumJ private options
@@ -45,6 +46,6 @@ public static class HashValidator {
public boolean isCustomConfig() {
return homesteadBlock != null || daoForkBlock != null || eip150Block != null ||
eip155Block != null || eip158Block != null || byzantiumBlock != null ||
- constantinopleBlock != null;
+ constantinopleBlock != null || petersburgBlock != null;
}
}
diff --git a/ethereumj-core/src/main/resources/genesis/ropsten.json b/ethereumj-core/src/main/resources/genesis/ropsten.json
index fc620a4650..572ab8a6c9 100644
--- a/ethereumj-core/src/main/resources/genesis/ropsten.json
+++ b/ethereumj-core/src/main/resources/genesis/ropsten.json
@@ -4,6 +4,7 @@
"eip158Block": 10,
"byzantiumBlock": 1700000,
"constantinopleBlock": 4230000,
+ "petersburgBlock": 4939394,
"headerValidators": [
{"number": 10, "hash": "0xb3074f936815a0425e674890d7db7b5e94f3a06dca5b22d291b55dcd02dde93e"},
diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubJSONTestSuite.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubJSONTestSuite.java
index a31e8cc725..da24619688 100644
--- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubJSONTestSuite.java
+++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubJSONTestSuite.java
@@ -319,13 +319,15 @@ public enum Network {
EIP158,
Byzantium,
Constantinople,
+ ConstantinopleFix,
// Transition networks
FrontierToHomesteadAt5,
HomesteadToDaoAt5,
HomesteadToEIP150At5,
EIP158ToByzantiumAt5,
- ByzantiumToConstantinopleAt5;
+ ByzantiumToConstantinopleAt5,
+ ByzantiumToConstantinopleFixAt5;
public BlockchainNetConfig getConfig() {
switch (this) {
@@ -336,6 +338,7 @@ public BlockchainNetConfig getConfig() {
case EIP158: return new Eip160HFConfig(new DaoHFConfig());
case Byzantium: return new ByzantiumConfig(new DaoHFConfig());
case Constantinople: return new ConstantinopleConfig(new DaoHFConfig());
+ case ConstantinopleFix: return new PetersburgConfig(new DaoHFConfig());
case FrontierToHomesteadAt5: return new BaseNetConfig() {{
add(0, new FrontierConfig());
@@ -362,6 +365,11 @@ public BlockchainNetConfig getConfig() {
add(5, new ConstantinopleConfig(new HomesteadConfig()));
}};
+ case ByzantiumToConstantinopleFixAt5: return new BaseNetConfig() {{
+ add(0, new ByzantiumConfig(new HomesteadConfig()));
+ add(5, new PetersburgConfig(new HomesteadConfig()));
+ }};
+
default: throw new IllegalArgumentException("Unknown network value: " + this.name());
}
}
diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubTestNetTest.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubTestNetTest.java
index ddbe4bfd95..a86b182305 100644
--- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubTestNetTest.java
+++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubTestNetTest.java
@@ -17,6 +17,7 @@
*/
package org.ethereum.jsontestsuite;
+import org.ethereum.jsontestsuite.GitHubJSONTestSuite.Network;
import org.ethereum.jsontestsuite.suite.BlockchainTestSuite;
import org.junit.*;
import org.junit.runners.MethodSorters;
@@ -68,6 +69,6 @@ public void bcEIP158ToByzantium() throws IOException {
@Test
public void byzantiumToConstantinople() throws IOException {
- suite.runAll("bcByzantiumToConstantinople", GitHubJSONTestSuite.Network.ByzantiumToConstantinopleAt5);
+ suite.runAll("bcByzantiumToConstantinople", GitHubJSONTestSuite.Network.ByzantiumToConstantinopleFixAt5);
}
}
diff --git a/ethereumj-core/src/test/resources/github-tests.prop b/ethereumj-core/src/test/resources/github-tests.prop
index a735f64ed8..9401729998 100644
--- a/ethereumj-core/src/test/resources/github-tests.prop
+++ b/ethereumj-core/src/test/resources/github-tests.prop
@@ -2,4 +2,4 @@
# to determinate commit of Ethereum tests repo https://github.com/ethereum/tests
# which should be checked out in local repo directory
# EthereumJ is tested with files from this commit
-GitHubTests.commit=253e99861fe406c7b1daf3d6a0c40906e8a8fd8f
+GitHubTests.commit=5cef36e2844d4cfdc6b52362ba09261f0a09b76e