Skip to content

Commit

Permalink
Fix experimental options not correctly displayed (#1366)
Browse files Browse the repository at this point in the history
Signed-off-by: Karim TAAM <[email protected]>
  • Loading branch information
matkt authored Sep 9, 2020
1 parent 9fe5f6f commit daca96e
Show file tree
Hide file tree
Showing 23 changed files with 420 additions and 166 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import static com.google.common.base.Preconditions.checkState;
import static java.nio.charset.StandardCharsets.UTF_8;

import org.hyperledger.besu.cli.options.NetworkingOptions;
import org.hyperledger.besu.cli.options.unstable.NetworkingOptions;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcApi;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis;
import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration;
Expand Down
187 changes: 59 additions & 128 deletions besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright 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.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.unstable;

import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeDnsConfiguration;
import org.hyperledger.besu.ethereum.p2p.peers.ImmutableEnodeDnsConfiguration;

import java.util.Arrays;
import java.util.List;

import picocli.CommandLine;

public class DnsOptions implements CLIOptions<EnodeDnsConfiguration> {

private final String DNS_ENABLED = "--Xdns-enabled";
private final String DNS_UPDATE_ENABLED = "--Xdns-update-enabled";

@CommandLine.Option(
hidden = true,
names = {"--Xdns-enabled"},
description = "Enabled DNS support",
arity = "1")
private Boolean dnsEnabled = Boolean.FALSE;

@CommandLine.Option(
hidden = true,
names = {"--Xdns-update-enabled"},
description = "Allow to detect an IP update automatically",
arity = "1")
private Boolean dnsUpdateEnabled = Boolean.FALSE;

public static DnsOptions create() {
return new DnsOptions();
}

public static DnsOptions fromConfig(final EnodeDnsConfiguration enodeDnsConfiguration) {
final DnsOptions cliOptions = new DnsOptions();
cliOptions.dnsEnabled = enodeDnsConfiguration.dnsEnabled();
cliOptions.dnsUpdateEnabled = enodeDnsConfiguration.updateEnabled();
return cliOptions;
}

public Boolean getDnsEnabled() {
return dnsEnabled;
}

public Boolean getDnsUpdateEnabled() {
return dnsUpdateEnabled;
}

@Override
public EnodeDnsConfiguration toDomainObject() {
return ImmutableEnodeDnsConfiguration.builder()
.updateEnabled(dnsUpdateEnabled)
.dnsEnabled(dnsEnabled)
.build();
}

@Override
public List<String> getCLIOptions() {
return Arrays.asList(
DNS_ENABLED, dnsEnabled.toString(), DNS_UPDATE_ENABLED, dnsUpdateEnabled.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options;
package org.hyperledger.besu.cli.options.unstable;

import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.cli.options.OptionParser;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.util.number.PositiveNumber;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options;
package org.hyperledger.besu.cli.options.unstable;

import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.ethstats.util.NetstatsUrl;

import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options;
package org.hyperledger.besu.cli.options.unstable;

import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;

import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 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.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.unstable;

import static org.hyperledger.besu.ethereum.core.MiningParameters.DEFAULT_REMOTE_SEALERS_LIMIT;
import static org.hyperledger.besu.ethereum.core.MiningParameters.DEFAULT_REMOTE_SEALERS_TTL;

import picocli.CommandLine;

public class MiningOptions {

@CommandLine.Option(
hidden = true,
names = {"--Xminer-remote-sealers-limit"},
description =
"Limits the number of remote sealers that can submit their hashrates (default: ${DEFAULT-VALUE})")
private final Integer remoteSealersLimit = DEFAULT_REMOTE_SEALERS_LIMIT;

@CommandLine.Option(
hidden = true,
names = {"--Xminer-remote-sealers-hashrate-ttl"},
description =
"Specifies the lifetime of each entry in the cache. An entry will be automatically deleted if no update has been received before the deadline (default: ${DEFAULT-VALUE} minutes)")
private final Long remoteSealersTimeToLive = DEFAULT_REMOTE_SEALERS_TTL;

@SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings.
@CommandLine.Option(
hidden = true,
names = {"--Xminer-stratum-extranonce"},
description = "Extranonce for Stratum network miners (default: ${DEFAULT-VALUE})")
private String stratumExtranonce = "080c";

public static MiningOptions create() {
return new MiningOptions();
}

public Integer getRemoteSealersLimit() {
return remoteSealersLimit;
}

public Long getRemoteSealersTimeToLive() {
return remoteSealersTimeToLive;
}

public String getStratumExtranonce() {
return stratumExtranonce;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright 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.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.unstable;

import static org.hyperledger.besu.nat.kubernetes.KubernetesNatManager.DEFAULT_BESU_SERVICE_NAME_FILTER;

import picocli.CommandLine;

public class NatOptions {

@SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings.
@CommandLine.Option(
hidden = true,
names = {"--Xnat-kube-service-name"},
description =
"Specify the name of the service that will be used by the nat manager in Kubernetes. (default: ${DEFAULT-VALUE})")
private String natManagerServiceName = DEFAULT_BESU_SERVICE_NAME_FILTER;

@CommandLine.Option(
hidden = true,
names = {"--Xnat-method-fallback-enabled"},
description =
"Enable fallback to NONE for the nat manager in case of failure. If False BESU will exit on failure. (default: ${DEFAULT-VALUE})",
arity = "1")
private final Boolean natMethodFallbackEnabled = true;

public static NatOptions create() {
return new NatOptions();
}

public String getNatManagerServiceName() {
return natManagerServiceName;
}

public Boolean getNatMethodFallbackEnabled() {
return natMethodFallbackEnabled;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 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.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.unstable;

import picocli.CommandLine;

public class NativeLibraryOptions {

@CommandLine.Option(
hidden = true,
names = {"--Xsecp256k1-native-enabled"},
description = "Path to PID file (optional)",
arity = "1")
private final Boolean nativeSecp256k1 = Boolean.TRUE;

@CommandLine.Option(
hidden = true,
names = {"--Xaltbn128-native-enabled"},
description = "Path to PID file (optional)",
arity = "1")
private final Boolean nativeAltbn128 = Boolean.TRUE;

public static NativeLibraryOptions create() {
return new NativeLibraryOptions();
}

public Boolean getNativeSecp256k1() {
return nativeSecp256k1;
}

public Boolean getNativeAltbn128() {
return nativeAltbn128;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options;
package org.hyperledger.besu.cli.options.unstable;

import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.cli.options.OptionParser;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;

import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 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.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.unstable;

import org.hyperledger.besu.ethereum.api.handlers.TimeoutOptions;

import picocli.CommandLine;

public class RPCOptions {

@CommandLine.Option(
hidden = true,
names = {"--Xhttp-timeout-seconds"},
description = "HTTP timeout in seconds (default: ${DEFAULT-VALUE})",
arity = "1")
private final Long httpTimeoutSec = TimeoutOptions.defaultOptions().getTimeoutSeconds();

@CommandLine.Option(
hidden = true,
names = {"--Xws-timeout-seconds"},
description = "Web socket timeout in seconds (default: ${DEFAULT-VALUE})",
arity = "1")
private final Long wsTimeoutSec = TimeoutOptions.defaultOptions().getTimeoutSeconds();

public static RPCOptions create() {
return new RPCOptions();
}

public Long getHttpTimeoutSec() {
return httpTimeoutSec;
}

public Long getWsTimeoutSec() {
return wsTimeoutSec;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options;
package org.hyperledger.besu.cli.options.unstable;

import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.cli.options.OptionParser;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;

import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options;
package org.hyperledger.besu.cli.options.unstable;

import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.cli.options.OptionParser;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;

import java.util.Arrays;
Expand Down
Loading

0 comments on commit daca96e

Please sign in to comment.