From f415317d385411cb57ea964550e0a10450d992db Mon Sep 17 00:00:00 2001 From: Meredith Baxter Date: Tue, 2 Jul 2019 11:38:28 -0400 Subject: [PATCH] Remove NetworkingOptions --- .../acceptance/dsl/node/PantheonNode.java | 8 -- .../dsl/node/ProcessPantheonNodeRunner.java | 5 - .../dsl/node/ThreadPantheonNodeRunner.java | 1 - .../PantheonFactoryConfiguration.java | 8 -- .../PantheonFactoryConfigurationBuilder.java | 9 -- .../configuration/PantheonNodeFactory.java | 1 - .../PrivacyPantheonFactoryConfiguration.java | 3 - ...cyPantheonFactoryConfigurationBuilder.java | 1 - .../privacy/PrivacyPantheonNodeFactory.java | 1 - .../acceptance/dsl/privacy/PrivacyNode.java | 3 - .../p2p/config/NetworkingConfiguration.java | 32 +----- .../p2p/network/DefaultP2PNetwork.java | 8 +- .../tech/pegasys/pantheon/RunnerBuilder.java | 14 +-- .../pegasys/pantheon/cli/PantheonCommand.java | 5 - .../cli/options/NetworkingOptions.java | 79 --------------- .../pantheon/cli/CommandTestAbstract.java | 6 -- .../cli/options/NetworkingOptionsTest.java | 97 ------------------- 17 files changed, 9 insertions(+), 272 deletions(-) delete mode 100644 pantheon/src/main/java/tech/pegasys/pantheon/cli/options/NetworkingOptions.java delete mode 100644 pantheon/src/test/java/tech/pegasys/pantheon/cli/options/NetworkingOptionsTest.java diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java index 894bbfc0cc..21b17968e4 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java @@ -24,7 +24,6 @@ import tech.pegasys.pantheon.ethereum.core.Util; import tech.pegasys.pantheon.ethereum.jsonrpc.JsonRpcConfiguration; import tech.pegasys.pantheon.ethereum.jsonrpc.websocket.WebSocketConfiguration; -import tech.pegasys.pantheon.ethereum.p2p.config.NetworkingConfiguration; import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration; import tech.pegasys.pantheon.metrics.prometheus.MetricsConfiguration; import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition; @@ -79,7 +78,6 @@ public class PantheonNode implements NodeConfiguration, RunnableNode, AutoClosea private final KeyPair keyPair; private final Properties portsProperties = new Properties(); private final Boolean p2pEnabled; - private final NetworkingConfiguration networkingConfiguration; private final String name; private final MiningParameters miningParameters; @@ -114,7 +112,6 @@ public PantheonNode( final boolean devMode, final GenesisConfigurationProvider genesisConfigProvider, final boolean p2pEnabled, - final NetworkingConfiguration networkingConfiguration, final boolean discoveryEnabled, final boolean bootnodeEligible, final List plugins, @@ -142,7 +139,6 @@ public PantheonNode( this.genesisConfigProvider = genesisConfigProvider; this.devMode = devMode; this.p2pEnabled = p2pEnabled; - this.networkingConfiguration = networkingConfiguration; this.discoveryEnabled = discoveryEnabled; plugins.forEach( pluginName -> { @@ -476,10 +472,6 @@ public boolean isP2pEnabled() { return p2pEnabled; } - public NetworkingConfiguration getNetworkingConfiguration() { - return networkingConfiguration; - } - @Override public boolean isBootnodeEligible() { return bootnodeEligible; diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ProcessPantheonNodeRunner.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ProcessPantheonNodeRunner.java index 10da4b6972..081bc8cfc4 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ProcessPantheonNodeRunner.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ProcessPantheonNodeRunner.java @@ -14,7 +14,6 @@ import static java.nio.charset.StandardCharsets.UTF_8; -import tech.pegasys.pantheon.cli.options.NetworkingOptions; import tech.pegasys.pantheon.ethereum.jsonrpc.RpcApi; import tech.pegasys.pantheon.ethereum.jsonrpc.RpcApis; import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration; @@ -144,10 +143,6 @@ public void startNode(final PantheonNode node) { if (!node.isP2pEnabled()) { params.add("--p2p-enabled"); params.add("false"); - } else { - final List networkConfigParams = - NetworkingOptions.fromConfig(node.getNetworkingConfiguration()).getCLIOptions(); - params.addAll(networkConfigParams); } node.getPermissioningConfiguration() diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java index 4ff4ea2f4c..267eee6f31 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java @@ -145,7 +145,6 @@ public void startNode(final PantheonNode node) { .p2pAdvertisedHost(node.getHostName()) .p2pListenPort(0) .maxPeers(25) - .networkingConfiguration(node.getNetworkingConfiguration()) .jsonRpcConfiguration(node.jsonRpcConfiguration()) .webSocketConfiguration(node.webSocketConfiguration()) .dataDir(node.homeDirectory()) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/configuration/PantheonFactoryConfiguration.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/configuration/PantheonFactoryConfiguration.java index d3aea06527..1e486075fc 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/configuration/PantheonFactoryConfiguration.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/configuration/PantheonFactoryConfiguration.java @@ -16,7 +16,6 @@ import tech.pegasys.pantheon.ethereum.core.PrivacyParameters; import tech.pegasys.pantheon.ethereum.jsonrpc.JsonRpcConfiguration; import tech.pegasys.pantheon.ethereum.jsonrpc.websocket.WebSocketConfiguration; -import tech.pegasys.pantheon.ethereum.p2p.config.NetworkingConfiguration; import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration; import tech.pegasys.pantheon.metrics.prometheus.MetricsConfiguration; import tech.pegasys.pantheon.tests.acceptance.dsl.node.configuration.genesis.GenesisConfigurationProvider; @@ -37,7 +36,6 @@ public class PantheonFactoryConfiguration { private final boolean devMode; private final GenesisConfigurationProvider genesisConfigProvider; private final boolean p2pEnabled; - private final NetworkingConfiguration networkingConfiguration; private final boolean discoveryEnabled; private final boolean bootnodeEligible; private final List plugins; @@ -55,7 +53,6 @@ public PantheonFactoryConfiguration( final boolean devMode, final GenesisConfigurationProvider genesisConfigProvider, final boolean p2pEnabled, - final NetworkingConfiguration networkingConfiguration, final boolean discoveryEnabled, final boolean bootnodeEligible, final List plugins, @@ -71,7 +68,6 @@ public PantheonFactoryConfiguration( this.devMode = devMode; this.genesisConfigProvider = genesisConfigProvider; this.p2pEnabled = p2pEnabled; - this.networkingConfiguration = networkingConfiguration; this.discoveryEnabled = discoveryEnabled; this.bootnodeEligible = bootnodeEligible; this.plugins = plugins; @@ -126,10 +122,6 @@ public boolean isP2pEnabled() { return p2pEnabled; } - public NetworkingConfiguration getNetworkingConfiguration() { - return networkingConfiguration; - } - public boolean isBootnodeEligible() { return bootnodeEligible; } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/configuration/PantheonFactoryConfigurationBuilder.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/configuration/PantheonFactoryConfigurationBuilder.java index c0bec820f1..a673c26b30 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/configuration/PantheonFactoryConfigurationBuilder.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/configuration/PantheonFactoryConfigurationBuilder.java @@ -20,7 +20,6 @@ import tech.pegasys.pantheon.ethereum.jsonrpc.JsonRpcConfiguration; import tech.pegasys.pantheon.ethereum.jsonrpc.RpcApis; import tech.pegasys.pantheon.ethereum.jsonrpc.websocket.WebSocketConfiguration; -import tech.pegasys.pantheon.ethereum.p2p.config.NetworkingConfiguration; import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration; import tech.pegasys.pantheon.metrics.prometheus.MetricsConfiguration; import tech.pegasys.pantheon.tests.acceptance.dsl.node.configuration.genesis.GenesisConfigurationProvider; @@ -46,18 +45,11 @@ public class PantheonFactoryConfigurationBuilder { private boolean devMode = true; private GenesisConfigurationProvider genesisConfigProvider = ignore -> Optional.empty(); private Boolean p2pEnabled = true; - private NetworkingConfiguration networkingConfiguration = NetworkingConfiguration.create(); private boolean discoveryEnabled = true; private boolean bootnodeEligible = true; private List plugins = new ArrayList<>(); private List extraCLIOptions = new ArrayList<>(); - public PantheonFactoryConfigurationBuilder() { - // Check connections more frequently during acceptance tests to cut down on - // intermittent failures due to the fact that we're running over a real network - networkingConfiguration.setInitiateConnectionsFrequency(5); - } - public PantheonFactoryConfigurationBuilder name(final String name) { this.name = name; return this; @@ -200,7 +192,6 @@ public PantheonFactoryConfiguration build() { devMode, genesisConfigProvider, p2pEnabled, - networkingConfiguration, discoveryEnabled, bootnodeEligible, plugins, diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/configuration/PantheonNodeFactory.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/configuration/PantheonNodeFactory.java index 9606263d87..aded2d7499 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/configuration/PantheonNodeFactory.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/configuration/PantheonNodeFactory.java @@ -44,7 +44,6 @@ public PantheonNode create(final PantheonFactoryConfiguration config) throws IOE config.isDevMode(), config.getGenesisConfigProvider(), config.isP2pEnabled(), - config.getNetworkingConfiguration(), config.isDiscoveryEnabled(), config.isBootnodeEligible(), config.getPlugins(), diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/configuration/privacy/PrivacyPantheonFactoryConfiguration.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/configuration/privacy/PrivacyPantheonFactoryConfiguration.java index f9fd3aac1b..c379e963e9 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/configuration/privacy/PrivacyPantheonFactoryConfiguration.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/configuration/privacy/PrivacyPantheonFactoryConfiguration.java @@ -17,7 +17,6 @@ import tech.pegasys.pantheon.ethereum.core.PrivacyParameters; import tech.pegasys.pantheon.ethereum.jsonrpc.JsonRpcConfiguration; import tech.pegasys.pantheon.ethereum.jsonrpc.websocket.WebSocketConfiguration; -import tech.pegasys.pantheon.ethereum.p2p.config.NetworkingConfiguration; import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration; import tech.pegasys.pantheon.metrics.prometheus.MetricsConfiguration; import tech.pegasys.pantheon.tests.acceptance.dsl.node.configuration.PantheonFactoryConfiguration; @@ -42,7 +41,6 @@ public class PrivacyPantheonFactoryConfiguration extends PantheonFactoryConfigur final boolean devMode, final GenesisConfigurationProvider genesisConfigProvider, final boolean p2pEnabled, - final NetworkingConfiguration networkingConfiguration, final boolean discoveryEnabled, final boolean bootnodeEligible, final List plugins, @@ -60,7 +58,6 @@ public class PrivacyPantheonFactoryConfiguration extends PantheonFactoryConfigur devMode, genesisConfigProvider, p2pEnabled, - networkingConfiguration, discoveryEnabled, bootnodeEligible, plugins, diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/configuration/privacy/PrivacyPantheonFactoryConfigurationBuilder.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/configuration/privacy/PrivacyPantheonFactoryConfigurationBuilder.java index 34aeef9639..927062c3e6 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/configuration/privacy/PrivacyPantheonFactoryConfigurationBuilder.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/configuration/privacy/PrivacyPantheonFactoryConfigurationBuilder.java @@ -44,7 +44,6 @@ public PrivacyPantheonFactoryConfiguration build() { config.isDevMode(), config.getGenesisConfigProvider(), config.isP2pEnabled(), - config.getNetworkingConfiguration(), config.isDiscoveryEnabled(), config.isBootnodeEligible(), config.getPlugins(), diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/configuration/privacy/PrivacyPantheonNodeFactory.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/configuration/privacy/PrivacyPantheonNodeFactory.java index 9971d92f2f..b7f43f4479 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/configuration/privacy/PrivacyPantheonNodeFactory.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/configuration/privacy/PrivacyPantheonNodeFactory.java @@ -40,7 +40,6 @@ private static PrivacyNode create(final PrivacyPantheonFactoryConfiguration conf config.isDevMode(), config.getGenesisConfigProvider(), config.isP2pEnabled(), - config.getNetworkingConfiguration(), config.isDiscoveryEnabled(), config.isBootnodeEligible(), config.getPlugins(), diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/privacy/PrivacyNode.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/privacy/PrivacyNode.java index 867fe2371c..10de64e65d 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/privacy/PrivacyNode.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/privacy/PrivacyNode.java @@ -22,7 +22,6 @@ import tech.pegasys.pantheon.ethereum.core.PrivacyParameters; import tech.pegasys.pantheon.ethereum.jsonrpc.JsonRpcConfiguration; import tech.pegasys.pantheon.ethereum.jsonrpc.websocket.WebSocketConfiguration; -import tech.pegasys.pantheon.ethereum.p2p.config.NetworkingConfiguration; import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration; import tech.pegasys.pantheon.metrics.prometheus.MetricsConfiguration; import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode; @@ -56,7 +55,6 @@ public PrivacyNode( final boolean devMode, final GenesisConfigurationProvider genesisConfigProvider, final boolean p2pEnabled, - final NetworkingConfiguration networkingConfiguration, final boolean discoveryEnabled, final boolean bootnodeEligible, final List plugins, @@ -75,7 +73,6 @@ public PrivacyNode( devMode, genesisConfigProvider, p2pEnabled, - networkingConfiguration, discoveryEnabled, bootnodeEligible, plugins, diff --git a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/config/NetworkingConfiguration.java b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/config/NetworkingConfiguration.java index 44d503d6c1..e2392a13f0 100644 --- a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/config/NetworkingConfiguration.java +++ b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/config/NetworkingConfiguration.java @@ -12,19 +12,13 @@ */ package tech.pegasys.pantheon.ethereum.p2p.config; -import static com.google.common.base.Preconditions.checkArgument; - import java.util.Objects; public class NetworkingConfiguration { - public static final int DEFAULT_INITIATE_CONNECTIONS_FREQUENCY_SEC = 30; - public static final int DEFAULT_CHECK_MAINTAINED_CONNECTSION_FREQUENCY_SEC = 60; - private DiscoveryConfiguration discovery = new DiscoveryConfiguration(); private RlpxConfiguration rlpx = new RlpxConfiguration(); - private int initiateConnectionsFrequencySec = DEFAULT_INITIATE_CONNECTIONS_FREQUENCY_SEC; - private int checkMaintainedConnectionsFrequencySec = - DEFAULT_CHECK_MAINTAINED_CONNECTSION_FREQUENCY_SEC; + + private NetworkingConfiguration() {} public static NetworkingConfiguration create() { return new NetworkingConfiguration(); @@ -48,28 +42,6 @@ public NetworkingConfiguration setRlpx(final RlpxConfiguration rlpx) { return this; } - public int getInitiateConnectionsFrequencySec() { - return initiateConnectionsFrequencySec; - } - - public NetworkingConfiguration setInitiateConnectionsFrequency( - final int initiateConnectionsFrequency) { - checkArgument(initiateConnectionsFrequency > 0); - this.initiateConnectionsFrequencySec = initiateConnectionsFrequency; - return this; - } - - public int getCheckMaintainedConnectionsFrequencySec() { - return checkMaintainedConnectionsFrequencySec; - } - - public NetworkingConfiguration setCheckMaintainedConnectionsFrequency( - final int checkMaintainedConnectionsFrequency) { - checkArgument(checkMaintainedConnectionsFrequency > 0); - this.checkMaintainedConnectionsFrequencySec = checkMaintainedConnectionsFrequency; - return this; - } - @Override public boolean equals(final Object o) { if (o == this) { diff --git a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/network/DefaultP2PNetwork.java b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/network/DefaultP2PNetwork.java index b8b2713ca9..de69148d98 100644 --- a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/network/DefaultP2PNetwork.java +++ b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/network/DefaultP2PNetwork.java @@ -181,14 +181,10 @@ public void start() { peerBondedObserverId = OptionalLong.of(peerDiscoveryAgent.observePeerBondedEvents(this::handlePeerBondedEvent)); - // Periodically check maintained connections - final int checkMaintainedConnectionsSec = config.getCheckMaintainedConnectionsFrequencySec(); peerConnectionScheduler.scheduleWithFixedDelay( - this::checkMaintainedConnectionPeers, 2, checkMaintainedConnectionsSec, TimeUnit.SECONDS); - // Periodically initiate outgoing connections to discovered peers - final int checkConnectionsSec = config.getInitiateConnectionsFrequencySec(); + this::checkMaintainedConnectionPeers, 2, 60, TimeUnit.SECONDS); peerConnectionScheduler.scheduleWithFixedDelay( - this::attemptPeerConnections, checkConnectionsSec, checkConnectionsSec, TimeUnit.SECONDS); + this::attemptPeerConnections, 30, 30, TimeUnit.SECONDS); } @Override diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java b/pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java index d0bddac3c8..2ae37745a6 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java @@ -105,7 +105,6 @@ public class RunnerBuilder { private Vertx vertx; private PantheonController pantheonController; - private NetworkingConfiguration networkingConfiguration = NetworkingConfiguration.create(); private Collection bannedNodeIds = new ArrayList<>(); private boolean p2pEnabled = true; private boolean discovery; @@ -148,12 +147,6 @@ public RunnerBuilder ethNetworkConfig(final EthNetworkConfig ethNetworkConfig) { return this; } - public RunnerBuilder networkingConfiguration( - final NetworkingConfiguration networkingConfiguration) { - this.networkingConfiguration = networkingConfiguration; - return this; - } - public RunnerBuilder p2pAdvertisedHost(final String p2pAdvertisedHost) { this.p2pAdvertisedHost = p2pAdvertisedHost; return this; @@ -257,7 +250,10 @@ public Runner build() { .setMaxPeers(maxPeers) .setSupportedProtocols(subProtocols) .setClientId(PantheonInfo.version()); - networkingConfiguration.setRlpx(rlpxConfiguration).setDiscovery(discoveryConfiguration); + final NetworkingConfiguration networkConfig = + NetworkingConfiguration.create() + .setRlpx(rlpxConfiguration) + .setDiscovery(discoveryConfiguration); final PeerPermissionsBlacklist bannedNodes = PeerPermissionsBlacklist.create(); bannedNodeIds.forEach(bannedNodes::add); @@ -287,7 +283,7 @@ public Runner build() { DefaultP2PNetwork.builder() .vertx(vertx) .keyPair(keyPair) - .config(networkingConfiguration) + .config(networkConfig) .peerPermissions(peerPermissions) .metricsSystem(metricsSystem) .supportedCapabilities(caps) 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 11a64514fa..fbce3e1563 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java @@ -39,7 +39,6 @@ import tech.pegasys.pantheon.cli.custom.RpcAuthFileValidator; import tech.pegasys.pantheon.cli.operator.OperatorSubCommand; import tech.pegasys.pantheon.cli.options.EthProtocolOptions; -import tech.pegasys.pantheon.cli.options.NetworkingOptions; import tech.pegasys.pantheon.cli.options.RocksDBOptions; import tech.pegasys.pantheon.cli.options.SynchronizerOptions; import tech.pegasys.pantheon.cli.options.TransactionPoolOptions; @@ -143,7 +142,6 @@ public class PantheonCommand implements DefaultCommandValues, Runnable { private final BlockImporter blockImporter; - final NetworkingOptions networkingOptions = NetworkingOptions.create(); final SynchronizerOptions synchronizerOptions = SynchronizerOptions.create(); final EthProtocolOptions ethProtocolOptions = EthProtocolOptions.create(); final RocksDBOptions rocksDBOptions = RocksDBOptions.create(); @@ -702,8 +700,6 @@ private PantheonCommand handleUnstableOptions() { UnstableOptionsSubCommand.createUnstableOptions( commandLine, ImmutableMap.of( - "P2P Network", - networkingOptions, "Synchronizer", synchronizerOptions, "RocksDB", @@ -1171,7 +1167,6 @@ private void synchronize( .p2pAdvertisedHost(p2pAdvertisedHost) .p2pListenPort(p2pListenPort) .maxPeers(maxPeers) - .networkingConfiguration(networkingOptions.toDomainObject()) .graphQLConfiguration(graphQLConfiguration) .jsonRpcConfiguration(jsonRpcConfiguration) .webSocketConfiguration(webSocketConfiguration) diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/options/NetworkingOptions.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/options/NetworkingOptions.java deleted file mode 100644 index 888133aab6..0000000000 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/options/NetworkingOptions.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2019 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package tech.pegasys.pantheon.cli.options; - -import tech.pegasys.pantheon.ethereum.p2p.config.NetworkingConfiguration; - -import java.util.Arrays; -import java.util.List; - -import picocli.CommandLine; - -public class NetworkingOptions implements CLIOptions { - private final String INITIATE_CONNECTIONS_FREQUENCY_FLAG = - "--Xp2p-initiate-connections-frequency"; - private final String CHECK_MAINTAINED_CONNECTIONS_FREQUENCY_FLAG = - "--Xp2p-check-maintained-connections-frequency"; - - @CommandLine.Option( - names = INITIATE_CONNECTIONS_FREQUENCY_FLAG, - hidden = true, - defaultValue = "30", - paramLabel = "", - description = - "The frequency (in seconds) at which to initiate new outgoing connections (default: ${DEFAULT-VALUE})") - private int initiateConnectionsFrequencySec = - NetworkingConfiguration.DEFAULT_INITIATE_CONNECTIONS_FREQUENCY_SEC; - - @CommandLine.Option( - names = CHECK_MAINTAINED_CONNECTIONS_FREQUENCY_FLAG, - hidden = true, - defaultValue = "60", - paramLabel = "", - description = - "The frequency (in seconds) at which to check maintained connections (default: ${DEFAULT-VALUE})") - private int checkMaintainedConnectionsFrequencySec = - NetworkingConfiguration.DEFAULT_CHECK_MAINTAINED_CONNECTSION_FREQUENCY_SEC; - - private NetworkingOptions() {} - - public static NetworkingOptions create() { - return new NetworkingOptions(); - } - - public static NetworkingOptions fromConfig(final NetworkingConfiguration networkingConfig) { - final NetworkingOptions cliOptions = new NetworkingOptions(); - cliOptions.checkMaintainedConnectionsFrequencySec = - networkingConfig.getCheckMaintainedConnectionsFrequencySec(); - cliOptions.initiateConnectionsFrequencySec = - networkingConfig.getInitiateConnectionsFrequencySec(); - return cliOptions; - } - - @Override - public NetworkingConfiguration toDomainObject() { - NetworkingConfiguration config = NetworkingConfiguration.create(); - config.setCheckMaintainedConnectionsFrequency(checkMaintainedConnectionsFrequencySec); - config.setInitiateConnectionsFrequency(initiateConnectionsFrequencySec); - return config; - } - - @Override - public List getCLIOptions() { - return Arrays.asList( - CHECK_MAINTAINED_CONNECTIONS_FREQUENCY_FLAG, - OptionParser.format(checkMaintainedConnectionsFrequencySec), - INITIATE_CONNECTIONS_FREQUENCY_FLAG, - OptionParser.format(initiateConnectionsFrequencySec)); - } -} diff --git a/pantheon/src/test/java/tech/pegasys/pantheon/cli/CommandTestAbstract.java b/pantheon/src/test/java/tech/pegasys/pantheon/cli/CommandTestAbstract.java index 76d54e4775..9748f08be7 100644 --- a/pantheon/src/test/java/tech/pegasys/pantheon/cli/CommandTestAbstract.java +++ b/pantheon/src/test/java/tech/pegasys/pantheon/cli/CommandTestAbstract.java @@ -24,7 +24,6 @@ import tech.pegasys.pantheon.RunnerBuilder; import tech.pegasys.pantheon.cli.PublicKeySubCommand.KeyLoader; import tech.pegasys.pantheon.cli.options.EthProtocolOptions; -import tech.pegasys.pantheon.cli.options.NetworkingOptions; import tech.pegasys.pantheon.cli.options.RocksDBOptions; import tech.pegasys.pantheon.cli.options.SynchronizerOptions; import tech.pegasys.pantheon.cli.options.TransactionPoolOptions; @@ -153,7 +152,6 @@ public void initMocks() throws Exception { when(mockRunnerBuilder.pantheonController(any())).thenReturn(mockRunnerBuilder); when(mockRunnerBuilder.discovery(anyBoolean())).thenReturn(mockRunnerBuilder); when(mockRunnerBuilder.ethNetworkConfig(any())).thenReturn(mockRunnerBuilder); - when(mockRunnerBuilder.networkingConfiguration(any())).thenReturn(mockRunnerBuilder); when(mockRunnerBuilder.p2pAdvertisedHost(anyString())).thenReturn(mockRunnerBuilder); when(mockRunnerBuilder.p2pListenPort(anyInt())).thenReturn(mockRunnerBuilder); when(mockRunnerBuilder.maxPeers(anyInt())).thenReturn(mockRunnerBuilder); @@ -258,10 +256,6 @@ public RocksDBOptions getRocksDBOptions() { return rocksDBOptions; } - public NetworkingOptions getNetworkingOptions() { - return networkingOptions; - } - public SynchronizerOptions getSynchronizerOptions() { return synchronizerOptions; } diff --git a/pantheon/src/test/java/tech/pegasys/pantheon/cli/options/NetworkingOptionsTest.java b/pantheon/src/test/java/tech/pegasys/pantheon/cli/options/NetworkingOptionsTest.java deleted file mode 100644 index 5a0208e437..0000000000 --- a/pantheon/src/test/java/tech/pegasys/pantheon/cli/options/NetworkingOptionsTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2019 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package tech.pegasys.pantheon.cli.options; - -import static org.assertj.core.api.Assertions.assertThat; - -import tech.pegasys.pantheon.ethereum.p2p.config.NetworkingConfiguration; - -import org.junit.Test; - -public class NetworkingOptionsTest - extends AbstractCLIOptionsTest { - - @Test - public void checkMaintainedConnectionsFrequencyFlag_isSet() { - final TestPantheonCommand cmd = - parseCommand("--Xp2p-check-maintained-connections-frequency", "2"); - - final NetworkingOptions options = cmd.getNetworkingOptions(); - final NetworkingConfiguration networkingConfig = options.toDomainObject(); - assertThat(networkingConfig.getCheckMaintainedConnectionsFrequencySec()).isEqualTo(2); - - assertThat(commandErrorOutput.toString()).isEmpty(); - assertThat(commandOutput.toString()).isEmpty(); - } - - @Test - public void checkMaintainedFrequencyConnectionsFlag_isNotSet() { - final TestPantheonCommand cmd = parseCommand(); - - final NetworkingOptions options = cmd.getNetworkingOptions(); - final NetworkingConfiguration networkingConfig = options.toDomainObject(); - assertThat(networkingConfig.getCheckMaintainedConnectionsFrequencySec()).isEqualTo(60); - - assertThat(commandErrorOutput.toString()).isEmpty(); - assertThat(commandOutput.toString()).isEmpty(); - } - - @Test - public void initiateConnectionsFrequencyFlag_isSet() { - final TestPantheonCommand cmd = parseCommand("--Xp2p-initiate-connections-frequency", "2"); - - final NetworkingOptions options = cmd.getNetworkingOptions(); - final NetworkingConfiguration networkingConfig = options.toDomainObject(); - assertThat(networkingConfig.getInitiateConnectionsFrequencySec()).isEqualTo(2); - - assertThat(commandErrorOutput.toString()).isEmpty(); - assertThat(commandOutput.toString()).isEmpty(); - } - - @Test - public void initiateConnectionsFrequencyFlag_isNotSet() { - final TestPantheonCommand cmd = parseCommand(); - - final NetworkingOptions options = cmd.getNetworkingOptions(); - final NetworkingConfiguration networkingConfig = options.toDomainObject(); - assertThat(networkingConfig.getInitiateConnectionsFrequencySec()).isEqualTo(30); - - assertThat(commandErrorOutput.toString()).isEmpty(); - assertThat(commandOutput.toString()).isEmpty(); - } - - @Override - NetworkingConfiguration createDefaultDomainObject() { - return NetworkingConfiguration.create(); - } - - @Override - NetworkingConfiguration createCustomizedDomainObject() { - final NetworkingConfiguration config = NetworkingConfiguration.create(); - config.setInitiateConnectionsFrequency( - NetworkingConfiguration.DEFAULT_INITIATE_CONNECTIONS_FREQUENCY_SEC + 10); - config.setCheckMaintainedConnectionsFrequency( - NetworkingConfiguration.DEFAULT_CHECK_MAINTAINED_CONNECTSION_FREQUENCY_SEC + 10); - return config; - } - - @Override - NetworkingOptions optionsFromDomainObject(final NetworkingConfiguration domainObject) { - return NetworkingOptions.fromConfig(domainObject); - } - - @Override - NetworkingOptions getOptionsFromPantheonCommand(final TestPantheonCommand pantheonCommand) { - return pantheonCommand.getNetworkingOptions(); - } -}