use of tech.pegasys.teku.validator.beaconnode.GenesisDataProvider in project teku by ConsenSys.
the class RemoteBeaconNodeApi method create.
public static BeaconNodeApi create(final ServiceConfig serviceConfig, final AsyncRunner asyncRunner, final URI beaconNodeApiEndpoint, final Spec spec, final boolean generateEarlyAttestations) {
final OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder().readTimeout(READ_TIMEOUT);
HttpUrl apiEndpoint = HttpUrl.get(beaconNodeApiEndpoint);
Preconditions.checkNotNull(apiEndpoint, String.format("Failed to convert remote api endpoint (%s) to a valid url", UrlSanitizer.sanitizePotentialUrl(beaconNodeApiEndpoint.toString())));
OkHttpClientAuthLoggingIntercepter.addAuthenticator(apiEndpoint, httpClientBuilder);
// Strip any authentication info from the URL to ensure it doesn't get logged.
apiEndpoint = apiEndpoint.newBuilder().username("").password("").build();
final OkHttpClient okHttpClient = httpClientBuilder.build();
final OkHttpValidatorRestApiClient apiClient = new OkHttpValidatorRestApiClient(apiEndpoint, okHttpClient);
final ValidatorApiChannel validatorApiChannel = new MetricRecordingValidatorApiChannel(serviceConfig.getMetricsSystem(), new RemoteValidatorApiHandler(spec, apiClient, asyncRunner));
final ValidatorTimingChannel validatorTimingChannel = serviceConfig.getEventChannels().getPublisher(ValidatorTimingChannel.class);
final BeaconChainEventAdapter beaconChainEventAdapter = new EventSourceBeaconChainEventAdapter(apiEndpoint, okHttpClient, new TimeBasedEventAdapter(new GenesisDataProvider(asyncRunner, validatorApiChannel), new RepeatingTaskScheduler(asyncRunner, serviceConfig.getTimeProvider()), serviceConfig.getTimeProvider(), validatorTimingChannel, spec), validatorTimingChannel, serviceConfig.getMetricsSystem(), generateEarlyAttestations);
return new RemoteBeaconNodeApi(beaconChainEventAdapter, validatorApiChannel);
}
use of tech.pegasys.teku.validator.beaconnode.GenesisDataProvider in project teku by ConsenSys.
the class InProcessBeaconNodeApi method create.
public static BeaconNodeApi create(final ServiceConfig services, final AsyncRunner asyncRunner, final boolean generateEarlyAttestations, final Spec spec) {
final MetricsSystem metricsSystem = services.getMetricsSystem();
final EventChannels eventChannels = services.getEventChannels();
final ValidatorApiChannel validatorApiChannel = new MetricRecordingValidatorApiChannel(metricsSystem, eventChannels.getPublisher(ValidatorApiChannel.class, asyncRunner));
final ValidatorTimingChannel validatorTimingChannel = eventChannels.getPublisher(ValidatorTimingChannel.class);
final TimeBasedEventAdapter timeBasedEventAdapter = new TimeBasedEventAdapter(new GenesisDataProvider(asyncRunner, validatorApiChannel), new RepeatingTaskScheduler(asyncRunner, services.getTimeProvider()), services.getTimeProvider(), validatorTimingChannel, spec);
final BeaconChainEventAdapter beaconChainEventAdapter = new IndependentTimerEventChannelEventAdapter(eventChannels, generateEarlyAttestations, timeBasedEventAdapter, validatorTimingChannel);
return new InProcessBeaconNodeApi(validatorApiChannel, beaconChainEventAdapter);
}
use of tech.pegasys.teku.validator.beaconnode.GenesisDataProvider in project teku by ConsenSys.
the class ValidatorClientService method create.
public static ValidatorClientService create(final ServiceConfig services, final ValidatorClientConfiguration config) {
final EventChannels eventChannels = services.getEventChannels();
final AsyncRunner asyncRunner = services.createAsyncRunner("validator");
final boolean generateEarlyAttestations = config.getValidatorConfig().generateEarlyAttestations();
final BeaconNodeApi beaconNodeApi = config.getValidatorConfig().getBeaconNodeApiEndpoint().map(endpoint -> RemoteBeaconNodeApi.create(services, asyncRunner, endpoint, config.getSpec(), generateEarlyAttestations)).orElseGet(() -> InProcessBeaconNodeApi.create(services, asyncRunner, generateEarlyAttestations, config.getSpec()));
final ValidatorApiChannel validatorApiChannel = beaconNodeApi.getValidatorApi();
final GenesisDataProvider genesisDataProvider = new GenesisDataProvider(asyncRunner, validatorApiChannel);
final ForkProvider forkProvider = new ForkProvider(config.getSpec(), genesisDataProvider);
final ValidatorLoader validatorLoader = createValidatorLoader(config, asyncRunner, services);
final ValidatorRestApiConfig validatorApiConfig = config.getValidatorRestApiConfig();
Optional<RestApi> validatorRestApi = Optional.empty();
if (validatorApiConfig.isRestApiEnabled()) {
validatorRestApi = Optional.of(ValidatorRestApi.create(validatorApiConfig, new ActiveKeyManager(validatorLoader, services.getEventChannels().getPublisher(ValidatorTimingChannel.class)), services.getDataDirLayout()));
} else {
LOG.info("validator-api-enabled is false, not starting rest api.");
}
ValidatorClientService validatorClientService = new ValidatorClientService(eventChannels, validatorLoader, beaconNodeApi, validatorRestApi, forkProvider, config.getSpec(), services.getMetricsSystem());
asyncRunner.runAsync(() -> validatorClientService.initializeValidators(config, validatorApiChannel, asyncRunner)).propagateTo(validatorClientService.initializationComplete);
return validatorClientService;
}
Aggregations