Skip to content
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

Add a version of constantinople HF without eip1283 #1258

Merged
merged 1 commit into from
Jan 25, 2019
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 @@ -201,4 +201,9 @@ public boolean eip1283() {
public boolean eip1014() {
return false;
}

@Override
public String toString() {
return getClass().getSimpleName();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.ethereum.config.blockchain;

import org.ethereum.config.BlockchainConfig;

/**
* A version of Constantinople Hard Fork after removing eip-1283.
* <p>
* Unofficial name 'Petersburg', includes:
* <ul>
* <li>1234 - Constantinople Difficulty Bomb Delay and Block Reward Adjustment (2 ETH)</li>
* <li>145 - Bitwise shifting instructions in EVM</li>
* <li>1014 - Skinny CREATE2</li>
* <li>1052 - EXTCODEHASH opcode</li>
* </ul>
*/
public class PetersburgConfig extends ConstantinopleConfig {

public PetersburgConfig(BlockchainConfig parent) {
super(parent);
}

@Override
public boolean eip1283() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -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()));
Expand All @@ -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()));
Expand All @@ -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()));
Expand All @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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())));
mkalinin marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
}
1 change: 1 addition & 0 deletions ethereumj-core/src/main/resources/genesis/ropsten.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"eip158Block": 10,
"byzantiumBlock": 1700000,
"constantinopleBlock": 4230000,
"petersburgBlock": 4939394,

"headerValidators": [
{"number": 10, "hash": "0xb3074f936815a0425e674890d7db7b5e94f3a06dca5b22d291b55dcd02dde93e"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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());
Expand All @@ -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());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion ethereumj-core/src/test/resources/github-tests.prop
Original file line number Diff line number Diff line change
Expand Up @@ -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