Revert "[NC-1805] net_version should return the network ID not the chain ID (#162)" (#166)

MetaMask depends on net_version returning the chain ID, not the network ID.
Adrian Sutton 6 years ago committed by GitHub
parent d159d994f1
commit c53b8498b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java
  2. 8
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcMethodsFactory.java
  3. 14
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/NetVersion.java
  4. 9
      pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java
  5. 7
      pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java
  6. 2
      pantheon/src/test/java/tech/pegasys/pantheon/RunnerTest.java
  7. 34
      pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java

@ -71,7 +71,6 @@ public class ThreadPantheonNodeRunner implements PantheonNodeRunner {
pantheonController, pantheonController,
true, true,
node.bootnodes(), node.bootnodes(),
NETWORK_ID,
node.getHost(), node.getHost(),
node.p2pPort(), node.p2pPort(),
25, 25,

@ -87,7 +87,7 @@ public class JsonRpcMethodsFactory {
public Map<String, JsonRpcMethod> methods( public Map<String, JsonRpcMethod> methods(
final String clientVersion, final String clientVersion,
final String networkId, final String chainId,
final P2PNetwork peerNetworkingService, final P2PNetwork peerNetworkingService,
final Blockchain blockchain, final Blockchain blockchain,
final WorldStateArchive worldStateArchive, final WorldStateArchive worldStateArchive,
@ -102,7 +102,7 @@ public class JsonRpcMethodsFactory {
new BlockchainQueries(blockchain, worldStateArchive); new BlockchainQueries(blockchain, worldStateArchive);
return methods( return methods(
clientVersion, clientVersion,
networkId, chainId,
peerNetworkingService, peerNetworkingService,
blockchainQueries, blockchainQueries,
synchronizer, synchronizer,
@ -116,7 +116,7 @@ public class JsonRpcMethodsFactory {
public Map<String, JsonRpcMethod> methods( public Map<String, JsonRpcMethod> methods(
final String clientVersion, final String clientVersion,
final String networkId, final String chainId,
final P2PNetwork p2pNetwork, final P2PNetwork p2pNetwork,
final BlockchainQueries blockchainQueries, final BlockchainQueries blockchainQueries,
final Synchronizer synchronizer, final Synchronizer synchronizer,
@ -195,7 +195,7 @@ public class JsonRpcMethodsFactory {
if (rpcApis.contains(RpcApis.NET)) { if (rpcApis.contains(RpcApis.NET)) {
addMethods( addMethods(
enabledMethods, enabledMethods,
new NetVersion(networkId), new NetVersion(chainId),
new NetListening(p2pNetwork), new NetListening(p2pNetwork),
new NetPeerCount(p2pNetwork), new NetPeerCount(p2pNetwork),
new AdminPeers(p2pNetwork)); new AdminPeers(p2pNetwork));

@ -16,11 +16,17 @@ import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse;
/**
* In Consensys' client, net_version maps to the network id, as specified in *
* https://github.com/ethereum/wiki/wiki/JSON-RPC#net_version
*
* <p>This method can be deprecated in the future, @see https://github.com/ethereum/EIPs/issues/611
*/
public class NetVersion implements JsonRpcMethod { public class NetVersion implements JsonRpcMethod {
private final String networkId; private final String chainId;
public NetVersion(final String networkId) { public NetVersion(final String chainId) {
this.networkId = networkId; this.chainId = chainId;
} }
@Override @Override
@ -30,6 +36,6 @@ public class NetVersion implements JsonRpcMethod {
@Override @Override
public JsonRpcResponse response(final JsonRpcRequest req) { public JsonRpcResponse response(final JsonRpcRequest req) {
return new JsonRpcSuccessResponse(req.getId(), networkId); return new JsonRpcSuccessResponse(req.getId(), chainId);
} }
} }

@ -73,7 +73,6 @@ public class RunnerBuilder {
final PantheonController<?, ?> pantheonController, final PantheonController<?, ?> pantheonController,
final boolean discovery, final boolean discovery,
final Collection<?> bootstrapPeers, final Collection<?> bootstrapPeers,
final int networkId,
final String discoveryHost, final String discoveryHost,
final int listenPort, final int listenPort,
final int maxPeers, final int maxPeers,
@ -151,7 +150,7 @@ public class RunnerBuilder {
jsonRpcMethods( jsonRpcMethods(
context, context,
protocolSchedule, protocolSchedule,
networkId, pantheonController,
networkRunner, networkRunner,
synchronizer, synchronizer,
transactionPool, transactionPool,
@ -169,7 +168,7 @@ public class RunnerBuilder {
jsonRpcMethods( jsonRpcMethods(
context, context,
protocolSchedule, protocolSchedule,
networkId, pantheonController,
networkRunner, networkRunner,
synchronizer, synchronizer,
transactionPool, transactionPool,
@ -214,7 +213,7 @@ public class RunnerBuilder {
private Map<String, JsonRpcMethod> jsonRpcMethods( private Map<String, JsonRpcMethod> jsonRpcMethods(
final ProtocolContext<?> context, final ProtocolContext<?> context,
final ProtocolSchedule<?> protocolSchedule, final ProtocolSchedule<?> protocolSchedule,
final int networkId, final PantheonController<?, ?> pantheonController,
final NetworkRunner networkRunner, final NetworkRunner networkRunner,
final Synchronizer synchronizer, final Synchronizer synchronizer,
final TransactionPool transactionPool, final TransactionPool transactionPool,
@ -226,7 +225,7 @@ public class RunnerBuilder {
new JsonRpcMethodsFactory() new JsonRpcMethodsFactory()
.methods( .methods(
PantheonInfo.version(), PantheonInfo.version(),
String.valueOf(networkId), String.valueOf(pantheonController.getGenesisConfig().getChainId()),
networkRunner.getNetwork(), networkRunner.getNetwork(),
context.getBlockchain(), context.getBlockchain(),
context.getWorldStateArchive(), context.getWorldStateArchive(),

@ -414,7 +414,7 @@ public class PantheonCommand implements Runnable {
synchronize( synchronize(
buildController(), buildController(),
noPeerDiscovery, noPeerDiscovery,
ethNetworkConfig, ethNetworkConfig.getBootNodes(),
maxPeers, maxPeers,
p2pHostAndPort, p2pHostAndPort,
jsonRpcConfiguration(), jsonRpcConfiguration(),
@ -467,7 +467,7 @@ public class PantheonCommand implements Runnable {
private void synchronize( private void synchronize(
final PantheonController<?, ?> controller, final PantheonController<?, ?> controller,
final boolean noPeerDiscovery, final boolean noPeerDiscovery,
final EthNetworkConfig ethNetworkConfig, final Collection<?> bootstrapNodes,
final int maxPeers, final int maxPeers,
final HostAndPort discoveryHostAndPort, final HostAndPort discoveryHostAndPort,
final JsonRpcConfiguration jsonRpcConfiguration, final JsonRpcConfiguration jsonRpcConfiguration,
@ -481,8 +481,7 @@ public class PantheonCommand implements Runnable {
Vertx.vertx(), Vertx.vertx(),
controller, controller,
!noPeerDiscovery, !noPeerDiscovery,
ethNetworkConfig.getBootNodes(), bootstrapNodes,
ethNetworkConfig.getNetworkId(),
discoveryHostAndPort.getHost(), discoveryHostAndPort.getHost(),
discoveryHostAndPort.getPort(), discoveryHostAndPort.getPort(),
maxPeers, maxPeers,

@ -120,7 +120,6 @@ public final class RunnerTest {
controllerAhead, controllerAhead,
true, true,
Collections.emptyList(), Collections.emptyList(),
NETWORK_ID,
listenHost, listenHost,
0, 0,
3, 3,
@ -154,7 +153,6 @@ public final class RunnerTest {
listenHost, listenHost,
runnerAhead.getP2pUdpPort(), runnerAhead.getP2pUdpPort(),
runnerAhead.getP2pTcpPort())), runnerAhead.getP2pTcpPort())),
NETWORK_ID,
listenHost, listenHost,
0, 0,
3, 3,

@ -88,7 +88,6 @@ public class PantheonCommandTest extends CommandTestAbstract {
any(), any(),
anyBoolean(), anyBoolean(),
any(), any(),
anyInt(),
anyString(), anyString(),
anyInt(), anyInt(),
anyInt(), anyInt(),
@ -131,7 +130,6 @@ public class PantheonCommandTest extends CommandTestAbstract {
any(), any(),
eq(true), eq(true),
eq(MAINNET_BOOTSTRAP_NODES), eq(MAINNET_BOOTSTRAP_NODES),
eq(1),
eq("127.0.0.1"), eq("127.0.0.1"),
eq(30303), eq(30303),
eq(25), eq(25),
@ -259,7 +257,6 @@ public class PantheonCommandTest extends CommandTestAbstract {
any(), any(),
eq(false), eq(false),
stringListArgumentCaptor.capture(), stringListArgumentCaptor.capture(),
eq(1),
eq("1.2.3.4"), eq("1.2.3.4"),
eq(1234), eq(1234),
eq(42), eq(42),
@ -313,7 +310,6 @@ public class PantheonCommandTest extends CommandTestAbstract {
any(), any(),
eq(true), eq(true),
eq(MAINNET_BOOTSTRAP_NODES), eq(MAINNET_BOOTSTRAP_NODES),
eq(1),
eq("127.0.0.1"), eq("127.0.0.1"),
eq(30303), eq(30303),
eq(25), eq(25),
@ -372,17 +368,7 @@ public class PantheonCommandTest extends CommandTestAbstract {
verify(mockRunnerBuilder) verify(mockRunnerBuilder)
.build( .build(
any(), any(), any(), eq(false), any(), anyString(), anyInt(), anyInt(), any(), any(), any());
any(),
eq(false),
any(),
anyInt(),
anyString(),
anyInt(),
anyInt(),
any(),
any(),
any());
assertThat(commandOutput.toString()).isEmpty(); assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty(); assertThat(commandErrorOutput.toString()).isEmpty();
@ -408,7 +394,6 @@ public class PantheonCommandTest extends CommandTestAbstract {
any(), any(),
anyBoolean(), anyBoolean(),
stringListArgumentCaptor.capture(), stringListArgumentCaptor.capture(),
anyInt(),
anyString(), anyString(),
anyInt(), anyInt(),
anyInt(), anyInt(),
@ -435,7 +420,6 @@ public class PantheonCommandTest extends CommandTestAbstract {
any(), any(),
anyBoolean(), anyBoolean(),
any(), any(),
anyInt(),
stringArgumentCaptor.capture(), stringArgumentCaptor.capture(),
intArgumentCaptor.capture(), intArgumentCaptor.capture(),
anyInt(), anyInt(),
@ -462,7 +446,6 @@ public class PantheonCommandTest extends CommandTestAbstract {
any(), any(),
anyBoolean(), anyBoolean(),
any(), any(),
anyInt(),
anyString(), anyString(),
anyInt(), anyInt(),
intArgumentCaptor.capture(), intArgumentCaptor.capture(),
@ -509,7 +492,6 @@ public class PantheonCommandTest extends CommandTestAbstract {
any(), any(),
anyBoolean(), anyBoolean(),
any(), any(),
anyInt(),
anyString(), anyString(),
anyInt(), anyInt(),
anyInt(), anyInt(),
@ -533,7 +515,6 @@ public class PantheonCommandTest extends CommandTestAbstract {
any(), any(),
anyBoolean(), anyBoolean(),
any(), any(),
anyInt(),
anyString(), anyString(),
anyInt(), anyInt(),
anyInt(), anyInt(),
@ -557,7 +538,6 @@ public class PantheonCommandTest extends CommandTestAbstract {
any(), any(),
anyBoolean(), anyBoolean(),
any(), any(),
anyInt(),
anyString(), anyString(),
anyInt(), anyInt(),
anyInt(), anyInt(),
@ -585,7 +565,6 @@ public class PantheonCommandTest extends CommandTestAbstract {
any(), any(),
anyBoolean(), anyBoolean(),
any(), any(),
anyInt(),
anyString(), anyString(),
anyInt(), anyInt(),
anyInt(), anyInt(),
@ -611,7 +590,6 @@ public class PantheonCommandTest extends CommandTestAbstract {
any(), any(),
anyBoolean(), anyBoolean(),
any(), any(),
anyInt(),
anyString(), anyString(),
anyInt(), anyInt(),
anyInt(), anyInt(),
@ -637,7 +615,6 @@ public class PantheonCommandTest extends CommandTestAbstract {
any(), any(),
anyBoolean(), anyBoolean(),
any(), any(),
anyInt(),
anyString(), anyString(),
anyInt(), anyInt(),
anyInt(), anyInt(),
@ -663,7 +640,6 @@ public class PantheonCommandTest extends CommandTestAbstract {
any(), any(),
anyBoolean(), anyBoolean(),
any(), any(),
anyInt(),
anyString(), anyString(),
anyInt(), anyInt(),
anyInt(), anyInt(),
@ -689,7 +665,6 @@ public class PantheonCommandTest extends CommandTestAbstract {
any(), any(),
anyBoolean(), anyBoolean(),
any(), any(),
anyInt(),
anyString(), anyString(),
anyInt(), anyInt(),
anyInt(), anyInt(),
@ -761,7 +736,6 @@ public class PantheonCommandTest extends CommandTestAbstract {
any(), any(),
anyBoolean(), anyBoolean(),
any(), any(),
anyInt(),
anyString(), anyString(),
anyInt(), anyInt(),
anyInt(), anyInt(),
@ -785,7 +759,6 @@ public class PantheonCommandTest extends CommandTestAbstract {
any(), any(),
anyBoolean(), anyBoolean(),
any(), any(),
anyInt(),
anyString(), anyString(),
anyInt(), anyInt(),
anyInt(), anyInt(),
@ -809,7 +782,6 @@ public class PantheonCommandTest extends CommandTestAbstract {
any(), any(),
anyBoolean(), anyBoolean(),
any(), any(),
anyInt(),
anyString(), anyString(),
anyInt(), anyInt(),
anyInt(), anyInt(),
@ -836,7 +808,6 @@ public class PantheonCommandTest extends CommandTestAbstract {
any(), any(),
anyBoolean(), anyBoolean(),
any(), any(),
anyInt(),
anyString(), anyString(),
anyInt(), anyInt(),
anyInt(), anyInt(),
@ -855,6 +826,9 @@ public class PantheonCommandTest extends CommandTestAbstract {
public void pantheonDoesNotStartInMiningModeIfCoinbaseNotSet() throws Exception { public void pantheonDoesNotStartInMiningModeIfCoinbaseNotSet() throws Exception {
parseCommand("--miner-enabled"); parseCommand("--miner-enabled");
final ArgumentCaptor<MiningParameters> miningArg =
ArgumentCaptor.forClass(MiningParameters.class);
verifyZeroInteractions(mockControllerBuilder); verifyZeroInteractions(mockControllerBuilder);
} }

Loading…
Cancel
Save