Search in sources :

Example 1 with ValidatorLoader

use of tech.pegasys.teku.validator.client.loader.ValidatorLoader in project teku by ConsenSys.

the class VoluntaryExitCommand method initialise.

private void initialise() {
    config = tekuConfiguration();
    final AsyncRunnerFactory asyncRunnerFactory = AsyncRunnerFactory.createDefault(new MetricTrackingExecutorFactory(metricsSystem));
    final AsyncRunner asyncRunner = asyncRunnerFactory.create("voluntary-exits", 8);
    apiClient = config.validatorClient().getValidatorConfig().getBeaconNodeApiEndpoint().map(RemoteSpecLoader::createApiClient).orElseThrow();
    spec = getSpec(apiClient);
    validateOrDefaultEpoch();
    fork = spec.getForkSchedule().getFork(epoch);
    // get genesis time
    final Optional<Bytes32> maybeRoot = getGenesisRoot();
    if (maybeRoot.isEmpty()) {
        SUB_COMMAND_LOG.error("Unable to fetch genesis data, cannot generate an exit.");
        System.exit(1);
    }
    genesisRoot = maybeRoot.get();
    final RejectingSlashingProtector slashingProtector = new RejectingSlashingProtector();
    final SlashingProtectionLogger slashingProtectionLogger = new SlashingProtectionLogger(slashingProtector, spec, asyncRunner, ValidatorLogger.VALIDATOR_LOGGER);
    final ValidatorLoader validatorLoader = ValidatorLoader.create(spec, config.validatorClient().getValidatorConfig(), config.validatorClient().getInteropConfig(), new RejectingSlashingProtector(), slashingProtectionLogger, new PublicKeyLoader(), asyncRunner, metricsSystem, Optional.empty());
    try {
        validatorLoader.loadValidators();
        validators = validatorLoader.getOwnedValidators();
    } catch (InvalidConfigurationException ex) {
        SUB_COMMAND_LOG.error(ex.getMessage());
        System.exit(1);
    }
    if (validators.hasNoValidators()) {
        SUB_COMMAND_LOG.error("No validators were found to exit.");
        System.exit(1);
    }
}
Also used : AsyncRunnerFactory(tech.pegasys.teku.infrastructure.async.AsyncRunnerFactory) ValidatorLoader(tech.pegasys.teku.validator.client.loader.ValidatorLoader) PublicKeyLoader(tech.pegasys.teku.validator.client.loader.PublicKeyLoader) MetricTrackingExecutorFactory(tech.pegasys.teku.infrastructure.async.MetricTrackingExecutorFactory) SlashingProtectionLogger(tech.pegasys.teku.validator.client.loader.SlashingProtectionLogger) Bytes32(org.apache.tuweni.bytes.Bytes32) RejectingSlashingProtector(tech.pegasys.teku.core.signatures.RejectingSlashingProtector) AsyncRunner(tech.pegasys.teku.infrastructure.async.AsyncRunner) InvalidConfigurationException(tech.pegasys.teku.infrastructure.exceptions.InvalidConfigurationException)

Example 2 with ValidatorLoader

use of tech.pegasys.teku.validator.client.loader.ValidatorLoader 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;
}
Also used : BlockDutyFactory(tech.pegasys.teku.validator.client.duties.BlockDutyFactory) ValidatorLoader(tech.pegasys.teku.validator.client.loader.ValidatorLoader) DataDirLayout(tech.pegasys.teku.service.serviceutils.layout.DataDirLayout) SafeFuture(tech.pegasys.teku.infrastructure.async.SafeFuture) ValidatorRestApiConfig(tech.pegasys.teku.validator.client.restapi.ValidatorRestApiConfig) Random(java.util.Random) LocalSlashingProtector(tech.pegasys.teku.core.signatures.LocalSlashingProtector) ArrayList(java.util.ArrayList) EventChannels(tech.pegasys.teku.infrastructure.events.EventChannels) ValidatorRestApi(tech.pegasys.teku.validator.client.restapi.ValidatorRestApi) PublicKeyLoader(tech.pegasys.teku.validator.client.loader.PublicKeyLoader) SlotBasedScheduledDuties(tech.pegasys.teku.validator.client.duties.SlotBasedScheduledDuties) JsonProvider(tech.pegasys.teku.provider.JsonProvider) ChainHeadTracker(tech.pegasys.teku.validator.client.duties.synccommittee.ChainHeadTracker) BeaconCommitteeSubscriptions(tech.pegasys.teku.validator.client.duties.BeaconCommitteeSubscriptions) Spec(tech.pegasys.teku.spec.Spec) Path(java.nio.file.Path) Service(tech.pegasys.teku.service.serviceutils.Service) ProposerConfigProvider(tech.pegasys.teku.validator.client.proposerconfig.ProposerConfigProvider) AsyncRunner(tech.pegasys.teku.infrastructure.async.AsyncRunner) ValidatorLogger(tech.pegasys.teku.infrastructure.logging.ValidatorLogger) SyncDataAccessor(tech.pegasys.teku.infrastructure.io.SyncDataAccessor) RestApi(tech.pegasys.teku.infrastructure.restapi.RestApi) ServiceConfig(tech.pegasys.teku.service.serviceutils.ServiceConfig) BeaconNodeApi(tech.pegasys.teku.validator.beaconnode.BeaconNodeApi) SyncCommitteeScheduledDuties(tech.pegasys.teku.validator.client.duties.synccommittee.SyncCommitteeScheduledDuties) List(java.util.List) Logger(org.apache.logging.log4j.Logger) TekuMetricCategory(tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory) ValidatorApiChannel(tech.pegasys.teku.validator.api.ValidatorApiChannel) InProcessBeaconNodeApi(tech.pegasys.teku.validator.eventadapter.InProcessBeaconNodeApi) OwnedValidators(tech.pegasys.teku.validator.client.loader.OwnedValidators) SlashingProtector(tech.pegasys.teku.core.signatures.SlashingProtector) SystemSignalListener(tech.pegasys.teku.infrastructure.io.SystemSignalListener) GenesisDataProvider(tech.pegasys.teku.validator.beaconnode.GenesisDataProvider) ProposerConfigLoader(tech.pegasys.teku.validator.client.proposerconfig.loader.ProposerConfigLoader) SlashingProtectionLogger(tech.pegasys.teku.validator.client.loader.SlashingProtectionLogger) Optional(java.util.Optional) RemoteBeaconNodeApi(tech.pegasys.teku.validator.remote.RemoteBeaconNodeApi) MetricsSystem(org.hyperledger.besu.plugin.services.MetricsSystem) LogManager(org.apache.logging.log4j.LogManager) SpecMilestone(tech.pegasys.teku.spec.SpecMilestone) ValidatorTimingChannel(tech.pegasys.teku.validator.api.ValidatorTimingChannel) AttestationDutyFactory(tech.pegasys.teku.validator.client.duties.attestations.AttestationDutyFactory) ValidatorRestApi(tech.pegasys.teku.validator.client.restapi.ValidatorRestApi) RestApi(tech.pegasys.teku.infrastructure.restapi.RestApi) ValidatorApiChannel(tech.pegasys.teku.validator.api.ValidatorApiChannel) GenesisDataProvider(tech.pegasys.teku.validator.beaconnode.GenesisDataProvider) BeaconNodeApi(tech.pegasys.teku.validator.beaconnode.BeaconNodeApi) InProcessBeaconNodeApi(tech.pegasys.teku.validator.eventadapter.InProcessBeaconNodeApi) RemoteBeaconNodeApi(tech.pegasys.teku.validator.remote.RemoteBeaconNodeApi) AsyncRunner(tech.pegasys.teku.infrastructure.async.AsyncRunner) ValidatorLoader(tech.pegasys.teku.validator.client.loader.ValidatorLoader) EventChannels(tech.pegasys.teku.infrastructure.events.EventChannels) ValidatorRestApiConfig(tech.pegasys.teku.validator.client.restapi.ValidatorRestApiConfig)

Aggregations

AsyncRunner (tech.pegasys.teku.infrastructure.async.AsyncRunner)2 PublicKeyLoader (tech.pegasys.teku.validator.client.loader.PublicKeyLoader)2 SlashingProtectionLogger (tech.pegasys.teku.validator.client.loader.SlashingProtectionLogger)2 ValidatorLoader (tech.pegasys.teku.validator.client.loader.ValidatorLoader)2 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Optional (java.util.Optional)1 Random (java.util.Random)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 Bytes32 (org.apache.tuweni.bytes.Bytes32)1 MetricsSystem (org.hyperledger.besu.plugin.services.MetricsSystem)1 LocalSlashingProtector (tech.pegasys.teku.core.signatures.LocalSlashingProtector)1 RejectingSlashingProtector (tech.pegasys.teku.core.signatures.RejectingSlashingProtector)1 SlashingProtector (tech.pegasys.teku.core.signatures.SlashingProtector)1 AsyncRunnerFactory (tech.pegasys.teku.infrastructure.async.AsyncRunnerFactory)1 MetricTrackingExecutorFactory (tech.pegasys.teku.infrastructure.async.MetricTrackingExecutorFactory)1 SafeFuture (tech.pegasys.teku.infrastructure.async.SafeFuture)1 EventChannels (tech.pegasys.teku.infrastructure.events.EventChannels)1