From 4423ba3fb9e9fedfcac494e3271b45c38a2f87fc Mon Sep 17 00:00:00 2001 From: Jussi Virtanen Date: Sat, 27 Oct 2018 21:46:51 +0300 Subject: [PATCH] Add --ropsten command line argument --- .../ethereum/p2p/config/DiscoveryConfiguration.java | 7 +++++++ .../tech/pegasys/pantheon/cli/EthNetworkConfig.java | 8 ++++++++ .../tech/pegasys/pantheon/cli/PantheonCommand.java | 10 +++++++++- .../pantheon/controller/MainnetPantheonController.java | 1 + 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/config/DiscoveryConfiguration.java b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/config/DiscoveryConfiguration.java index 44c5060996..9712b24c45 100644 --- a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/config/DiscoveryConfiguration.java +++ b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/config/DiscoveryConfiguration.java @@ -44,6 +44,13 @@ public class DiscoveryConfiguration { "enode://b6b28890b006743680c52e64e0d16db57f28124885595fa03a562be1d2bf0f3a1da297d56b13da25fb992888fd556d4c1a27b1f39d531bde7de1921c90061cc6@159.89.28.211:30303") .map(DefaultPeer::fromURI) .collect(toList())); + public static List 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 String bindHost = "0.0.0.0"; diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/EthNetworkConfig.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/EthNetworkConfig.java index 4a57341c80..8a77053eef 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/EthNetworkConfig.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/EthNetworkConfig.java @@ -14,8 +14,10 @@ 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.controller.MainnetPantheonController.ROPSTEN_NETWORK_ID; 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.ROPSTEN_BOOTSTRAP_NODES; import java.net.URI; import java.net.URISyntaxException; @@ -28,6 +30,7 @@ public class EthNetworkConfig { private static final String MAINNET_GENESIS = "mainnet.json"; private static final String RINKEBY_GENESIS = "rinkeby.json"; + private static final String ROPSTEN_GENESIS = "ropsten.json"; private final URI genesisConfig; private final int networkId; private final Collection bootNodes; @@ -94,6 +97,11 @@ public static EthNetworkConfig rinkeby() { 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) { try { return Resources.getResource(resourceName).toURI(); diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java index 3c5f7dd69a..e90564dd64 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java @@ -230,6 +230,12 @@ public static class RpcApisConversionException extends Exception { ) private final Boolean rinkeby = false; + @Option( + names = {"--ropsten"}, + description = "Use the Ropsten test network (default: ${DEFAULT-VALUE})" + ) + private final Boolean ropsten = false; + @Option( names = {"--p2p-listen"}, paramLabel = MANDATORY_HOST_AND_PORT_FORMAT_HELP, @@ -563,7 +569,9 @@ private Path getDefaultPantheonDataDir() { private EthNetworkConfig ethNetworkConfig() { final EthNetworkConfig predefinedNetworkConfig = - rinkeby ? EthNetworkConfig.rinkeby() : EthNetworkConfig.mainnet(); + rinkeby + ? EthNetworkConfig.rinkeby() + : ropsten ? EthNetworkConfig.ropsten() : EthNetworkConfig.mainnet(); return updateNetworkConfig(predefinedNetworkConfig); } diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/controller/MainnetPantheonController.java b/pantheon/src/main/java/tech/pegasys/pantheon/controller/MainnetPantheonController.java index fbfd18bb66..22b9f6a9f0 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/controller/MainnetPantheonController.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/controller/MainnetPantheonController.java @@ -59,6 +59,7 @@ public class MainnetPantheonController implements PantheonController { private static final Logger LOG = LogManager.getLogger(); public static final int MAINNET_NETWORK_ID = 1; + public static final int ROPSTEN_NETWORK_ID = 3; private final GenesisConfig genesisConfig; private final ProtocolContext protocolContext;