Search in sources :

Example 1 with NoOpMetricsSystem

use of org.hyperledger.besu.metrics.noop.NoOpMetricsSystem in project teku by ConsenSys.

the class DirectEventDelivererTest method shouldNotifyExceptionHandlerWhenIllegalAccessExceptionOccurs.

@Test
void shouldNotifyExceptionHandlerWhenIllegalAccessExceptionOccurs() throws Exception {
    final ClassWithPrivateMethod target = new ClassWithPrivateMethod();
    final Method method = ClassWithPrivateMethod.class.getDeclaredMethod("run");
    final DirectEventDeliverer<ClassWithPrivateMethod> deliverer = new DirectEventDeliverer<>(exceptionHandler, new NoOpMetricsSystem());
    deliverer.deliverTo(target, method, NO_ARGS);
    verify(exceptionHandler).handleException(any(IllegalAccessException.class), eq(target), eq(method), eq(NO_ARGS));
    verifyNoMoreInteractions(exceptionHandler);
}
Also used : NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) Method(java.lang.reflect.Method) Test(org.junit.jupiter.api.Test)

Example 2 with NoOpMetricsSystem

use of org.hyperledger.besu.metrics.noop.NoOpMetricsSystem in project teku by ConsenSys.

the class DebugDbCommand method getLatestFinalizedState.

@Command(name = "get-latest-finalized-state", description = "Get the latest finalized state, if available, as SSZ", mixinStandardHelpOptions = true, showDefaultValues = true, abbreviateSynopsis = true, versionProvider = PicoCliVersionProvider.class, synopsisHeading = "%n", descriptionHeading = "%nDescription:%n%n", optionListHeading = "%nOptions:%n", footerHeading = "%n", footer = "Teku is licensed under the Apache License 2.0")
public int getLatestFinalizedState(@Mixin final BeaconNodeDataOptions dataOptions, @Mixin final DataStorageOptions dataStorageOptions, @Mixin final Eth2NetworkOptions eth2NetworkOptions, @Option(required = true, names = { "--output", "-o" }, description = "File to write state to") final Path outputFile, @Option(names = { "--block-output" }, description = "File to write the block matching the latest finalized state to") final Path blockOutputFile) throws Exception {
    final AsyncRunner asyncRunner = ScheduledExecutorAsyncRunner.create("async", 1, new MetricTrackingExecutorFactory(new NoOpMetricsSystem()));
    try (final Database database = createDatabase(dataOptions, dataStorageOptions, eth2NetworkOptions)) {
        final Optional<AnchorPoint> finalizedAnchor = database.createMemoryStore().map(builder -> builder.blockProvider(BlockProvider.NOOP).asyncRunner(asyncRunner).stateProvider(StateAndBlockSummaryProvider.NOOP).build()).map(UpdatableStore::getLatestFinalized);
        int result = writeState(outputFile, finalizedAnchor.map(AnchorPoint::getState));
        if (result == 0 && blockOutputFile != null) {
            final Optional<SignedBeaconBlock> finalizedBlock = finalizedAnchor.flatMap(AnchorPoint::getSignedBeaconBlock);
            result = writeBlock(blockOutputFile, finalizedBlock);
        }
        return result;
    } finally {
        asyncRunner.shutdown();
    }
}
Also used : BlockProvider(tech.pegasys.teku.dataproviders.lookup.BlockProvider) DataDirLayout(tech.pegasys.teku.service.serviceutils.layout.DataDirLayout) UpdatableStore(tech.pegasys.teku.storage.store.UpdatableStore) BeaconNodeDataOptions(tech.pegasys.teku.cli.options.BeaconNodeDataOptions) NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) DepositStorage(tech.pegasys.teku.storage.server.DepositStorage) VersionedDatabaseFactory(tech.pegasys.teku.storage.server.VersionedDatabaseFactory) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64) Command(picocli.CommandLine.Command) MetricTrackingExecutorFactory(tech.pegasys.teku.infrastructure.async.MetricTrackingExecutorFactory) Spec(tech.pegasys.teku.spec.Spec) SignedBeaconBlock(tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock) Path(java.nio.file.Path) CommandLine(picocli.CommandLine) AsyncRunner(tech.pegasys.teku.infrastructure.async.AsyncRunner) Files(java.nio.file.Files) ScheduledExecutorAsyncRunner(tech.pegasys.teku.infrastructure.async.ScheduledExecutorAsyncRunner) Mixin(picocli.CommandLine.Mixin) IOException(java.io.IOException) StateAndBlockSummaryProvider(tech.pegasys.teku.dataproviders.lookup.StateAndBlockSummaryProvider) Option(picocli.CommandLine.Option) PicoCliVersionProvider(tech.pegasys.teku.cli.converter.PicoCliVersionProvider) Database(tech.pegasys.teku.storage.server.Database) Eth2NetworkOptions(tech.pegasys.teku.cli.options.Eth2NetworkOptions) AnchorPoint(tech.pegasys.teku.spec.datastructures.state.AnchorPoint) Optional(java.util.Optional) DataStorageOptions(tech.pegasys.teku.cli.options.DataStorageOptions) BeaconState(tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState) AnchorPoint(tech.pegasys.teku.spec.datastructures.state.AnchorPoint) UpdatableStore(tech.pegasys.teku.storage.store.UpdatableStore) MetricTrackingExecutorFactory(tech.pegasys.teku.infrastructure.async.MetricTrackingExecutorFactory) NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) Database(tech.pegasys.teku.storage.server.Database) SignedBeaconBlock(tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock) AnchorPoint(tech.pegasys.teku.spec.datastructures.state.AnchorPoint) AsyncRunner(tech.pegasys.teku.infrastructure.async.AsyncRunner) ScheduledExecutorAsyncRunner(tech.pegasys.teku.infrastructure.async.ScheduledExecutorAsyncRunner) Command(picocli.CommandLine.Command)

Example 3 with NoOpMetricsSystem

use of org.hyperledger.besu.metrics.noop.NoOpMetricsSystem in project teku by ConsenSys.

the class WeakSubjectivityCommand method createDatabase.

private Database createDatabase(final BeaconNodeDataOptions dataOptions, final DataStorageOptions dataStorageOptions, final Eth2NetworkOptions eth2NetworkOptions) {
    final Spec spec = eth2NetworkOptions.getNetworkConfiguration().getSpec();
    final VersionedDatabaseFactory databaseFactory = new VersionedDatabaseFactory(new NoOpMetricsSystem(), DataDirLayout.createFrom(dataOptions.getDataConfig()).getBeaconDataDirectory(), dataStorageOptions.getDataStorageMode(), eth2NetworkOptions.getNetworkConfiguration().getEth1DepositContractAddress(), dataStorageOptions.isStoreNonCanonicalBlocks(), spec);
    return databaseFactory.createDatabase();
}
Also used : NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) VersionedDatabaseFactory(tech.pegasys.teku.storage.server.VersionedDatabaseFactory) Spec(tech.pegasys.teku.spec.Spec)

Example 4 with NoOpMetricsSystem

use of org.hyperledger.besu.metrics.noop.NoOpMetricsSystem in project besu by hyperledger.

the class JsonRpcHttpServiceLoginTest method initServerAndClient.

@BeforeClass
public static void initServerAndClient() throws Exception {
    peerDiscoveryMock = mock(P2PNetwork.class);
    blockchainQueries = mock(BlockchainQueries.class);
    synchronizer = mock(Synchronizer.class);
    final Set<Capability> supportedCapabilities = new HashSet<>();
    supportedCapabilities.add(EthProtocol.ETH62);
    supportedCapabilities.add(EthProtocol.ETH63);
    final StubGenesisConfigOptions genesisConfigOptions = new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID);
    rpcMethods = spy(new JsonRpcMethodsFactory().methods(CLIENT_VERSION, CHAIN_ID, genesisConfigOptions, peerDiscoveryMock, blockchainQueries, synchronizer, MainnetProtocolSchedule.fromConfig(genesisConfigOptions), mock(ProtocolContext.class), mock(FilterManager.class), mock(TransactionPool.class), mock(PoWMiningCoordinator.class), new NoOpMetricsSystem(), supportedCapabilities, Optional.empty(), Optional.empty(), JSON_RPC_APIS, mock(PrivacyParameters.class), mock(JsonRpcConfiguration.class), mock(WebSocketConfiguration.class), mock(MetricsConfiguration.class), natService, new HashMap<>(), folder.getRoot().toPath(), mock(EthPeers.class)));
    service = createJsonRpcHttpService();
    jwtAuth = service.authenticationService.get().getJwtAuthProvider();
    service.start().join();
    // Build an OkHttp client.
    client = new OkHttpClient();
    baseUrl = service.url();
}
Also used : Synchronizer(org.hyperledger.besu.ethereum.core.Synchronizer) TransactionPool(org.hyperledger.besu.ethereum.eth.transactions.TransactionPool) OkHttpClient(okhttp3.OkHttpClient) Capability(org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability) WebSocketConfiguration(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration) P2PNetwork(org.hyperledger.besu.ethereum.p2p.network.P2PNetwork) EthPeers(org.hyperledger.besu.ethereum.eth.manager.EthPeers) PrivacyParameters(org.hyperledger.besu.ethereum.core.PrivacyParameters) JsonRpcMethodsFactory(org.hyperledger.besu.ethereum.api.jsonrpc.methods.JsonRpcMethodsFactory) FilterManager(org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager) MetricsConfiguration(org.hyperledger.besu.metrics.prometheus.MetricsConfiguration) BlockchainQueries(org.hyperledger.besu.ethereum.api.query.BlockchainQueries) NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) ProtocolContext(org.hyperledger.besu.ethereum.ProtocolContext) StubGenesisConfigOptions(org.hyperledger.besu.config.StubGenesisConfigOptions) PoWMiningCoordinator(org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator) HashSet(java.util.HashSet) BeforeClass(org.junit.BeforeClass)

Example 5 with NoOpMetricsSystem

use of org.hyperledger.besu.metrics.noop.NoOpMetricsSystem in project besu by hyperledger.

the class JsonRpcHttpServiceRpcApisTest method createJsonRpcHttpServiceWithRpcApis.

private JsonRpcHttpService createJsonRpcHttpServiceWithRpcApis(final JsonRpcConfiguration config) throws Exception {
    final Set<Capability> supportedCapabilities = new HashSet<>();
    supportedCapabilities.add(EthProtocol.ETH62);
    supportedCapabilities.add(EthProtocol.ETH63);
    final Map<String, JsonRpcMethod> rpcMethods = spy(new JsonRpcMethodsFactory().methods(CLIENT_VERSION, NETWORK_ID, new StubGenesisConfigOptions(), mock(P2PNetwork.class), blockchainQueries, mock(Synchronizer.class), ProtocolScheduleFixture.MAINNET, mock(ProtocolContext.class), mock(FilterManager.class), mock(TransactionPool.class), mock(PoWMiningCoordinator.class), new NoOpMetricsSystem(), supportedCapabilities, Optional.of(mock(AccountLocalConfigPermissioningController.class)), Optional.of(mock(NodeLocalConfigPermissioningController.class)), config.getRpcApis(), mock(PrivacyParameters.class), mock(JsonRpcConfiguration.class), mock(WebSocketConfiguration.class), mock(MetricsConfiguration.class), natService, new HashMap<>(), folder.getRoot().toPath(), mock(EthPeers.class)));
    final JsonRpcHttpService jsonRpcHttpService = new JsonRpcHttpService(vertx, folder.newFolder().toPath(), config, new NoOpMetricsSystem(), natService, rpcMethods, HealthService.ALWAYS_HEALTHY, HealthService.ALWAYS_HEALTHY);
    jsonRpcHttpService.start().join();
    baseUrl = jsonRpcHttpService.url();
    return jsonRpcHttpService;
}
Also used : NodeLocalConfigPermissioningController(org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController) Capability(org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability) HashMap(java.util.HashMap) AccountLocalConfigPermissioningController(org.hyperledger.besu.ethereum.permissioning.AccountLocalConfigPermissioningController) JsonRpcMethodsFactory(org.hyperledger.besu.ethereum.api.jsonrpc.methods.JsonRpcMethodsFactory) JsonRpcMethod(org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod) NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) StubGenesisConfigOptions(org.hyperledger.besu.config.StubGenesisConfigOptions) HashSet(java.util.HashSet)

Aggregations

NoOpMetricsSystem (org.hyperledger.besu.metrics.noop.NoOpMetricsSystem)82 Before (org.junit.Before)24 Test (org.junit.Test)23 EthScheduler (org.hyperledger.besu.ethereum.eth.manager.EthScheduler)17 ProtocolContext (org.hyperledger.besu.ethereum.ProtocolContext)16 Path (java.nio.file.Path)13 StubGenesisConfigOptions (org.hyperledger.besu.config.StubGenesisConfigOptions)13 HashSet (java.util.HashSet)12 EthPeers (org.hyperledger.besu.ethereum.eth.manager.EthPeers)12 TransactionPool (org.hyperledger.besu.ethereum.eth.transactions.TransactionPool)12 JsonRpcMethodsFactory (org.hyperledger.besu.ethereum.api.jsonrpc.methods.JsonRpcMethodsFactory)11 SyncState (org.hyperledger.besu.ethereum.eth.sync.state.SyncState)11 Capability (org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability)11 PrivacyParameters (org.hyperledger.besu.ethereum.core.PrivacyParameters)10 P2PNetwork (org.hyperledger.besu.ethereum.p2p.network.P2PNetwork)10 MetricsConfiguration (org.hyperledger.besu.metrics.prometheus.MetricsConfiguration)10 FilterManager (org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager)9 WebSocketConfiguration (org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration)9 BlockchainQueries (org.hyperledger.besu.ethereum.api.query.BlockchainQueries)9 PoWMiningCoordinator (org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator)9