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);
}
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();
}
}
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();
}
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();
}
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;
}
Aggregations