use of org.hyperledger.besu.metrics.prometheus.MetricsConfiguration in project besu by hyperledger.
the class RunnerBuilder method build.
public Runner build() {
Preconditions.checkNotNull(besuController);
final DiscoveryConfiguration discoveryConfiguration = DiscoveryConfiguration.create().setBindHost(p2pListenInterface).setBindPort(p2pListenPort).setAdvertisedHost(p2pAdvertisedHost);
if (discovery) {
final List<EnodeURL> bootstrap;
if (ethNetworkConfig.getBootNodes() == null) {
bootstrap = EthNetworkConfig.getNetworkConfig(NetworkName.MAINNET).getBootNodes();
} else {
bootstrap = ethNetworkConfig.getBootNodes();
}
discoveryConfiguration.setBootnodes(bootstrap);
discoveryConfiguration.setDnsDiscoveryURL(ethNetworkConfig.getDnsDiscoveryUrl());
} else {
discoveryConfiguration.setActive(false);
}
final NodeKey nodeKey = besuController.getNodeKey();
final SubProtocolConfiguration subProtocolConfiguration = besuController.getSubProtocolConfiguration();
final ProtocolSchedule protocolSchedule = besuController.getProtocolSchedule();
final ProtocolContext context = besuController.getProtocolContext();
final List<SubProtocol> subProtocols = subProtocolConfiguration.getSubProtocols();
final List<ProtocolManager> protocolManagers = subProtocolConfiguration.getProtocolManagers();
final Set<Capability> supportedCapabilities = protocolManagers.stream().flatMap(protocolManager -> protocolManager.getSupportedCapabilities().stream()).collect(Collectors.toSet());
final RlpxConfiguration rlpxConfiguration = RlpxConfiguration.create().setBindHost(p2pListenInterface).setBindPort(p2pListenPort).setMaxPeers(maxPeers).setSupportedProtocols(subProtocols).setClientId(BesuInfo.nodeName(identityString)).setLimitRemoteWireConnectionsEnabled(limitRemoteWireConnectionsEnabled).setFractionRemoteWireConnectionsAllowed(fractionRemoteConnectionsAllowed);
networkingConfiguration.setRlpx(rlpxConfiguration).setDiscovery(discoveryConfiguration);
final PeerPermissionsDenylist bannedNodes = PeerPermissionsDenylist.create();
bannedNodeIds.forEach(bannedNodes::add);
final List<EnodeURL> bootnodes = discoveryConfiguration.getBootnodes();
final Synchronizer synchronizer = besuController.getSynchronizer();
final TransactionSimulator transactionSimulator = new TransactionSimulator(context.getBlockchain(), context.getWorldStateArchive(), protocolSchedule);
final Bytes localNodeId = nodeKey.getPublicKey().getEncodedBytes();
final Optional<NodePermissioningController> nodePermissioningController = buildNodePermissioningController(bootnodes, synchronizer, transactionSimulator, localNodeId, context.getBlockchain());
final PeerPermissions peerPermissions = nodePermissioningController.map(nodePC -> new PeerPermissionsAdapter(nodePC, bootnodes, context.getBlockchain())).map(nodePerms -> PeerPermissions.combine(nodePerms, bannedNodes)).orElse(bannedNodes);
LOG.info("Detecting NAT service.");
final boolean fallbackEnabled = natMethod == NatMethod.AUTO || natMethodFallbackEnabled;
final NatService natService = new NatService(buildNatManager(natMethod), fallbackEnabled);
final NetworkBuilder inactiveNetwork = caps -> new NoopP2PNetwork();
final NetworkBuilder activeNetwork = caps -> DefaultP2PNetwork.builder().vertx(vertx).nodeKey(nodeKey).config(networkingConfiguration).peerPermissions(peerPermissions).metricsSystem(metricsSystem).supportedCapabilities(caps).natService(natService).randomPeerPriority(randomPeerPriority).storageProvider(storageProvider).forkIdSupplier(forkIdSupplier).p2pTLSConfiguration(p2pTLSConfiguration).build();
final NetworkRunner networkRunner = NetworkRunner.builder().protocolManagers(protocolManagers).subProtocols(subProtocols).network(p2pEnabled ? activeNetwork : inactiveNetwork).metricsSystem(metricsSystem).build();
final P2PNetwork network = networkRunner.getNetwork();
// ForkId in Ethereum Node Record needs updating when we transition to a new protocol spec
context.getBlockchain().observeBlockAdded(blockAddedEvent -> {
if (protocolSchedule.streamMilestoneBlocks().anyMatch(blockNumber -> blockNumber == blockAddedEvent.getBlock().getHeader().getNumber())) {
network.updateNodeRecord();
}
});
nodePermissioningController.ifPresent(n -> n.setInsufficientPeersPermissioningProvider(new InsufficientPeersPermissioningProvider(network, bootnodes)));
final TransactionPool transactionPool = besuController.getTransactionPool();
final MiningCoordinator miningCoordinator = besuController.getMiningCoordinator();
final BlockchainQueries blockchainQueries = new BlockchainQueries(context.getBlockchain(), context.getWorldStateArchive(), Optional.of(dataDir.resolve(CACHE_PATH)), Optional.of(besuController.getProtocolManager().ethContext().getScheduler()), apiConfiguration);
final PrivacyParameters privacyParameters = besuController.getPrivacyParameters();
final FilterManager filterManager = new FilterManagerBuilder().blockchainQueries(blockchainQueries).transactionPool(transactionPool).privacyParameters(privacyParameters).build();
vertx.deployVerticle(filterManager);
createPrivateTransactionObserver(filterManager, privacyParameters);
final P2PNetwork peerNetwork = networkRunner.getNetwork();
final MiningParameters miningParameters = besuController.getMiningParameters();
Optional<StratumServer> stratumServer = Optional.empty();
if (miningParameters.isStratumMiningEnabled()) {
var powMiningCoordinator = miningCoordinator;
if (miningCoordinator instanceof TransitionCoordinator) {
LOG.debug("fetching powMiningCoordinator from TransitionCoordinator");
powMiningCoordinator = ((TransitionCoordinator) miningCoordinator).getPreMergeObject();
}
stratumServer = Optional.of(new StratumServer(vertx, powMiningCoordinator, miningParameters.getStratumPort(), miningParameters.getStratumNetworkInterface(), miningParameters.getStratumExtranonce(), metricsSystem));
miningCoordinator.addEthHashObserver(stratumServer.get());
LOG.debug("added ethash observer: {}", stratumServer.get());
}
sanitizePeers(network, staticNodes).map(DefaultPeer::fromEnodeURL).forEach(peerNetwork::addMaintainedConnectionPeer);
final Optional<NodeLocalConfigPermissioningController> nodeLocalConfigPermissioningController = nodePermissioningController.flatMap(NodePermissioningController::localConfigController);
final Optional<AccountPermissioningController> accountPermissioningController = buildAccountPermissioningController(permissioningConfiguration, besuController, transactionSimulator, context.getBlockchain());
final Optional<AccountLocalConfigPermissioningController> accountLocalConfigPermissioningController = accountPermissioningController.flatMap(AccountPermissioningController::getAccountLocalConfigPermissioningController);
Optional<JsonRpcHttpService> jsonRpcHttpService = Optional.empty();
if (jsonRpcConfiguration.isEnabled()) {
final Map<String, JsonRpcMethod> nonEngineMethods = jsonRpcMethods(protocolSchedule, context, besuController, peerNetwork, blockchainQueries, synchronizer, transactionPool, miningCoordinator, metricsSystem, supportedCapabilities, jsonRpcConfiguration.getRpcApis().stream().filter(apiGroup -> !apiGroup.toLowerCase().startsWith("engine")).collect(Collectors.toList()), filterManager, accountLocalConfigPermissioningController, nodeLocalConfigPermissioningController, privacyParameters, jsonRpcConfiguration, webSocketConfiguration, metricsConfiguration, natService, besuPluginContext.getNamedPlugins(), dataDir, rpcEndpointServiceImpl);
jsonRpcHttpService = Optional.of(new JsonRpcHttpService(vertx, dataDir, jsonRpcConfiguration, metricsSystem, natService, nonEngineMethods, new HealthService(new LivenessCheck()), new HealthService(new ReadinessCheck(peerNetwork, synchronizer))));
}
Optional<JsonRpcService> engineJsonRpcService = Optional.empty();
if (engineJsonRpcConfiguration.isPresent() && engineJsonRpcConfiguration.get().isEnabled()) {
final Map<String, JsonRpcMethod> engineMethods = jsonRpcMethods(protocolSchedule, context, besuController, peerNetwork, blockchainQueries, synchronizer, transactionPool, miningCoordinator, metricsSystem, supportedCapabilities, engineJsonRpcConfiguration.get().getRpcApis(), filterManager, accountLocalConfigPermissioningController, nodeLocalConfigPermissioningController, privacyParameters, engineJsonRpcConfiguration.get(), webSocketConfiguration, metricsConfiguration, natService, besuPluginContext.getNamedPlugins(), dataDir, rpcEndpointServiceImpl);
Optional<AuthenticationService> authToUse = engineJsonRpcConfiguration.get().isAuthenticationEnabled() ? Optional.of(new EngineAuthService(vertx, Optional.ofNullable(engineJsonRpcConfiguration.get().getAuthenticationPublicKeyFile()), dataDir)) : Optional.empty();
WebSocketConfiguration engineSocketConfig = webSocketConfiguration.isEnabled() ? webSocketConfiguration : WebSocketConfiguration.createEngineDefault();
engineJsonRpcService = Optional.of(new JsonRpcService(vertx, dataDir, engineJsonRpcConfiguration.orElse(JsonRpcConfiguration.createEngineDefault()), metricsSystem, natService, engineMethods, Optional.ofNullable(engineSocketConfig), besuController.getProtocolManager().ethContext().getScheduler(), authToUse, new HealthService(new LivenessCheck()), new HealthService(new ReadinessCheck(peerNetwork, synchronizer))));
}
Optional<GraphQLHttpService> graphQLHttpService = Optional.empty();
if (graphQLConfiguration.isEnabled()) {
final GraphQLDataFetchers fetchers = new GraphQLDataFetchers(supportedCapabilities, privacyParameters.getGoQuorumPrivacyParameters());
final Map<GraphQLContextType, Object> graphQlContextMap = new ConcurrentHashMap<>();
graphQlContextMap.putIfAbsent(GraphQLContextType.BLOCKCHAIN_QUERIES, blockchainQueries);
graphQlContextMap.putIfAbsent(GraphQLContextType.PROTOCOL_SCHEDULE, protocolSchedule);
graphQlContextMap.putIfAbsent(GraphQLContextType.TRANSACTION_POOL, transactionPool);
graphQlContextMap.putIfAbsent(GraphQLContextType.MINING_COORDINATOR, miningCoordinator);
graphQlContextMap.putIfAbsent(GraphQLContextType.SYNCHRONIZER, synchronizer);
final GraphQL graphQL;
try {
graphQL = GraphQLProvider.buildGraphQL(fetchers);
} catch (final IOException ioe) {
throw new RuntimeException(ioe);
}
graphQLHttpService = Optional.of(new GraphQLHttpService(vertx, dataDir, graphQLConfiguration, graphQL, graphQlContextMap, besuController.getProtocolManager().ethContext().getScheduler()));
}
Optional<WebSocketService> webSocketService = Optional.empty();
if (webSocketConfiguration.isEnabled()) {
final Map<String, JsonRpcMethod> nonEngineMethods = jsonRpcMethods(protocolSchedule, context, besuController, peerNetwork, blockchainQueries, synchronizer, transactionPool, miningCoordinator, metricsSystem, supportedCapabilities, webSocketConfiguration.getRpcApis().stream().filter(apiGroup -> !apiGroup.toLowerCase().startsWith("engine")).collect(Collectors.toList()), filterManager, accountLocalConfigPermissioningController, nodeLocalConfigPermissioningController, privacyParameters, jsonRpcConfiguration, webSocketConfiguration, metricsConfiguration, natService, besuPluginContext.getNamedPlugins(), dataDir, rpcEndpointServiceImpl);
final SubscriptionManager subscriptionManager = createSubscriptionManager(vertx, transactionPool, blockchainQueries);
createLogsSubscriptionService(context.getBlockchain(), context.getWorldStateArchive(), subscriptionManager, privacyParameters);
createNewBlockHeadersSubscriptionService(context.getBlockchain(), blockchainQueries, subscriptionManager);
createSyncingSubscriptionService(synchronizer, subscriptionManager);
webSocketService = Optional.of(createWebsocketService(vertx, webSocketConfiguration, subscriptionManager, nonEngineMethods, privacyParameters, protocolSchedule, blockchainQueries, DefaultAuthenticationService.create(vertx, webSocketConfiguration), metricsSystem));
createPrivateTransactionObserver(subscriptionManager, privacyParameters);
}
Optional<MetricsService> metricsService = createMetricsService(vertx, metricsConfiguration);
final Optional<EthStatsService> ethStatsService;
if (!Strings.isNullOrEmpty(ethstatsUrl)) {
ethStatsService = Optional.of(new EthStatsService(NetstatsUrl.fromParams(ethstatsUrl, ethstatsContact), blockchainQueries, besuController.getProtocolManager(), transactionPool, miningCoordinator, besuController.getSyncState(), vertx, BesuInfo.nodeName(identityString), besuController.getGenesisConfigOptions(), network));
} else {
ethStatsService = Optional.empty();
}
final Optional<JsonRpcIpcService> jsonRpcIpcService;
if (jsonRpcIpcConfiguration.isEnabled()) {
Map<String, JsonRpcMethod> ipcMethods = jsonRpcMethods(protocolSchedule, context, besuController, peerNetwork, blockchainQueries, synchronizer, transactionPool, miningCoordinator, metricsSystem, supportedCapabilities, jsonRpcIpcConfiguration.getEnabledApis().stream().filter(apiGroup -> !apiGroup.toLowerCase().startsWith("engine")).collect(Collectors.toList()), filterManager, accountLocalConfigPermissioningController, nodeLocalConfigPermissioningController, privacyParameters, jsonRpcConfiguration, webSocketConfiguration, metricsConfiguration, natService, besuPluginContext.getNamedPlugins(), dataDir, rpcEndpointServiceImpl);
jsonRpcIpcService = Optional.of(new JsonRpcIpcService(vertx, jsonRpcIpcConfiguration.getPath(), new JsonRpcExecutor(new BaseJsonRpcProcessor(), ipcMethods)));
} else {
jsonRpcIpcService = Optional.empty();
}
return new Runner(vertx, networkRunner, natService, jsonRpcHttpService, engineJsonRpcService, graphQLHttpService, webSocketService, jsonRpcIpcService, stratumServer, metricsService, ethStatsService, besuController, dataDir, pidPath, autoLogBloomCaching ? blockchainQueries.getTransactionLogBloomCacher() : Optional.empty(), context.getBlockchain());
}
use of org.hyperledger.besu.metrics.prometheus.MetricsConfiguration in project besu by hyperledger.
the class RunnerBuilderTest method enodeUrlShouldHaveAdvertisedHostWhenDiscoveryDisabled.
@Test
public void enodeUrlShouldHaveAdvertisedHostWhenDiscoveryDisabled() {
final String p2pAdvertisedHost = "172.0.0.1";
final int p2pListenPort = 30302;
final Runner runner = new RunnerBuilder().p2pListenInterface("0.0.0.0").p2pListenPort(p2pListenPort).p2pAdvertisedHost(p2pAdvertisedHost).p2pEnabled(true).discovery(false).besuController(besuController).ethNetworkConfig(mock(EthNetworkConfig.class)).metricsSystem(mock(ObservableMetricsSystem.class)).jsonRpcConfiguration(mock(JsonRpcConfiguration.class)).permissioningService(mock(PermissioningServiceImpl.class)).graphQLConfiguration(mock(GraphQLConfiguration.class)).webSocketConfiguration(mock(WebSocketConfiguration.class)).jsonRpcIpcConfiguration(mock(JsonRpcIpcConfiguration.class)).metricsConfiguration(mock(MetricsConfiguration.class)).vertx(vertx).dataDir(dataDir.getRoot().toPath()).storageProvider(mock(KeyValueStorageProvider.class)).forkIdSupplier(() -> Collections.singletonList(Bytes.EMPTY)).rpcEndpointService(new RpcEndpointServiceImpl()).build();
runner.startEthereumMainLoop();
final EnodeURL expectedEodeURL = EnodeURLImpl.builder().ipAddress(p2pAdvertisedHost).discoveryPort(0).listeningPort(p2pListenPort).nodeId(besuController.getNodeKey().getPublicKey().getEncoded()).build();
assertThat(runner.getLocalEnode().orElseThrow()).isEqualTo(expectedEodeURL);
}
use of org.hyperledger.besu.metrics.prometheus.MetricsConfiguration in project besu by hyperledger.
the class OpenTelemetryAcceptanceTest method setUp.
@Before
public void setUp() throws Exception {
Server server = NettyServerBuilder.forPort(4317).addService(fakeTracesCollector).addService(fakeMetricsCollector).build().start();
closer.register(server::shutdownNow);
MetricsConfiguration configuration = MetricsConfiguration.builder().protocol(MetricsProtocol.OPENTELEMETRY).enabled(true).port(0).hostsAllowlist(singletonList("*")).build();
metricsNode = besu.create(new BesuNodeConfigurationBuilder().name("metrics-node").jsonRpcEnabled().metricsConfiguration(configuration).build());
cluster.start(metricsNode);
}
use of org.hyperledger.besu.metrics.prometheus.MetricsConfiguration in project besu by hyperledger.
the class ProcessBesuNodeRunner method startNode.
@Override
public void startNode(final BesuNode node) {
final Path dataDir = node.homeDirectory();
final List<String> params = new ArrayList<>();
params.add("build/install/besu/bin/besu");
params.add("--data-path");
params.add(dataDir.toAbsolutePath().toString());
if (node.isDevMode()) {
params.add("--network");
params.add("DEV");
} else if (node.getNetwork() != null) {
params.add("--network");
params.add(node.getNetwork().name());
}
params.add("--sync-mode");
params.add("FULL");
params.add("--discovery-enabled");
params.add(Boolean.toString(node.isDiscoveryEnabled()));
params.add("--p2p-host");
params.add(node.p2pListenHost());
params.add("--p2p-port");
params.add(node.getP2pPort());
if (node.getMiningParameters().isMiningEnabled()) {
params.add("--miner-enabled");
params.add("--miner-coinbase");
params.add(node.getMiningParameters().getCoinbase().get().toString());
params.add("--miner-stratum-port");
params.add(Integer.toString(node.getMiningParameters().getStratumPort()));
params.add("--miner-stratum-host");
params.add(node.getMiningParameters().getStratumNetworkInterface());
params.add("--min-gas-price");
params.add(Integer.toString(node.getMiningParameters().getMinTransactionGasPrice().intValue()));
params.add("--Xminer-remote-sealers-limit");
params.add(Integer.toString(node.getMiningParameters().getRemoteSealersLimit()));
params.add("--Xminer-remote-sealers-hashrate-ttl");
params.add(Long.toString(node.getMiningParameters().getRemoteSealersTimeToLive()));
}
if (node.getMiningParameters().isStratumMiningEnabled()) {
params.add("--miner-stratum-enabled");
}
if (node.getPrivacyParameters().isEnabled()) {
params.add("--privacy-enabled");
params.add("--privacy-url");
params.add(node.getPrivacyParameters().getEnclaveUri().toString());
if (node.getPrivacyParameters().isMultiTenancyEnabled()) {
params.add("--privacy-multi-tenancy-enabled");
} else {
params.add("--privacy-public-key-file");
params.add(node.getPrivacyParameters().getEnclavePublicKeyFile().getAbsolutePath());
}
if (!node.getExtraCLIOptions().contains("--plugin-privacy-service-signing-enabled=true")) {
params.add("--privacy-marker-transaction-signing-key-file");
params.add(node.homeDirectory().resolve("key").toString());
}
if (node.getPrivacyParameters().isFlexiblePrivacyGroupsEnabled()) {
params.add("--privacy-flexible-groups-enabled");
}
if (node.getPrivacyParameters().isPrivacyPluginEnabled()) {
params.add("--Xprivacy-plugin-enabled");
}
}
if (!node.getBootnodes().isEmpty()) {
params.add("--bootnodes");
params.add(node.getBootnodes().stream().map(URI::toString).collect(Collectors.joining(",")));
}
if (node.hasStaticNodes()) {
createStaticNodes(node);
}
if (node.isDnsEnabled()) {
params.add("--Xdns-enabled");
params.add("true");
params.add("--Xdns-update-enabled");
params.add("true");
}
if (node.isJsonRpcEnabled()) {
params.add("--rpc-http-enabled");
params.add("--rpc-http-host");
params.add(node.jsonRpcListenHost().get());
params.add("--rpc-http-port");
params.add(node.jsonRpcListenPort().map(Object::toString).get());
params.add("--rpc-http-api");
params.add(apiList(node.jsonRpcConfiguration().getRpcApis()));
if (!node.jsonRpcConfiguration().getNoAuthRpcApis().isEmpty()) {
params.add("--rpc-http-api-methods-no-auth");
params.add(apiList(node.jsonRpcConfiguration().getNoAuthRpcApis()));
}
if (node.jsonRpcConfiguration().isAuthenticationEnabled()) {
params.add("--rpc-http-authentication-enabled");
}
if (node.jsonRpcConfiguration().getAuthenticationCredentialsFile() != null) {
params.add("--rpc-http-authentication-credentials-file");
params.add(node.jsonRpcConfiguration().getAuthenticationCredentialsFile());
}
if (node.jsonRpcConfiguration().getAuthenticationPublicKeyFile() != null) {
params.add("--rpc-http-authentication-jwt-public-key-file");
params.add(node.jsonRpcConfiguration().getAuthenticationPublicKeyFile().getAbsolutePath());
}
if (node.jsonRpcConfiguration().getAuthenticationAlgorithm() != null) {
params.add("--rpc-http-authentication-jwt-algorithm");
params.add(node.jsonRpcConfiguration().getAuthenticationAlgorithm().toString());
}
}
if (node.isEngineRpcEnabled()) {
params.add("--engine-rpc-port");
params.add(node.jsonEngineListenPort().get().toString());
if (node.isEngineAuthDisabled()) {
params.add("--engine-jwt-disabled");
}
}
if (node.wsRpcEnabled()) {
params.add("--rpc-ws-enabled");
params.add("--rpc-ws-host");
params.add(node.wsRpcListenHost().get());
params.add("--rpc-ws-port");
params.add(node.wsRpcListenPort().map(Object::toString).get());
params.add("--rpc-ws-api");
params.add(apiList(node.webSocketConfiguration().getRpcApis()));
if (!node.webSocketConfiguration().getRpcApisNoAuth().isEmpty()) {
params.add("--rpc-ws-api-methods-no-auth");
params.add(apiList(node.webSocketConfiguration().getRpcApisNoAuth()));
}
if (node.webSocketConfiguration().isAuthenticationEnabled()) {
params.add("--rpc-ws-authentication-enabled");
}
if (node.webSocketConfiguration().getAuthenticationCredentialsFile() != null) {
params.add("--rpc-ws-authentication-credentials-file");
params.add(node.webSocketConfiguration().getAuthenticationCredentialsFile());
}
if (node.webSocketConfiguration().getAuthenticationPublicKeyFile() != null) {
params.add("--rpc-ws-authentication-jwt-public-key-file");
params.add(node.webSocketConfiguration().getAuthenticationPublicKeyFile().getAbsolutePath());
}
if (node.webSocketConfiguration().getAuthenticationAlgorithm() != null) {
params.add("--rpc-ws-authentication-jwt-algorithm");
params.add(node.webSocketConfiguration().getAuthenticationAlgorithm().toString());
}
}
if (node.isJsonRpcIpcEnabled()) {
final JsonRpcIpcConfiguration ipcConfiguration = node.jsonRpcIpcConfiguration();
params.add("--Xrpc-ipc-enabled");
params.add("--Xrpc-ipc-path");
params.add(ipcConfiguration.getPath().toString());
params.add("--Xrpc-ipc-apis");
params.add(String.join(",", ipcConfiguration.getEnabledApis()));
}
if (node.isMetricsEnabled()) {
final MetricsConfiguration metricsConfiguration = node.getMetricsConfiguration();
params.add("--metrics-enabled");
params.add("--metrics-host");
params.add(metricsConfiguration.getHost());
params.add("--metrics-port");
params.add(Integer.toString(metricsConfiguration.getPort()));
for (final MetricCategory category : metricsConfiguration.getMetricCategories()) {
params.add("--metrics-category");
params.add(((Enum<?>) category).name());
}
if (node.isMetricsEnabled() || metricsConfiguration.isPushEnabled()) {
params.add("--metrics-protocol");
params.add(metricsConfiguration.getProtocol().name());
}
if (metricsConfiguration.isPushEnabled()) {
params.add("--metrics-push-enabled");
params.add("--metrics-push-host");
params.add(metricsConfiguration.getPushHost());
params.add("--metrics-push-port");
params.add(Integer.toString(metricsConfiguration.getPushPort()));
params.add("--metrics-push-interval");
params.add(Integer.toString(metricsConfiguration.getPushInterval()));
params.add("--metrics-push-prometheus-job");
params.add(metricsConfiguration.getPrometheusJob());
}
}
node.getGenesisConfig().ifPresent(genesis -> {
final Path genesisFile = createGenesisFile(node, genesis);
params.add("--genesis-file");
params.add(genesisFile.toAbsolutePath().toString());
});
if (!node.isP2pEnabled()) {
params.add("--p2p-enabled");
params.add("false");
} else {
final List<String> networkConfigParams = NetworkingOptions.fromConfig(node.getNetworkingConfiguration()).getCLIOptions();
params.addAll(networkConfigParams);
if (node.getTLSConfiguration().isPresent()) {
final TLSConfiguration config = node.getTLSConfiguration().get();
params.add("--Xp2p-tls-enabled");
params.add("--Xp2p-tls-keystore-type");
params.add(config.getKeyStoreType());
params.add("--Xp2p-tls-keystore-file");
params.add(config.getKeyStorePath().toAbsolutePath().toString());
params.add("--Xp2p-tls-keystore-password-file");
params.add(config.getKeyStorePasswordPath().toAbsolutePath().toString());
params.add("--Xp2p-tls-crl-file");
params.add(config.getCrlPath().toAbsolutePath().toString());
if (null != config.getTrustStoreType()) {
params.add("--Xp2p-tls-truststore-type");
params.add(config.getTrustStoreType());
params.add("--Xp2p-tls-truststore-file");
params.add(config.getTrustStorePath().toAbsolutePath().toString());
params.add("--Xp2p-tls-truststore-password-file");
params.add(config.getTrustStorePasswordPath().toAbsolutePath().toString());
}
}
}
if (node.isRevertReasonEnabled()) {
params.add("--revert-reason-enabled");
}
params.add("--Xsecp256k1-native-enabled=" + node.isSecp256k1Native());
params.add("--Xaltbn128-native-enabled=" + node.isAltbn128Native());
node.getPermissioningConfiguration().flatMap(PermissioningConfiguration::getLocalConfig).ifPresent(permissioningConfiguration -> {
if (permissioningConfiguration.isNodeAllowlistEnabled()) {
params.add("--permissions-nodes-config-file-enabled");
}
if (permissioningConfiguration.getNodePermissioningConfigFilePath() != null) {
params.add("--permissions-nodes-config-file");
params.add(permissioningConfiguration.getNodePermissioningConfigFilePath());
}
if (permissioningConfiguration.isAccountAllowlistEnabled()) {
params.add("--permissions-accounts-config-file-enabled");
}
if (permissioningConfiguration.getAccountPermissioningConfigFilePath() != null) {
params.add("--permissions-accounts-config-file");
params.add(permissioningConfiguration.getAccountPermissioningConfigFilePath());
}
});
node.getPermissioningConfiguration().flatMap(PermissioningConfiguration::getSmartContractConfig).ifPresent(permissioningConfiguration -> {
if (permissioningConfiguration.isSmartContractNodeAllowlistEnabled()) {
params.add("--permissions-nodes-contract-enabled");
}
if (permissioningConfiguration.getNodeSmartContractAddress() != null) {
params.add("--permissions-nodes-contract-address");
params.add(permissioningConfiguration.getNodeSmartContractAddress().toString());
}
if (permissioningConfiguration.isSmartContractAccountAllowlistEnabled()) {
params.add("--permissions-accounts-contract-enabled");
}
if (permissioningConfiguration.getAccountSmartContractAddress() != null) {
params.add("--permissions-accounts-contract-address");
params.add(permissioningConfiguration.getAccountSmartContractAddress().toString());
}
params.add("--permissions-nodes-contract-version");
params.add(String.valueOf(permissioningConfiguration.getNodeSmartContractInterfaceVersion()));
});
node.getPkiKeyStoreConfiguration().ifPresent(pkiConfig -> {
params.add("--Xpki-block-creation-enabled");
params.add("--Xpki-block-creation-keystore-certificate-alias");
params.add(pkiConfig.getCertificateAlias());
params.add("--Xpki-block-creation-keystore-type");
params.add(pkiConfig.getKeyStoreType());
params.add("--Xpki-block-creation-keystore-file");
params.add(pkiConfig.getKeyStorePath().toAbsolutePath().toString());
params.add("--Xpki-block-creation-keystore-password-file");
params.add(pkiConfig.getKeyStorePasswordPath().toAbsolutePath().toString());
params.add("--Xpki-block-creation-truststore-type");
params.add(pkiConfig.getTrustStoreType());
params.add("--Xpki-block-creation-truststore-file");
params.add(pkiConfig.getTrustStorePath().toAbsolutePath().toString());
params.add("--Xpki-block-creation-truststore-password-file");
params.add(pkiConfig.getTrustStorePasswordPath().toAbsolutePath().toString());
});
params.addAll(node.getExtraCLIOptions());
params.add("--key-value-storage");
params.add("rocksdb");
params.add("--auto-log-bloom-caching-enabled");
params.add("false");
params.add("--strict-tx-replay-protection-enabled");
params.add(Boolean.toString(node.isStrictTxReplayProtectionEnabled()));
final String level = System.getProperty("root.log.level");
if (level != null) {
params.add("--logging=" + level);
}
params.addAll(node.getRunCommand());
LOG.info("Creating besu process with params {}", params);
final ProcessBuilder processBuilder = new ProcessBuilder(params).directory(new File(System.getProperty("user.dir")).getParentFile().getParentFile()).redirectErrorStream(true).redirectInput(Redirect.INHERIT);
if (!node.getPlugins().isEmpty()) {
processBuilder.environment().put("BESU_OPTS", "-Dbesu.plugins.dir=" + dataDir.resolve("plugins").toAbsolutePath().toString());
}
// Use non-blocking randomness for acceptance tests
processBuilder.environment().put("JAVA_OPTS", "-Djava.security.properties=" + "acceptance-tests/tests/build/resources/test/acceptanceTesting.security");
try {
checkState(isNotAliveOrphan(node.getName()), "A live process with name: %s, already exists. Cannot create another with the same name as it would orphan the first", node.getName());
final Process process = processBuilder.start();
process.onExit().thenRun(() -> node.setExitCode(process.exitValue()));
outputProcessorExecutor.execute(() -> printOutput(node, process));
besuProcesses.put(node.getName(), process);
} catch (final IOException e) {
LOG.error("Error starting BesuNode process", e);
}
if (node.getRunCommand().isEmpty()) {
waitForFile(dataDir, "besu.ports");
waitForFile(dataDir, "besu.networks");
}
MDC.remove("node");
}
use of org.hyperledger.besu.metrics.prometheus.MetricsConfiguration in project besu by hyperledger.
the class JsonRpcTestMethodsFactory method methods.
public Map<String, JsonRpcMethod> methods() {
final P2PNetwork peerDiscovery = mock(P2PNetwork.class);
final EthPeers ethPeers = mock(EthPeers.class);
final TransactionPool transactionPool = mock(TransactionPool.class);
final PoWMiningCoordinator miningCoordinator = mock(PoWMiningCoordinator.class);
final ObservableMetricsSystem metricsSystem = new NoOpMetricsSystem();
final Optional<AccountLocalConfigPermissioningController> accountWhitelistController = Optional.of(mock(AccountLocalConfigPermissioningController.class));
final Optional<NodeLocalConfigPermissioningController> nodeWhitelistController = Optional.of(mock(NodeLocalConfigPermissioningController.class));
final PrivacyParameters privacyParameters = mock(PrivacyParameters.class);
final FilterManager filterManager = new FilterManagerBuilder().blockchainQueries(blockchainQueries).transactionPool(transactionPool).privacyParameters(privacyParameters).build();
final JsonRpcConfiguration jsonRpcConfiguration = mock(JsonRpcConfiguration.class);
final WebSocketConfiguration webSocketConfiguration = mock(WebSocketConfiguration.class);
final MetricsConfiguration metricsConfiguration = mock(MetricsConfiguration.class);
final NatService natService = new NatService(Optional.empty());
final List<String> apis = new ArrayList<>();
apis.add(RpcApis.ETH.name());
apis.add(RpcApis.NET.name());
apis.add(RpcApis.WEB3.name());
apis.add(RpcApis.PRIV.name());
apis.add(RpcApis.DEBUG.name());
final Path dataDir = mock(Path.class);
return new JsonRpcMethodsFactory().methods(CLIENT_VERSION, NETWORK_ID, new StubGenesisConfigOptions(), peerDiscovery, blockchainQueries, synchronizer, importer.getProtocolSchedule(), context, filterManager, transactionPool, miningCoordinator, metricsSystem, new HashSet<>(), accountWhitelistController, nodeWhitelistController, apis, privacyParameters, jsonRpcConfiguration, webSocketConfiguration, metricsConfiguration, natService, new HashMap<>(), dataDir, ethPeers);
}
Aggregations