Skip to content

Commit

Permalink
Added GraphQL Service Information in responese result NetServices (hy…
Browse files Browse the repository at this point in the history
…perledger#7580)

Signed-off-by: ITStarMan100 <[email protected]>
Co-authored-by: Justin Florentine <[email protected]>
Co-authored-by: Sally MacFarlane <[email protected]>
  • Loading branch information
3 people authored Sep 16, 2024
1 parent 87bad72 commit 12caf7d
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 4 deletions.
7 changes: 7 additions & 0 deletions besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,7 @@ public Runner build() {
jsonRpcConfiguration,
webSocketConfiguration,
metricsConfiguration,
graphQLConfiguration,
natService,
besuPluginContext.getNamedPlugins(),
dataDir,
Expand Down Expand Up @@ -907,6 +908,7 @@ public Runner build() {
engineJsonRpcConfiguration.get(),
webSocketConfiguration,
metricsConfiguration,
graphQLConfiguration,
natService,
besuPluginContext.getNamedPlugins(),
dataDir,
Expand Down Expand Up @@ -1001,6 +1003,7 @@ public Runner build() {
jsonRpcConfiguration,
webSocketConfiguration,
metricsConfiguration,
graphQLConfiguration,
natService,
besuPluginContext.getNamedPlugins(),
dataDir,
Expand Down Expand Up @@ -1081,6 +1084,7 @@ public Runner build() {
jsonRpcConfiguration,
webSocketConfiguration,
metricsConfiguration,
graphQLConfiguration,
natService,
besuPluginContext.getNamedPlugins(),
dataDir,
Expand Down Expand Up @@ -1119,6 +1123,7 @@ public Runner build() {
jsonRpcConfiguration,
webSocketConfiguration,
metricsConfiguration,
graphQLConfiguration,
natService,
besuPluginContext.getNamedPlugins(),
dataDir,
Expand Down Expand Up @@ -1280,6 +1285,7 @@ private Map<String, JsonRpcMethod> jsonRpcMethods(
final JsonRpcConfiguration jsonRpcConfiguration,
final WebSocketConfiguration webSocketConfiguration,
final MetricsConfiguration metricsConfiguration,
final GraphQLConfiguration graphQLConfiguration,
final NatService natService,
final Map<String, BesuPlugin> namedPlugins,
final Path dataDir,
Expand Down Expand Up @@ -1313,6 +1319,7 @@ private Map<String, JsonRpcMethod> jsonRpcMethods(
jsonRpcConfiguration,
webSocketConfiguration,
metricsConfiguration,
graphQLConfiguration,
natService,
namedPlugins,
dataDir,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration;
import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManagerBuilder;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
Expand Down Expand Up @@ -164,6 +165,8 @@ public Map<String, JsonRpcMethod> methods() {
final JsonRpcConfiguration jsonRpcConfiguration = mock(JsonRpcConfiguration.class);
final WebSocketConfiguration webSocketConfiguration = mock(WebSocketConfiguration.class);
final MetricsConfiguration metricsConfiguration = mock(MetricsConfiguration.class);
final GraphQLConfiguration graphQLConfiguration = mock(GraphQLConfiguration.class);

final NatService natService = new NatService(Optional.empty());

final List<String> apis = new ArrayList<>();
Expand Down Expand Up @@ -200,6 +203,7 @@ public Map<String, JsonRpcMethod> methods() {
jsonRpcConfiguration,
webSocketConfiguration,
metricsConfiguration,
graphQLConfiguration,
natService,
new HashMap<>(),
dataDir,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;

import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
Expand All @@ -32,16 +33,19 @@ public class NetServices implements JsonRpcMethod {
private final WebSocketConfiguration webSocketConfiguration;
private final P2PNetwork p2pNetwork;
private final MetricsConfiguration metricsConfiguration;
private final GraphQLConfiguration graphQLConfiguration;

public NetServices(
final JsonRpcConfiguration jsonRpcConfiguration,
final WebSocketConfiguration webSocketConfiguration,
final P2PNetwork p2pNetwork,
final MetricsConfiguration metricsConfiguration) {
final MetricsConfiguration metricsConfiguration,
final GraphQLConfiguration graphQLConfiguration) {
this.jsonRpcConfiguration = jsonRpcConfiguration;
this.webSocketConfiguration = webSocketConfiguration;
this.p2pNetwork = p2pNetwork;
this.metricsConfiguration = metricsConfiguration;
this.graphQLConfiguration = graphQLConfiguration;
}

@Override
Expand Down Expand Up @@ -82,6 +86,11 @@ public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
createServiceDetailsMap(
metricsConfiguration.getHost(), metricsConfiguration.getActualPort()));
}
if (graphQLConfiguration.isEnabled()) {
servicesMapBuilder.put(
"graphQL",
createServiceDetailsMap(graphQLConfiguration.getHost(), graphQLConfiguration.getPort()));
}

return new JsonRpcSuccessResponse(
requestContext.getRequest().getId(), servicesMapBuilder.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
Expand Down Expand Up @@ -77,6 +78,7 @@ public Map<String, JsonRpcMethod> methods(
final JsonRpcConfiguration jsonRpcConfiguration,
final WebSocketConfiguration webSocketConfiguration,
final MetricsConfiguration metricsConfiguration,
final GraphQLConfiguration graphQLConfiguration,
final NatService natService,
final Map<String, BesuPlugin> namedPlugins,
final Path dataDir,
Expand Down Expand Up @@ -135,7 +137,8 @@ public Map<String, JsonRpcMethod> methods(
networkId,
jsonRpcConfiguration,
webSocketConfiguration,
metricsConfiguration),
metricsConfiguration,
graphQLConfiguration),
new MinerJsonRpcMethods(miningParameters, miningCoordinator),
new PermJsonRpcMethods(accountsAllowlistController, nodeAllowlistController),
new PrivJsonRpcMethods(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.methods;

import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
Expand All @@ -37,18 +38,21 @@ public class NetJsonRpcMethods extends ApiGroupJsonRpcMethods {
private final JsonRpcConfiguration jsonRpcConfiguration;
private final WebSocketConfiguration webSocketConfiguration;
private final MetricsConfiguration metricsConfiguration;
private final GraphQLConfiguration graphQLConfiguration;

public NetJsonRpcMethods(
final P2PNetwork p2pNetwork,
final BigInteger networkId,
final JsonRpcConfiguration jsonRpcConfiguration,
final WebSocketConfiguration webSocketConfiguration,
final MetricsConfiguration metricsConfiguration) {
final MetricsConfiguration metricsConfiguration,
final GraphQLConfiguration graphQLConfiguration) {
this.p2pNetwork = p2pNetwork;
this.networkId = networkId;
this.jsonRpcConfiguration = jsonRpcConfiguration;
this.webSocketConfiguration = webSocketConfiguration;
this.metricsConfiguration = metricsConfiguration;
this.graphQLConfiguration = graphQLConfiguration;
}

@Override
Expand All @@ -64,6 +68,10 @@ protected Map<String, JsonRpcMethod> create() {
new NetPeerCount(p2pNetwork),
new NetEnode(p2pNetwork),
new NetServices(
jsonRpcConfiguration, webSocketConfiguration, p2pNetwork, metricsConfiguration));
jsonRpcConfiguration,
webSocketConfiguration,
p2pNetwork,
metricsConfiguration,
graphQLConfiguration));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.health.HealthService;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterIdGenerator;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
Expand Down Expand Up @@ -193,6 +194,7 @@ protected Map<String, JsonRpcMethod> getRpcMethods(
config,
mock(WebSocketConfiguration.class),
mock(MetricsConfiguration.class),
mock(GraphQLConfiguration.class),
natService,
new HashMap<>(),
folder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.health.HealthService;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
Expand Down Expand Up @@ -130,6 +131,7 @@ public void initServerAndClient() throws Exception {
mock(JsonRpcConfiguration.class),
mock(WebSocketConfiguration.class),
mock(MetricsConfiguration.class),
mock(GraphQLConfiguration.class),
natService,
new HashMap<>(),
folder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.health.HealthService;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.EthAccounts;
Expand Down Expand Up @@ -161,6 +162,7 @@ public static void initServerAndClient() throws Exception {
mock(JsonRpcConfiguration.class),
mock(WebSocketConfiguration.class),
mock(MetricsConfiguration.class),
mock(GraphQLConfiguration.class),
natService,
new HashMap<>(),
folder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.health.HealthService;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
Expand Down Expand Up @@ -227,6 +228,7 @@ private JsonRpcHttpService createJsonRpcHttpServiceWithRpcApis(final JsonRpcConf
mock(JsonRpcConfiguration.class),
mock(WebSocketConfiguration.class),
mock(MetricsConfiguration.class),
mock(GraphQLConfiguration.class),
natService,
new HashMap<>(),
folder,
Expand Down Expand Up @@ -337,6 +339,7 @@ private JsonRpcHttpService createJsonRpcHttpService(
jsonRpcConfiguration,
webSocketConfiguration,
metricsConfiguration,
mock(GraphQLConfiguration.class),
natService,
new HashMap<>(),
folder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.health.HealthService;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
Expand Down Expand Up @@ -139,6 +140,7 @@ public static void initServerAndClient() throws Exception {
mock(JsonRpcConfiguration.class),
mock(WebSocketConfiguration.class),
mock(MetricsConfiguration.class),
mock(GraphQLConfiguration.class),
natService,
new HashMap<>(),
folder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.health.HealthService;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
Expand Down Expand Up @@ -144,6 +145,7 @@ public void initServer() throws Exception {
mock(JsonRpcConfiguration.class),
mock(WebSocketConfiguration.class),
mock(MetricsConfiguration.class),
mock(GraphQLConfiguration.class),
natService,
Collections.emptyMap(),
folder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.health.HealthService;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
Expand Down Expand Up @@ -132,6 +133,7 @@ public void beforeEach() {
mock(JsonRpcConfiguration.class),
mock(WebSocketConfiguration.class),
mock(MetricsConfiguration.class),
mock(GraphQLConfiguration.class),
natService,
Collections.emptyMap(),
tempDir.getRoot(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.health.HealthService;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
Expand Down Expand Up @@ -133,6 +134,7 @@ public void initServer() throws Exception {
mock(JsonRpcConfiguration.class),
mock(WebSocketConfiguration.class),
mock(MetricsConfiguration.class),
mock(GraphQLConfiguration.class),
natService,
Collections.emptyMap(),
folder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.handlers.TimeoutOptions;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcHttpService;
Expand Down Expand Up @@ -197,6 +198,7 @@ public void before() throws URISyntaxException {
mock(JsonRpcConfiguration.class),
mock(WebSocketConfiguration.class),
mock(MetricsConfiguration.class),
mock(GraphQLConfiguration.class),
natService,
new HashMap<>(),
folder,
Expand Down

0 comments on commit 12caf7d

Please sign in to comment.