Skip to content

Commit

Permalink
ETC - Cleanup (hyperledger#201)
Browse files Browse the repository at this point in the history
Cleans up issues relating to the Ethereum Classic configurations.

* Fixes Jira BESU-116
* Fixes ommer reward calculation
* Fixes Mordor config
* Fixes Kotti Sync issues

Signed-off-by: soc1c <soc1c@users.noreply.github.com>
Signed-off-by: edwardmack <ed@edwardmack.com>
  • Loading branch information
GregTheGreek authored and edwardmack committed Feb 4, 2020
1 parent 441fdef commit 43eeaf2
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.hyperledger.besu.ethereum.p2p.config.DiscoveryConfiguration.GOERLI_BOOTSTRAP_NODES;
import static org.hyperledger.besu.ethereum.p2p.config.DiscoveryConfiguration.KOTTI_BOOTSTRAP_NODES;
import static org.hyperledger.besu.ethereum.p2p.config.DiscoveryConfiguration.MAINNET_BOOTSTRAP_NODES;
import static org.hyperledger.besu.ethereum.p2p.config.DiscoveryConfiguration.MORDOR_BOOTSTRAP_NODES;
import static org.hyperledger.besu.ethereum.p2p.config.DiscoveryConfiguration.RINKEBY_BOOTSTRAP_NODES;
import static org.hyperledger.besu.ethereum.p2p.config.DiscoveryConfiguration.ROPSTEN_BOOTSTRAP_NODES;

Expand All @@ -43,13 +44,15 @@ public class EthNetworkConfig {
public static final BigInteger DEV_NETWORK_ID = BigInteger.valueOf(2018);
public static final BigInteger CLASSIC_NETWORK_ID = BigInteger.valueOf(1);
public static final BigInteger KOTTI_NETWORK_ID = BigInteger.valueOf(6);
public static final BigInteger MORDOR_NETWORK_ID = BigInteger.valueOf(7);
private static final String MAINNET_GENESIS = "/mainnet.json";
private static final String ROPSTEN_GENESIS = "/ropsten.json";
private static final String RINKEBY_GENESIS = "/rinkeby.json";
private static final String GOERLI_GENESIS = "/goerli.json";
private static final String DEV_GENESIS = "/dev.json";
private static final String CLASSIC_GENESIS = "/classic.json";
private static final String KOTTI_GENESIS = "/kotti.json";
private static final String MORDOR_GENESIS = "/mordor.json";
private final String genesisConfig;
private final BigInteger networkId;
private final List<EnodeURL> bootNodes;
Expand Down Expand Up @@ -125,6 +128,9 @@ public static EthNetworkConfig getNetworkConfig(final NetworkName networkName) {
case KOTTI:
return new EthNetworkConfig(
jsonConfig(KOTTI_GENESIS), KOTTI_NETWORK_ID, KOTTI_BOOTSTRAP_NODES);
case MORDOR:
return new EthNetworkConfig(
jsonConfig(MORDOR_GENESIS), MORDOR_NETWORK_ID, MORDOR_BOOTSTRAP_NODES);
case MAINNET:
default:
return new EthNetworkConfig(
Expand Down Expand Up @@ -157,6 +163,8 @@ public static String jsonConfig(final NetworkName network) {
return jsonConfig(CLASSIC_GENESIS);
case KOTTI:
return jsonConfig(KOTTI_GENESIS);
case MORDOR:
return jsonConfig(MORDOR_GENESIS);
default:
throw new IllegalArgumentException("Unknown network:" + network);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ public enum NetworkName {
GOERLI,
DEV,
CLASSIC,
KOTTI
KOTTI,
MORDOR
}
22 changes: 22 additions & 0 deletions besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import static org.hyperledger.besu.cli.config.NetworkName.GOERLI;
import static org.hyperledger.besu.cli.config.NetworkName.KOTTI;
import static org.hyperledger.besu.cli.config.NetworkName.MAINNET;
import static org.hyperledger.besu.cli.config.NetworkName.MORDOR;
import static org.hyperledger.besu.cli.config.NetworkName.RINKEBY;
import static org.hyperledger.besu.cli.config.NetworkName.ROPSTEN;
import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.ETH;
Expand Down Expand Up @@ -2512,6 +2513,22 @@ public void kottiValuesAreUsed() throws Exception {
assertThat(commandErrorOutput.toString()).isEmpty();
}

@Test
public void mordorValuesAreUsed() throws Exception {
parseCommand("--network", "mordor");

final ArgumentCaptor<EthNetworkConfig> networkArg =
ArgumentCaptor.forClass(EthNetworkConfig.class);

verify(mockControllerBuilderFactory).fromEthNetworkConfig(networkArg.capture(), any());
verify(mockControllerBuilder).build();

assertThat(networkArg.getValue()).isEqualTo(EthNetworkConfig.getNetworkConfig(MORDOR));

assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty();
}

@Test
public void rinkebyValuesCanBeOverridden() throws Exception {
networkValuesCanBeOverridden("rinkeby");
Expand Down Expand Up @@ -2542,6 +2559,11 @@ public void kottiValuesCanBeOverridden() throws Exception {
networkValuesCanBeOverridden("kotti");
}

@Test
public void mordorValuesCanBeOverridden() throws Exception {
networkValuesCanBeOverridden("mordor");
}

private void networkValuesCanBeOverridden(final String network) throws Exception {
parseCommand(
"--network",
Expand Down
2 changes: 1 addition & 1 deletion config/src/main/resources/classic.json
Original file line number Diff line number Diff line change
Expand Up @@ -26705,4 +26705,4 @@
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ public class DiscoveryConfiguration {
.map(EnodeURL::fromString)
.collect(toList()));

public static List<EnodeURL> MORDOR_BOOTSTRAP_NODES =
Collections.unmodifiableList(
Stream.of(
"enode://03b133f731049e3f7be827339c3759be92778c05e54a1847d178c0fdb56fa168aa1e7e61fc77791a7afdd0328a00318f73c01212eb3f3bbe919f5ce8f5b4a314@192.227.105.4:32000",
"enode://06fdbeb591d26f53b2e7250025fe955ca013431ded930920cf1e3cd1f0c920e9a5e727949d209bc25a07288327b525279b11c5551315c50ff0db483e69fc159b@34.218.225.178:32000",
"enode://1813e90a0afdd7c1e4892c5376960e3577a9e6c5a4f86fa405a405c7421a4a1608248d77cc90333842f13d8954d82113dec480cfb76b4fef8cb475157cf4d5f2@10.28.224.3:30000",
"enode://2b69a3926f36a7748c9021c34050be5e0b64346225e477fe7377070f6289bd363b2be73a06010fd516e6ea3ee90778dd0399bc007bb1281923a79374f842675a@51.15.116.226:30303",
"enode://621e28e529146fd501709194885f50540c494f1a2985d1fb4ec8769226b5cb0b0d1a11545926077821474c2767cdd87888ead8a2509a2c9069dd5584e4b1c3b8@10.28.223.8:30000",
"enode://a59e33ccd2b3e52d578f1fbd70c6f9babda2650f0760d6ff3b37742fdcdfdb3defba5d56d315b40c46b70198c7621e63ffa3f987389c7118634b0fefbbdfa7fd@51.15.116.226:30303")
.map(EnodeURL::fromString)
.collect(toList()));

private boolean active = true;
private String bindHost = NetworkUtility.INADDR_ANY;
private int bindPort = 30303;
Expand Down

0 comments on commit 43eeaf2

Please sign in to comment.