Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
NC-2104 Clique and iBFT should not be defined by default in RPC APIs (#…
Browse files Browse the repository at this point in the history
…635)

fixes NC-2104 remove Clique and iBFT defaults and centralise default values

As toString() is used to display default values in CLI description and this is
not used anywhere else for RpcApi objects, it may have been used for debug long
ago, but now we can use the simple string value as return from toString.
Then we are able to use the DEFAULT_JSON_RPC_APIS constant as default value
directly instead of hard coded defaults string in option that was probably used
because previous toString was not outputting correct representation. It may be
interesting to comment when some does this sort of hack.
  • Loading branch information
NicolasMassart authored Jan 24, 2019
1 parent 08d0848 commit 11de8af
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 25 deletions.
4 changes: 2 additions & 2 deletions docs/Reference/Pantheon-CLI-Syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ rpc-http-api=["ETH","NET","WEB3"]
Comma-separated APIs to enable on the HTTP JSON-RPC channel.
When you use this option, the `--rpc-http-enabled` option must also be specified.
The available API options are: `ADMIN`, `ETH`, `NET`, `WEB3`, `CLIQUE`, `IBFT`, `DEBUG`, and `MINER`.
The default is: `ETH`, `NET`, `WEB3`, `CLIQUE`, `IBFT`.
The default is: `ETH`, `NET`, `WEB3`.
!!!note
:construction: IBFT is not currently supported. Support for IBFT is in active development.
Expand Down Expand Up @@ -697,7 +697,7 @@ rpc-ws-api=["ETH","NET","WEB3"]
Comma-separated APIs to enable on Websockets channel.
When you use this option, the `--rpc-ws-enabled` option must also be specified.
The available API options are: `ETH`, `NET`, `WEB3`, `CLIQUE`, `IBFT`, `DEBUG`, and `MINER`.
The default is: `ETH`, `NET`, `WEB3`, `CLIQUE`, `IBFT`.
The default is: `ETH`, `NET`, `WEB3`.
!!!note
:construction: IBFT is not currently supported. Support for IBFT is in active development.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
package tech.pegasys.pantheon.ethereum.jsonrpc;

import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;

public class RpcApi {
Expand Down Expand Up @@ -45,6 +44,6 @@ public int hashCode() {

@Override
public String toString() {
return MoreObjects.toStringHelper(this).add("cliValue", cliValue).toString();
return cliValue;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import static tech.pegasys.pantheon.cli.DefaultCommandValues.getDefaultPantheonDataPath;
import static tech.pegasys.pantheon.cli.NetworkName.MAINNET;
import static tech.pegasys.pantheon.ethereum.jsonrpc.JsonRpcConfiguration.DEFAULT_JSON_RPC_PORT;
import static tech.pegasys.pantheon.ethereum.jsonrpc.RpcApis.DEFAULT_JSON_RPC_APIS;
import static tech.pegasys.pantheon.ethereum.jsonrpc.websocket.WebSocketConfiguration.DEFAULT_WEBSOCKET_PORT;
import static tech.pegasys.pantheon.ethereum.jsonrpc.websocket.WebSocketConfiguration.DEFAULT_WEBSOCKET_REFRESH_DELAY;
import static tech.pegasys.pantheon.ethereum.p2p.peers.DefaultPeer.DEFAULT_PORT;
Expand Down Expand Up @@ -336,10 +337,9 @@ public static class RpcApisConversionException extends Exception {
split = ",",
arity = "1..*",
converter = RpcApisConverter.class,
description = "Comma separated APIs to enable on JSON-RPC channel. default: ${DEFAULT-VALUE}",
defaultValue = "ETH,NET,WEB3,CLIQUE,IBFT"
description = "Comma separated APIs to enable on JSON-RPC channel. default: ${DEFAULT-VALUE}"
)
private final Collection<RpcApi> rpcHttpApis = null;
private final Collection<RpcApi> rpcHttpApis = DEFAULT_JSON_RPC_APIS;

@Option(
names = {"--rpc-ws-enabled"},
Expand Down Expand Up @@ -371,10 +371,9 @@ public static class RpcApisConversionException extends Exception {
split = ",",
arity = "1..*",
converter = RpcApisConverter.class,
description = "Comma separated APIs to enable on WebSocket channel. default: ${DEFAULT-VALUE}",
defaultValue = "ETH,NET,WEB3,CLIQUE,IBFT"
description = "Comma separated APIs to enable on WebSocket channel. default: ${DEFAULT-VALUE}"
)
private final Collection<RpcApi> rpcWsApis = null;
private final Collection<RpcApi> rpcWsApis = DEFAULT_JSON_RPC_APIS;

private Long rpcWsRefreshDelay;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import static tech.pegasys.pantheon.ethereum.p2p.config.DiscoveryConfiguration.MAINNET_BOOTSTRAP_NODES;

import tech.pegasys.pantheon.PantheonInfo;
import tech.pegasys.pantheon.consensus.clique.jsonrpc.CliqueRpcApis;
import tech.pegasys.pantheon.consensus.ibft.jsonrpc.IbftRpcApis;
import tech.pegasys.pantheon.ethereum.core.Address;
import tech.pegasys.pantheon.ethereum.core.MiningParameters;
import tech.pegasys.pantheon.ethereum.core.PrivacyParameters;
Expand Down Expand Up @@ -86,13 +84,9 @@ public class PantheonCommandTest extends CommandTestAbstract {

static {
final JsonRpcConfiguration rpcConf = JsonRpcConfiguration.createDefault();
rpcConf.addRpcApi(CliqueRpcApis.CLIQUE);
rpcConf.addRpcApi(IbftRpcApis.IBFT);
defaultJsonRpcConfiguration = rpcConf;

final WebSocketConfiguration websocketConf = WebSocketConfiguration.createDefault();
websocketConf.addRpcApi(CliqueRpcApis.CLIQUE);
websocketConf.addRpcApi(IbftRpcApis.IBFT);
defaultWebSocketConfiguration = websocketConf;

defaultMetricsConfiguration = MetricsConfiguration.createDefault();
Expand All @@ -109,7 +103,7 @@ public void callingHelpSubCommandMustDisplayUsage() {
@Test
public void callingHelpDisplaysDefaultRpcApisCorrectly() {
parseCommand("--help");
assertThat(commandOutput.toString()).contains("default: ETH,NET,WEB3,CLIQUE,IBFT");
assertThat(commandOutput.toString()).contains("default: [ETH, NET, WEB3]");
assertThat(commandErrorOutput.toString()).isEmpty();
}

Expand Down Expand Up @@ -256,16 +250,12 @@ public void overrideDefaultValuesIfKeyIsPresentInConfigFile() throws IOException
jsonRpcConfiguration.setPort(5678);
jsonRpcConfiguration.setCorsAllowedDomains(Collections.emptyList());
jsonRpcConfiguration.setRpcApis(RpcApis.DEFAULT_JSON_RPC_APIS);
jsonRpcConfiguration.addRpcApi(CliqueRpcApis.CLIQUE);
jsonRpcConfiguration.addRpcApi(IbftRpcApis.IBFT);

final WebSocketConfiguration webSocketConfiguration = WebSocketConfiguration.createDefault();
webSocketConfiguration.setEnabled(false);
webSocketConfiguration.setHost("9.10.11.12");
webSocketConfiguration.setPort(9101);
webSocketConfiguration.setRpcApis(WebSocketConfiguration.DEFAULT_WEBSOCKET_APIS);
webSocketConfiguration.addRpcApi(CliqueRpcApis.CLIQUE);
webSocketConfiguration.addRpcApi(IbftRpcApis.IBFT);

final MetricsConfiguration metricsConfiguration = MetricsConfiguration.createDefault();
metricsConfiguration.setEnabled(false);
Expand Down Expand Up @@ -358,12 +348,8 @@ public void noOverrideDefaultValuesIfKeyIsNotPresentInConfigFile() throws IOExce

parseCommand("--config-file", configFile);
final JsonRpcConfiguration jsonRpcConfiguration = JsonRpcConfiguration.createDefault();
jsonRpcConfiguration.addRpcApi(CliqueRpcApis.CLIQUE);
jsonRpcConfiguration.addRpcApi(IbftRpcApis.IBFT);

final WebSocketConfiguration webSocketConfiguration = WebSocketConfiguration.createDefault();
webSocketConfiguration.addRpcApi(CliqueRpcApis.CLIQUE);
webSocketConfiguration.addRpcApi(IbftRpcApis.IBFT);

final MetricsConfiguration metricsConfiguration = MetricsConfiguration.createDefault();

Expand Down

0 comments on commit 11de8af

Please sign in to comment.