Add --ropsten command line argument (#197)

Jussi Virtanen 6 years ago committed by Adrian Sutton
parent 7062a420fa
commit b9e5d74deb
  1. 7
      ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/config/DiscoveryConfiguration.java
  2. 12
      pantheon/src/main/java/tech/pegasys/pantheon/cli/EthNetworkConfig.java
  3. 21
      pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java
  4. 1
      pantheon/src/main/java/tech/pegasys/pantheon/controller/CliquePantheonController.java
  5. 1
      pantheon/src/main/java/tech/pegasys/pantheon/controller/MainnetPantheonController.java

@ -44,6 +44,13 @@ public class DiscoveryConfiguration {
"enode://b6b28890b006743680c52e64e0d16db57f28124885595fa03a562be1d2bf0f3a1da297d56b13da25fb992888fd556d4c1a27b1f39d531bde7de1921c90061cc6@159.89.28.211:30303") "enode://b6b28890b006743680c52e64e0d16db57f28124885595fa03a562be1d2bf0f3a1da297d56b13da25fb992888fd556d4c1a27b1f39d531bde7de1921c90061cc6@159.89.28.211:30303")
.map(DefaultPeer::fromURI) .map(DefaultPeer::fromURI)
.collect(toList())); .collect(toList()));
public static List<Peer> ROPSTEN_BOOTSTRAP_NODES =
Collections.unmodifiableList(
Stream.of(
"enode://6332792c4a00e3e4ee0926ed89e0d27ef985424d97b6a45bf0f23e51f0dcb5e66b875777506458aea7af6f9e4ffb69f43f3778ee73c81ed9d34c51c4b16b0b0f@52.232.243.152:30303",
"enode://94c15d1b9e2fe7ce56e458b9a3b672ef11894ddedd0c6f247e0f1d3487f52b66208fb4aeb8179fce6e3a749ea93ed147c37976d67af557508d199d9594c35f09@192.81.208.223:30303")
.map(DefaultPeer::fromURI)
.collect(toList()));
private boolean active = true; private boolean active = true;
private String bindHost = "0.0.0.0"; private String bindHost = "0.0.0.0";

@ -12,10 +12,9 @@
*/ */
package tech.pegasys.pantheon.cli; package tech.pegasys.pantheon.cli;
import static tech.pegasys.pantheon.controller.CliquePantheonController.RINKEBY_NETWORK_ID;
import static tech.pegasys.pantheon.controller.MainnetPantheonController.MAINNET_NETWORK_ID;
import static tech.pegasys.pantheon.ethereum.p2p.config.DiscoveryConfiguration.MAINNET_BOOTSTRAP_NODES; import static tech.pegasys.pantheon.ethereum.p2p.config.DiscoveryConfiguration.MAINNET_BOOTSTRAP_NODES;
import static tech.pegasys.pantheon.ethereum.p2p.config.DiscoveryConfiguration.RINKEBY_BOOTSTRAP_NODES; import static tech.pegasys.pantheon.ethereum.p2p.config.DiscoveryConfiguration.RINKEBY_BOOTSTRAP_NODES;
import static tech.pegasys.pantheon.ethereum.p2p.config.DiscoveryConfiguration.ROPSTEN_BOOTSTRAP_NODES;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
@ -26,8 +25,12 @@ import com.google.common.base.Preconditions;
import com.google.common.io.Resources; import com.google.common.io.Resources;
public class EthNetworkConfig { public class EthNetworkConfig {
private static final int MAINNET_NETWORK_ID = 1;
private static final int RINKEBY_NETWORK_ID = 4;
private static final int ROPSTEN_NETWORK_ID = 3;
private static final String MAINNET_GENESIS = "mainnet.json"; private static final String MAINNET_GENESIS = "mainnet.json";
private static final String RINKEBY_GENESIS = "rinkeby.json"; private static final String RINKEBY_GENESIS = "rinkeby.json";
private static final String ROPSTEN_GENESIS = "ropsten.json";
private final URI genesisConfig; private final URI genesisConfig;
private final int networkId; private final int networkId;
private final Collection<?> bootNodes; private final Collection<?> bootNodes;
@ -94,6 +97,11 @@ public class EthNetworkConfig {
return new EthNetworkConfig(genesisConfig, RINKEBY_NETWORK_ID, RINKEBY_BOOTSTRAP_NODES); return new EthNetworkConfig(genesisConfig, RINKEBY_NETWORK_ID, RINKEBY_BOOTSTRAP_NODES);
} }
public static EthNetworkConfig ropsten() {
final URI genesisConfig = jsonConfigURI(ROPSTEN_GENESIS);
return new EthNetworkConfig(genesisConfig, ROPSTEN_NETWORK_ID, ROPSTEN_BOOTSTRAP_NODES);
}
private static URI jsonConfigURI(final String resourceName) { private static URI jsonConfigURI(final String resourceName) {
try { try {
return Resources.getResource(resourceName).toURI(); return Resources.getResource(resourceName).toURI();

@ -230,6 +230,12 @@ public class PantheonCommand implements Runnable {
) )
private final Boolean rinkeby = false; private final Boolean rinkeby = false;
@Option(
names = {"--ropsten"},
description = "Use the Ropsten test network (default: ${DEFAULT-VALUE})"
)
private final Boolean ropsten = false;
@Option( @Option(
names = {"--p2p-listen"}, names = {"--p2p-listen"},
paramLabel = MANDATORY_HOST_AND_PORT_FORMAT_HELP, paramLabel = MANDATORY_HOST_AND_PORT_FORMAT_HELP,
@ -410,6 +416,11 @@ public class PantheonCommand implements Runnable {
+ "or specify the beneficiary of mining (via --miner-coinbase <Address>)"); + "or specify the beneficiary of mining (via --miner-coinbase <Address>)");
return; return;
} }
if (ropsten && rinkeby) {
System.out.println(
"Unable to connect to multiple networks simultaneously. Remove one of --ropsten or --rinkeby");
return;
}
final EthNetworkConfig ethNetworkConfig = ethNetworkConfig(); final EthNetworkConfig ethNetworkConfig = ethNetworkConfig();
synchronize( synchronize(
buildController(), buildController(),
@ -562,8 +573,14 @@ public class PantheonCommand implements Runnable {
} }
private EthNetworkConfig ethNetworkConfig() { private EthNetworkConfig ethNetworkConfig() {
final EthNetworkConfig predefinedNetworkConfig = final EthNetworkConfig predefinedNetworkConfig;
rinkeby ? EthNetworkConfig.rinkeby() : EthNetworkConfig.mainnet(); if (rinkeby) {
predefinedNetworkConfig = EthNetworkConfig.rinkeby();
} else if (ropsten) {
predefinedNetworkConfig = EthNetworkConfig.ropsten();
} else {
predefinedNetworkConfig = EthNetworkConfig.mainnet();
}
return updateNetworkConfig(predefinedNetworkConfig); return updateNetworkConfig(predefinedNetworkConfig);
} }

@ -61,7 +61,6 @@ import io.vertx.core.json.JsonObject;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
public class CliquePantheonController implements PantheonController<CliqueContext> { public class CliquePantheonController implements PantheonController<CliqueContext> {
public static int RINKEBY_NETWORK_ID = 4;
private static final Logger LOG = getLogger(); private static final Logger LOG = getLogger();
private final GenesisConfig<CliqueContext> genesisConfig; private final GenesisConfig<CliqueContext> genesisConfig;
private final ProtocolContext<CliqueContext> context; private final ProtocolContext<CliqueContext> context;

@ -58,7 +58,6 @@ import org.apache.logging.log4j.Logger;
public class MainnetPantheonController implements PantheonController<Void> { public class MainnetPantheonController implements PantheonController<Void> {
private static final Logger LOG = LogManager.getLogger(); private static final Logger LOG = LogManager.getLogger();
public static final int MAINNET_NETWORK_ID = 1;
private final GenesisConfig<Void> genesisConfig; private final GenesisConfig<Void> genesisConfig;
private final ProtocolContext<Void> protocolContext; private final ProtocolContext<Void> protocolContext;

Loading…
Cancel
Save