mirror of
https://github.com/vacp2p/status-linea-besu.git
synced 2026-01-09 15:28:09 -05:00
Metrics via dagger (#5244)
* dagger component * pushed up MetricsSystemModule * passes around the BesuComponent as an interim application context till more things are managed by Dagger --------- Signed-off-by: Justin Florentine <justin+github@florentine.us>
This commit is contained in:
committed by
GitHub
parent
681f4a5116
commit
25ab21128e
@@ -28,6 +28,8 @@ dependencies {
|
||||
|
||||
implementation 'com.github.tomakehurst:wiremock-jre8'
|
||||
implementation 'com.google.guava:guava'
|
||||
implementation 'com.google.dagger:dagger'
|
||||
annotationProcessor 'com.google.dagger:dagger-compiler'
|
||||
implementation 'com.squareup.okhttp3:okhttp'
|
||||
implementation 'info.picocli:picocli'
|
||||
implementation 'io.reactivex.rxjava2:rxjava'
|
||||
|
||||
@@ -63,6 +63,7 @@ dependencies {
|
||||
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8'
|
||||
implementation 'com.github.oshi:oshi-core'
|
||||
implementation 'com.google.guava:guava'
|
||||
implementation 'com.google.dagger:dagger'
|
||||
implementation 'com.graphql-java:graphql-java'
|
||||
implementation 'info.picocli:picocli'
|
||||
implementation 'io.vertx:vertx-core'
|
||||
@@ -102,4 +103,5 @@ dependencies {
|
||||
testImplementation 'tech.pegasys.discovery:discovery'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
annotationProcessor 'com.google.dagger:dagger-compiler'
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright ConsenSys AG.
|
||||
* Copyright Hyperledger Besu Contributors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
@@ -14,13 +14,9 @@
|
||||
*/
|
||||
package org.hyperledger.besu;
|
||||
|
||||
import org.hyperledger.besu.chainexport.RlpBlockExporter;
|
||||
import org.hyperledger.besu.chainimport.JsonBlockImporter;
|
||||
import org.hyperledger.besu.chainimport.RlpBlockImporter;
|
||||
import org.hyperledger.besu.cli.BesuCommand;
|
||||
import org.hyperledger.besu.cli.logging.BesuLoggingConfigurationFactory;
|
||||
import org.hyperledger.besu.controller.BesuController;
|
||||
import org.hyperledger.besu.services.BesuPluginContextImpl;
|
||||
import org.hyperledger.besu.components.DaggerBesuComponent;
|
||||
|
||||
import io.netty.util.internal.logging.InternalLoggerFactory;
|
||||
import io.netty.util.internal.logging.Log4J2LoggerFactory;
|
||||
@@ -37,19 +33,8 @@ public final class Besu {
|
||||
* @param args command line arguments.
|
||||
*/
|
||||
public static void main(final String... args) {
|
||||
final Logger logger = setupLogging();
|
||||
|
||||
final BesuCommand besuCommand =
|
||||
new BesuCommand(
|
||||
logger,
|
||||
RlpBlockImporter::new,
|
||||
JsonBlockImporter::new,
|
||||
RlpBlockExporter::new,
|
||||
new RunnerBuilder(),
|
||||
new BesuController.Builder(),
|
||||
new BesuPluginContextImpl(),
|
||||
System.getenv());
|
||||
|
||||
setupLogging();
|
||||
final BesuCommand besuCommand = DaggerBesuComponent.create().getBesuCommand();
|
||||
int exitCode =
|
||||
besuCommand.parse(
|
||||
new RunLast(),
|
||||
@@ -61,7 +46,11 @@ public final class Besu {
|
||||
System.exit(exitCode);
|
||||
}
|
||||
|
||||
private static Logger setupLogging() {
|
||||
/**
|
||||
* a Logger setup for handling any exceptions during the bootstrap process, to indicate to users
|
||||
* their CLI configuration had problems.
|
||||
*/
|
||||
public static void setupLogging() {
|
||||
try {
|
||||
InternalLoggerFactory.setDefaultFactory(Log4J2LoggerFactory.INSTANCE);
|
||||
} catch (Throwable t) {
|
||||
@@ -81,6 +70,14 @@ public final class Besu {
|
||||
"Could not set logging system property: %s - %s%n",
|
||||
t.getClass().getSimpleName(), t.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first logger to be created. This is used to set the default uncaught exception
|
||||
*
|
||||
* @return Logger
|
||||
*/
|
||||
public static Logger getFirstLogger() {
|
||||
final Logger logger = LoggerFactory.getLogger(Besu.class);
|
||||
Thread.setDefaultUncaughtExceptionHandler(slf4jExceptionHandler(logger));
|
||||
Thread.currentThread().setUncaughtExceptionHandler(slf4jExceptionHandler(logger));
|
||||
|
||||
@@ -86,6 +86,7 @@ import org.hyperledger.besu.cli.util.BesuCommandCustomFactory;
|
||||
import org.hyperledger.besu.cli.util.CommandLineUtils;
|
||||
import org.hyperledger.besu.cli.util.ConfigOptionSearchAndRunHandler;
|
||||
import org.hyperledger.besu.cli.util.VersionProvider;
|
||||
import org.hyperledger.besu.components.BesuComponent;
|
||||
import org.hyperledger.besu.config.CheckpointConfigOptions;
|
||||
import org.hyperledger.besu.config.GenesisConfigFile;
|
||||
import org.hyperledger.besu.config.GenesisConfigOptions;
|
||||
@@ -1323,8 +1324,15 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
||||
private Collection<EnodeURL> staticNodes;
|
||||
private BesuController besuController;
|
||||
private BesuConfiguration pluginCommonConfiguration;
|
||||
|
||||
private BesuComponent besuComponent;
|
||||
private final Supplier<ObservableMetricsSystem> metricsSystem =
|
||||
Suppliers.memoize(() -> MetricsSystemFactory.create(metricsConfiguration()));
|
||||
Suppliers.memoize(
|
||||
() -> {
|
||||
return besuComponent == null
|
||||
? MetricsSystemFactory.create(metricsConfiguration())
|
||||
: besuComponent.getObservableMetricsSystem();
|
||||
});
|
||||
private Vertx vertx;
|
||||
private EnodeDnsConfiguration enodeDnsConfiguration;
|
||||
private KeyValueStorageProvider keyValueStorageProvider;
|
||||
@@ -1334,7 +1342,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
||||
/**
|
||||
* Besu command constructor.
|
||||
*
|
||||
* @param logger Logger instance
|
||||
* @param besuComponent BesuComponent which acts as our application context
|
||||
* @param rlpBlockImporter RlpBlockImporter supplier
|
||||
* @param jsonBlockImporterFactory instance of {@code Function<BesuController, JsonBlockImporter>}
|
||||
* @param rlpBlockExporterFactory instance of {@code Function<Blockchain, RlpBlockExporter>}
|
||||
@@ -1344,7 +1352,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
||||
* @param environment Environment variables map
|
||||
*/
|
||||
public BesuCommand(
|
||||
final Logger logger,
|
||||
final BesuComponent besuComponent,
|
||||
final Supplier<RlpBlockImporter> rlpBlockImporter,
|
||||
final Function<BesuController, JsonBlockImporter> jsonBlockImporterFactory,
|
||||
final Function<Blockchain, RlpBlockExporter> rlpBlockExporterFactory,
|
||||
@@ -1353,7 +1361,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
||||
final BesuPluginContextImpl besuPluginContext,
|
||||
final Map<String, String> environment) {
|
||||
this(
|
||||
logger,
|
||||
besuComponent,
|
||||
rlpBlockImporter,
|
||||
jsonBlockImporterFactory,
|
||||
rlpBlockExporterFactory,
|
||||
@@ -1372,7 +1380,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
||||
/**
|
||||
* Overloaded Besu command constructor visible for testing.
|
||||
*
|
||||
* @param logger Logger instance
|
||||
* @param besuComponent BesuComponent which acts as our application context
|
||||
* @param rlpBlockImporter RlpBlockImporter supplier
|
||||
* @param jsonBlockImporterFactory instance of {@code Function<BesuController, JsonBlockImporter>}
|
||||
* @param rlpBlockExporterFactory instance of {@code Function<Blockchain, RlpBlockExporter>}
|
||||
@@ -1389,7 +1397,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
||||
*/
|
||||
@VisibleForTesting
|
||||
protected BesuCommand(
|
||||
final Logger logger,
|
||||
final BesuComponent besuComponent,
|
||||
final Supplier<RlpBlockImporter> rlpBlockImporter,
|
||||
final Function<BesuController, JsonBlockImporter> jsonBlockImporterFactory,
|
||||
final Function<Blockchain, RlpBlockExporter> rlpBlockExporterFactory,
|
||||
@@ -1403,7 +1411,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
||||
final PrivacyPluginServiceImpl privacyPluginService,
|
||||
final PkiBlockCreationConfigurationProvider pkiBlockCreationConfigProvider,
|
||||
final RpcEndpointServiceImpl rpcEndpointServiceImpl) {
|
||||
this.logger = logger;
|
||||
this.logger = besuComponent.getBesuCommandLogger();
|
||||
this.rlpBlockImporter = rlpBlockImporter;
|
||||
this.rlpBlockExporterFactory = rlpBlockExporterFactory;
|
||||
this.jsonBlockImporterFactory = jsonBlockImporterFactory;
|
||||
@@ -1438,9 +1446,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
||||
final InputStream in,
|
||||
final String... args) {
|
||||
|
||||
commandLine =
|
||||
new CommandLine(this, new BesuCommandCustomFactory(besuPluginContext))
|
||||
.setCaseInsensitiveEnumValuesAllowed(true);
|
||||
toCommandLine();
|
||||
|
||||
handleStableOptions();
|
||||
addSubCommands(in);
|
||||
@@ -1454,6 +1460,13 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
/** Used by Dagger to parse all options into a commandline instance. */
|
||||
public void toCommandLine() {
|
||||
commandLine =
|
||||
new CommandLine(this, new BesuCommandCustomFactory(besuPluginContext))
|
||||
.setCaseInsensitiveEnumValuesAllowed(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (network != null && network.isDeprecated()) {
|
||||
@@ -2206,7 +2219,9 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
||||
*/
|
||||
public BesuController buildController() {
|
||||
try {
|
||||
return getControllerBuilder().build();
|
||||
return this.besuComponent == null
|
||||
? getControllerBuilder().build()
|
||||
: getControllerBuilder().besuComponent(this.besuComponent).build();
|
||||
} catch (final Exception e) {
|
||||
throw new ExecutionException(this.commandLine, e.getMessage(), e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright Hyperledger Besu Contributors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package org.hyperledger.besu.components;
|
||||
|
||||
import org.hyperledger.besu.Besu;
|
||||
import org.hyperledger.besu.RunnerBuilder;
|
||||
import org.hyperledger.besu.chainexport.RlpBlockExporter;
|
||||
import org.hyperledger.besu.chainimport.JsonBlockImporter;
|
||||
import org.hyperledger.besu.chainimport.RlpBlockImporter;
|
||||
import org.hyperledger.besu.cli.BesuCommand;
|
||||
import org.hyperledger.besu.controller.BesuController;
|
||||
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
|
||||
import org.hyperledger.besu.services.BesuPluginContextImpl;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
/**
|
||||
* A dagger module that know how to create the BesuCommand, which collects all configuration
|
||||
* settings.
|
||||
*/
|
||||
@Module
|
||||
public class BesuCommandModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
BesuCommand provideBesuCommand(final BesuComponent besuComponent) {
|
||||
final BesuCommand besuCommand =
|
||||
new BesuCommand(
|
||||
besuComponent,
|
||||
RlpBlockImporter::new,
|
||||
JsonBlockImporter::new,
|
||||
RlpBlockExporter::new,
|
||||
new RunnerBuilder(),
|
||||
new BesuController.Builder(),
|
||||
new BesuPluginContextImpl(),
|
||||
System.getenv());
|
||||
besuCommand.toCommandLine();
|
||||
return besuCommand;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
MetricsConfiguration provideMetricsConfiguration(final BesuCommand provideFrom) {
|
||||
return provideFrom.metricsConfiguration();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Named("besuCommandLogger")
|
||||
@Singleton
|
||||
Logger provideBesuCommandLogger() {
|
||||
return Besu.getFirstLogger();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright Hyperledger Besu Contributors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
*/
|
||||
|
||||
package org.hyperledger.besu.components;
|
||||
|
||||
import org.hyperledger.besu.cli.BesuCommand;
|
||||
import org.hyperledger.besu.ethereum.bonsai.cache.CachedMerkleTrieLoader;
|
||||
import org.hyperledger.besu.ethereum.bonsai.cache.CachedMerkleTrieLoaderModule;
|
||||
import org.hyperledger.besu.metrics.MetricsSystemModule;
|
||||
import org.hyperledger.besu.metrics.ObservableMetricsSystem;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Component;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
/** An application context that knows how to provide dependencies based on Dagger setup. */
|
||||
@Singleton
|
||||
@Component(
|
||||
modules = {
|
||||
BesuCommandModule.class,
|
||||
MetricsSystemModule.class,
|
||||
CachedMerkleTrieLoaderModule.class
|
||||
})
|
||||
public interface BesuComponent {
|
||||
|
||||
/**
|
||||
* the configured and parsed representation of the user issued command to run Besu
|
||||
*
|
||||
* @return BesuCommand
|
||||
*/
|
||||
BesuCommand getBesuCommand();
|
||||
|
||||
/**
|
||||
* a cached trie node loader
|
||||
*
|
||||
* @return CachedMerkleTrieLoader
|
||||
*/
|
||||
CachedMerkleTrieLoader getCachedMerkleTrieLoader();
|
||||
|
||||
/**
|
||||
* a metrics system that is observable by a Prometheus or OTEL metrics collection subsystem
|
||||
*
|
||||
* @return ObservableMetricsSystem
|
||||
*/
|
||||
ObservableMetricsSystem getObservableMetricsSystem();
|
||||
|
||||
/**
|
||||
* a Logger specifically configured to provide configuration feedback to users.
|
||||
*
|
||||
* @return Logger
|
||||
*/
|
||||
@Named("besuCommandLogger")
|
||||
Logger getBesuCommandLogger();
|
||||
}
|
||||
@@ -16,6 +16,7 @@ package org.hyperledger.besu.controller;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.hyperledger.besu.components.BesuComponent;
|
||||
import org.hyperledger.besu.config.CheckpointConfigOptions;
|
||||
import org.hyperledger.besu.config.GenesisConfigFile;
|
||||
import org.hyperledger.besu.config.GenesisConfigOptions;
|
||||
@@ -178,6 +179,19 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
|
||||
|
||||
private NetworkingConfiguration networkingConfiguration;
|
||||
private Boolean randomPeerPriority;
|
||||
/** the Dagger configured context that can provide dependencies */
|
||||
protected BesuComponent besuComponent = null;
|
||||
|
||||
/**
|
||||
* Provide a BesuComponent which can be used to get other dependencies
|
||||
*
|
||||
* @param besuComponent application context that can be used to get other dependencies
|
||||
* @return the besu controller builder
|
||||
*/
|
||||
public BesuControllerBuilder besuComponent(final BesuComponent besuComponent) {
|
||||
this.besuComponent = besuComponent;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Storage provider besu controller builder.
|
||||
@@ -547,7 +561,10 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
|
||||
reorgLoggingThreshold,
|
||||
dataDirectory.toString());
|
||||
|
||||
final CachedMerkleTrieLoader cachedMerkleTrieLoader = new CachedMerkleTrieLoader(metricsSystem);
|
||||
final CachedMerkleTrieLoader cachedMerkleTrieLoader =
|
||||
besuComponent == null
|
||||
? new CachedMerkleTrieLoader(metricsSystem)
|
||||
: besuComponent.getCachedMerkleTrieLoader();
|
||||
|
||||
final WorldStateArchive worldStateArchive =
|
||||
createWorldStateArchive(worldStateStorage, blockchain, cachedMerkleTrieLoader);
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.hyperledger.besu.cli.options.unstable.MetricsCLIOptions;
|
||||
import org.hyperledger.besu.cli.options.unstable.NetworkingOptions;
|
||||
import org.hyperledger.besu.cli.options.unstable.SynchronizerOptions;
|
||||
import org.hyperledger.besu.cli.options.unstable.TransactionPoolOptions;
|
||||
import org.hyperledger.besu.components.BesuComponent;
|
||||
import org.hyperledger.besu.consensus.qbft.pki.PkiBlockCreationConfiguration;
|
||||
import org.hyperledger.besu.consensus.qbft.pki.PkiBlockCreationConfigurationProvider;
|
||||
import org.hyperledger.besu.controller.BesuController;
|
||||
@@ -166,6 +167,8 @@ public abstract class CommandTestAbstract {
|
||||
@Mock
|
||||
protected Logger mockLogger;
|
||||
|
||||
@Mock protected BesuComponent mockBesuComponent;
|
||||
|
||||
@Mock protected PkiBlockCreationConfigurationProvider mockPkiBlockCreationConfigProvider;
|
||||
@Mock protected PkiBlockCreationConfiguration mockPkiBlockCreationConfiguration;
|
||||
|
||||
@@ -318,6 +321,7 @@ public abstract class CommandTestAbstract {
|
||||
.doReturn(mockPkiBlockCreationConfiguration)
|
||||
.when(mockPkiBlockCreationConfigProvider)
|
||||
.load(pkiKeyStoreConfigurationArgumentCaptor.capture());
|
||||
when(mockBesuComponent.getBesuCommandLogger()).thenReturn(mockLogger);
|
||||
}
|
||||
|
||||
@Before
|
||||
@@ -402,7 +406,7 @@ public abstract class CommandTestAbstract {
|
||||
switch (testType) {
|
||||
case REQUIRED_OPTION:
|
||||
return new TestBesuCommandWithRequiredOption(
|
||||
mockLogger,
|
||||
mockBesuComponent,
|
||||
() -> rlpBlockImporter,
|
||||
this::jsonBlockImporterFactory,
|
||||
(blockchain) -> rlpBlockExporter,
|
||||
@@ -416,7 +420,7 @@ public abstract class CommandTestAbstract {
|
||||
privacyPluginService);
|
||||
case PORT_CHECK:
|
||||
return new TestBesuCommand(
|
||||
mockLogger,
|
||||
mockBesuComponent,
|
||||
() -> rlpBlockImporter,
|
||||
this::jsonBlockImporterFactory,
|
||||
(blockchain) -> rlpBlockExporter,
|
||||
@@ -430,7 +434,7 @@ public abstract class CommandTestAbstract {
|
||||
privacyPluginService);
|
||||
default:
|
||||
return new TestBesuCommandWithoutPortCheck(
|
||||
mockLogger,
|
||||
mockBesuComponent,
|
||||
() -> rlpBlockImporter,
|
||||
this::jsonBlockImporterFactory,
|
||||
(blockchain) -> rlpBlockExporter,
|
||||
@@ -452,7 +456,7 @@ public abstract class CommandTestAbstract {
|
||||
private Vertx vertx;
|
||||
|
||||
TestBesuCommand(
|
||||
final Logger mockLogger,
|
||||
final BesuComponent besuComponent,
|
||||
final Supplier<RlpBlockImporter> mockBlockImporter,
|
||||
final Function<BesuController, JsonBlockImporter> jsonBlockImporterFactory,
|
||||
final Function<Blockchain, RlpBlockExporter> rlpBlockExporterFactory,
|
||||
@@ -465,7 +469,7 @@ public abstract class CommandTestAbstract {
|
||||
final PkiBlockCreationConfigurationProvider pkiBlockCreationConfigProvider,
|
||||
final PrivacyPluginServiceImpl privacyPluginService) {
|
||||
super(
|
||||
mockLogger,
|
||||
besuComponent,
|
||||
mockBlockImporter,
|
||||
jsonBlockImporterFactory,
|
||||
rlpBlockExporterFactory,
|
||||
@@ -536,7 +540,7 @@ public abstract class CommandTestAbstract {
|
||||
private final Boolean acceptTermsAndConditions = false;
|
||||
|
||||
TestBesuCommandWithRequiredOption(
|
||||
final Logger mockLogger,
|
||||
final BesuComponent besuComponent,
|
||||
final Supplier<RlpBlockImporter> mockBlockImporter,
|
||||
final Function<BesuController, JsonBlockImporter> jsonBlockImporterFactory,
|
||||
final Function<Blockchain, RlpBlockExporter> rlpBlockExporterFactory,
|
||||
@@ -549,7 +553,7 @@ public abstract class CommandTestAbstract {
|
||||
final PkiBlockCreationConfigurationProvider pkiBlockCreationConfigProvider,
|
||||
final PrivacyPluginServiceImpl privacyPluginService) {
|
||||
super(
|
||||
mockLogger,
|
||||
besuComponent,
|
||||
mockBlockImporter,
|
||||
jsonBlockImporterFactory,
|
||||
rlpBlockExporterFactory,
|
||||
@@ -572,7 +576,7 @@ public abstract class CommandTestAbstract {
|
||||
public static class TestBesuCommandWithoutPortCheck extends TestBesuCommand {
|
||||
|
||||
TestBesuCommandWithoutPortCheck(
|
||||
final Logger mockLogger,
|
||||
final BesuComponent context,
|
||||
final Supplier<RlpBlockImporter> mockBlockImporter,
|
||||
final Function<BesuController, JsonBlockImporter> jsonBlockImporterFactory,
|
||||
final Function<Blockchain, RlpBlockExporter> rlpBlockExporterFactory,
|
||||
@@ -585,7 +589,7 @@ public abstract class CommandTestAbstract {
|
||||
final PkiBlockCreationConfigurationProvider pkiBlockCreationConfigProvider,
|
||||
final PrivacyPluginServiceImpl privacyPluginService) {
|
||||
super(
|
||||
mockLogger,
|
||||
context,
|
||||
mockBlockImporter,
|
||||
jsonBlockImporterFactory,
|
||||
rlpBlockExporterFactory,
|
||||
|
||||
@@ -46,6 +46,8 @@ dependencies {
|
||||
|
||||
implementation 'com.fasterxml.jackson.core:jackson-databind'
|
||||
implementation 'com.google.guava:guava'
|
||||
implementation 'com.google.dagger:dagger'
|
||||
annotationProcessor 'com.google.dagger:dagger-compiler'
|
||||
implementation 'io.opentelemetry:opentelemetry-api'
|
||||
implementation 'io.vertx:vertx-core'
|
||||
implementation 'net.java.dev.jna:jna'
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright Hyperledger Besu Contributors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package org.hyperledger.besu.ethereum.bonsai.cache;
|
||||
|
||||
import org.hyperledger.besu.metrics.ObservableMetricsSystem;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Module
|
||||
public class CachedMerkleTrieLoaderModule {
|
||||
|
||||
@Provides
|
||||
CachedMerkleTrieLoader provideCachedMerkleTrieLoaderModule(
|
||||
final ObservableMetricsSystem metricsSystem) {
|
||||
return new CachedMerkleTrieLoader(metricsSystem);
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,7 @@ import org.hyperledger.besu.evm.tracing.OperationTracer;
|
||||
import org.hyperledger.besu.evm.tracing.StandardJsonTracer;
|
||||
import org.hyperledger.besu.evm.worldstate.WorldState;
|
||||
import org.hyperledger.besu.evm.worldstate.WorldUpdater;
|
||||
import org.hyperledger.besu.metrics.MetricsSystemModule;
|
||||
import org.hyperledger.besu.util.LogConfigurator;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright ConsenSys AG.
|
||||
* Copyright Hyperledger Besu Contributors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
@@ -20,6 +20,8 @@ import org.hyperledger.besu.ethereum.core.BlockHeader;
|
||||
import org.hyperledger.besu.ethereum.core.MutableWorldState;
|
||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
|
||||
import org.hyperledger.besu.evm.worldstate.WorldUpdater;
|
||||
import org.hyperledger.besu.metrics.MetricsConfigurationModule;
|
||||
import org.hyperledger.besu.metrics.MetricsSystemModule;
|
||||
|
||||
import java.util.function.Function;
|
||||
import javax.inject.Singleton;
|
||||
@@ -34,6 +36,7 @@ import dagger.Component;
|
||||
DataStoreModule.class,
|
||||
BlockchainModule.class,
|
||||
EvmToolCommandOptionsModule.class,
|
||||
MetricsConfigurationModule.class,
|
||||
MetricsSystemModule.class,
|
||||
})
|
||||
public interface EvmToolComponent {
|
||||
|
||||
@@ -39,6 +39,8 @@ dependencies {
|
||||
api 'org.slf4j:slf4j-api'
|
||||
|
||||
implementation 'com.google.guava:guava'
|
||||
implementation 'com.google.dagger:dagger'
|
||||
implementation 'info.picocli:picocli'
|
||||
implementation 'io.grpc:grpc-netty'
|
||||
implementation 'io.grpc:grpc-core'
|
||||
implementation 'io.netty:netty-tcnative-boringssl-static'
|
||||
@@ -71,6 +73,8 @@ dependencies {
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
|
||||
testSupportImplementation 'org.mockito:mockito-core'
|
||||
|
||||
annotationProcessor 'com.google.dagger:dagger-compiler'
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright ConsenSys AG.
|
||||
* Copyright Hyperledger Besu Contributors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
@@ -11,27 +11,23 @@
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
*/
|
||||
|
||||
package org.hyperledger.besu.evmtool;
|
||||
package org.hyperledger.besu.metrics;
|
||||
|
||||
import org.hyperledger.besu.metrics.MetricsSystemFactory;
|
||||
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
|
||||
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
/** Dagger module for providing the {@link MetricsConfiguration} instance. */
|
||||
@Module
|
||||
public class MetricsSystemModule {
|
||||
|
||||
public class MetricsConfigurationModule {
|
||||
@Provides
|
||||
@Singleton
|
||||
MetricsSystem getMetricsSystem() {
|
||||
return MetricsSystemFactory.create(MetricsConfiguration.builder().build());
|
||||
MetricsConfiguration provideMetricsConfiguration() {
|
||||
return MetricsConfiguration.builder().build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright Hyperledger Besu Contributors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
*/
|
||||
|
||||
package org.hyperledger.besu.metrics;
|
||||
|
||||
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
|
||||
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
/**
|
||||
* Dagger module for providing the {@link MetricsSystem} and {@link ObservableMetricsSystem}
|
||||
* instances.
|
||||
*/
|
||||
@Module
|
||||
public class MetricsSystemModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
MetricsSystem provideMetricsSystem(final MetricsConfiguration metricsConfig) {
|
||||
return MetricsSystemFactory.create(metricsConfig);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
ObservableMetricsSystem provideObservableMetricsSystem(final MetricsConfiguration metricsConfig) {
|
||||
return MetricsSystemFactory.create(metricsConfig);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright ConsenSys AG.
|
||||
* Copyright Hyperledger Besu Contributors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
|
||||
Reference in New Issue
Block a user