NC-2104 Clique and iBFT should not be defined by default in RPC APIs (#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.

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
Nicolas MASSART 6 years ago committed by GitHub
parent 0e3f199ef5
commit e681f80c85
  1. 4
      docs/Reference/Pantheon-CLI-Syntax.md
  2. 3
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/RpcApi.java
  3. 11
      pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java
  4. 16
      pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java

@ -618,7 +618,7 @@ rpc-http-api=["ETH","NET","WEB3"]
Comma-separated APIs to enable on the HTTP JSON-RPC channel. 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. 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 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 !!!note
:construction: IBFT is not currently supported. Support for IBFT is in active development. :construction: IBFT is not currently supported. Support for IBFT is in active development.
@ -697,7 +697,7 @@ rpc-ws-api=["ETH","NET","WEB3"]
Comma-separated APIs to enable on Websockets channel. Comma-separated APIs to enable on Websockets channel.
When you use this option, the `--rpc-ws-enabled` option must also be specified. 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 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 !!!note
:construction: IBFT is not currently supported. Support for IBFT is in active development. :construction: IBFT is not currently supported. Support for IBFT is in active development.

@ -12,7 +12,6 @@
*/ */
package tech.pegasys.pantheon.ethereum.jsonrpc; package tech.pegasys.pantheon.ethereum.jsonrpc;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects; import com.google.common.base.Objects;
public class RpcApi { public class RpcApi {
@ -45,6 +44,6 @@ public class RpcApi {
@Override @Override
public String toString() { public String toString() {
return MoreObjects.toStringHelper(this).add("cliValue", cliValue).toString(); return cliValue;
} }
} }

@ -17,6 +17,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import static tech.pegasys.pantheon.cli.DefaultCommandValues.getDefaultPantheonDataPath; import static tech.pegasys.pantheon.cli.DefaultCommandValues.getDefaultPantheonDataPath;
import static tech.pegasys.pantheon.cli.NetworkName.MAINNET; 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.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_PORT;
import static tech.pegasys.pantheon.ethereum.jsonrpc.websocket.WebSocketConfiguration.DEFAULT_WEBSOCKET_REFRESH_DELAY; import static tech.pegasys.pantheon.ethereum.jsonrpc.websocket.WebSocketConfiguration.DEFAULT_WEBSOCKET_REFRESH_DELAY;
import static tech.pegasys.pantheon.ethereum.p2p.peers.DefaultPeer.DEFAULT_PORT; import static tech.pegasys.pantheon.ethereum.p2p.peers.DefaultPeer.DEFAULT_PORT;
@ -336,10 +337,9 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
split = ",", split = ",",
arity = "1..*", arity = "1..*",
converter = RpcApisConverter.class, converter = RpcApisConverter.class,
description = "Comma separated APIs to enable on JSON-RPC channel. default: ${DEFAULT-VALUE}", description = "Comma separated APIs to enable on JSON-RPC channel. default: ${DEFAULT-VALUE}"
defaultValue = "ETH,NET,WEB3,CLIQUE,IBFT"
) )
private final Collection<RpcApi> rpcHttpApis = null; private final Collection<RpcApi> rpcHttpApis = DEFAULT_JSON_RPC_APIS;
@Option( @Option(
names = {"--rpc-ws-enabled"}, names = {"--rpc-ws-enabled"},
@ -371,10 +371,9 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
split = ",", split = ",",
arity = "1..*", arity = "1..*",
converter = RpcApisConverter.class, converter = RpcApisConverter.class,
description = "Comma separated APIs to enable on WebSocket channel. default: ${DEFAULT-VALUE}", description = "Comma separated APIs to enable on WebSocket channel. default: ${DEFAULT-VALUE}"
defaultValue = "ETH,NET,WEB3,CLIQUE,IBFT"
) )
private final Collection<RpcApi> rpcWsApis = null; private final Collection<RpcApi> rpcWsApis = DEFAULT_JSON_RPC_APIS;
private Long rpcWsRefreshDelay; private Long rpcWsRefreshDelay;

@ -24,8 +24,6 @@ import static org.mockito.Mockito.verifyZeroInteractions;
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 tech.pegasys.pantheon.PantheonInfo; 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.Address;
import tech.pegasys.pantheon.ethereum.core.MiningParameters; import tech.pegasys.pantheon.ethereum.core.MiningParameters;
import tech.pegasys.pantheon.ethereum.core.PrivacyParameters; import tech.pegasys.pantheon.ethereum.core.PrivacyParameters;
@ -86,13 +84,9 @@ public class PantheonCommandTest extends CommandTestAbstract {
static { static {
final JsonRpcConfiguration rpcConf = JsonRpcConfiguration.createDefault(); final JsonRpcConfiguration rpcConf = JsonRpcConfiguration.createDefault();
rpcConf.addRpcApi(CliqueRpcApis.CLIQUE);
rpcConf.addRpcApi(IbftRpcApis.IBFT);
defaultJsonRpcConfiguration = rpcConf; defaultJsonRpcConfiguration = rpcConf;
final WebSocketConfiguration websocketConf = WebSocketConfiguration.createDefault(); final WebSocketConfiguration websocketConf = WebSocketConfiguration.createDefault();
websocketConf.addRpcApi(CliqueRpcApis.CLIQUE);
websocketConf.addRpcApi(IbftRpcApis.IBFT);
defaultWebSocketConfiguration = websocketConf; defaultWebSocketConfiguration = websocketConf;
defaultMetricsConfiguration = MetricsConfiguration.createDefault(); defaultMetricsConfiguration = MetricsConfiguration.createDefault();
@ -109,7 +103,7 @@ public class PantheonCommandTest extends CommandTestAbstract {
@Test @Test
public void callingHelpDisplaysDefaultRpcApisCorrectly() { public void callingHelpDisplaysDefaultRpcApisCorrectly() {
parseCommand("--help"); parseCommand("--help");
assertThat(commandOutput.toString()).contains("default: ETH,NET,WEB3,CLIQUE,IBFT"); assertThat(commandOutput.toString()).contains("default: [ETH, NET, WEB3]");
assertThat(commandErrorOutput.toString()).isEmpty(); assertThat(commandErrorOutput.toString()).isEmpty();
} }
@ -256,16 +250,12 @@ public class PantheonCommandTest extends CommandTestAbstract {
jsonRpcConfiguration.setPort(5678); jsonRpcConfiguration.setPort(5678);
jsonRpcConfiguration.setCorsAllowedDomains(Collections.emptyList()); jsonRpcConfiguration.setCorsAllowedDomains(Collections.emptyList());
jsonRpcConfiguration.setRpcApis(RpcApis.DEFAULT_JSON_RPC_APIS); jsonRpcConfiguration.setRpcApis(RpcApis.DEFAULT_JSON_RPC_APIS);
jsonRpcConfiguration.addRpcApi(CliqueRpcApis.CLIQUE);
jsonRpcConfiguration.addRpcApi(IbftRpcApis.IBFT);
final WebSocketConfiguration webSocketConfiguration = WebSocketConfiguration.createDefault(); final WebSocketConfiguration webSocketConfiguration = WebSocketConfiguration.createDefault();
webSocketConfiguration.setEnabled(false); webSocketConfiguration.setEnabled(false);
webSocketConfiguration.setHost("9.10.11.12"); webSocketConfiguration.setHost("9.10.11.12");
webSocketConfiguration.setPort(9101); webSocketConfiguration.setPort(9101);
webSocketConfiguration.setRpcApis(WebSocketConfiguration.DEFAULT_WEBSOCKET_APIS); webSocketConfiguration.setRpcApis(WebSocketConfiguration.DEFAULT_WEBSOCKET_APIS);
webSocketConfiguration.addRpcApi(CliqueRpcApis.CLIQUE);
webSocketConfiguration.addRpcApi(IbftRpcApis.IBFT);
final MetricsConfiguration metricsConfiguration = MetricsConfiguration.createDefault(); final MetricsConfiguration metricsConfiguration = MetricsConfiguration.createDefault();
metricsConfiguration.setEnabled(false); metricsConfiguration.setEnabled(false);
@ -358,12 +348,8 @@ public class PantheonCommandTest extends CommandTestAbstract {
parseCommand("--config-file", configFile); parseCommand("--config-file", configFile);
final JsonRpcConfiguration jsonRpcConfiguration = JsonRpcConfiguration.createDefault(); final JsonRpcConfiguration jsonRpcConfiguration = JsonRpcConfiguration.createDefault();
jsonRpcConfiguration.addRpcApi(CliqueRpcApis.CLIQUE);
jsonRpcConfiguration.addRpcApi(IbftRpcApis.IBFT);
final WebSocketConfiguration webSocketConfiguration = WebSocketConfiguration.createDefault(); final WebSocketConfiguration webSocketConfiguration = WebSocketConfiguration.createDefault();
webSocketConfiguration.addRpcApi(CliqueRpcApis.CLIQUE);
webSocketConfiguration.addRpcApi(IbftRpcApis.IBFT);
final MetricsConfiguration metricsConfiguration = MetricsConfiguration.createDefault(); final MetricsConfiguration metricsConfiguration = MetricsConfiguration.createDefault();

Loading…
Cancel
Save