Search in sources :

Example 1 with BlockGossipChannel

use of tech.pegasys.teku.networking.eth2.gossip.BlockGossipChannel in project teku by ConsenSys.

the class BeaconChainController method initValidatorApiHandler.

public void initValidatorApiHandler() {
    LOG.debug("BeaconChainController.initValidatorApiHandler()");
    final BlockFactory blockFactory = new BlockFactory(spec, new BlockOperationSelectorFactory(spec, attestationPool, attesterSlashingPool, proposerSlashingPool, voluntaryExitPool, syncCommitteeContributionPool, depositProvider, eth1DataCache, VersionProvider.getDefaultGraffiti(), forkChoiceNotifier, executionEngine));
    SyncCommitteeSubscriptionManager syncCommitteeSubscriptionManager = beaconConfig.p2pConfig().isSubscribeAllSubnetsEnabled() ? new AllSyncCommitteeSubscriptions(p2pNetwork, spec) : new SyncCommitteeSubscriptionManager(p2pNetwork);
    final BlockImportChannel blockImportChannel = eventChannels.getPublisher(BlockImportChannel.class, beaconAsyncRunner);
    final BlockGossipChannel blockGossipChannel = eventChannels.getPublisher(BlockGossipChannel.class);
    final ValidatorApiHandler validatorApiHandler = new ValidatorApiHandler(new ChainDataProvider(spec, recentChainData, combinedChainDataClient), combinedChainDataClient, syncService, blockFactory, blockImportChannel, blockGossipChannel, attestationPool, attestationManager, attestationTopicSubscriber, activeValidatorTracker, DutyMetrics.create(metricsSystem, timeProvider, recentChainData, spec), performanceTracker, spec, forkChoiceTrigger, forkChoiceNotifier, syncCommitteeMessagePool, syncCommitteeContributionPool, syncCommitteeSubscriptionManager);
    eventChannels.subscribe(SlotEventsChannel.class, activeValidatorTracker).subscribeMultithreaded(ValidatorApiChannel.class, validatorApiHandler, beaconConfig.beaconRestApiConfig().getValidatorThreads());
    // so don't subscribe.
    if (!beaconConfig.p2pConfig().isSubscribeAllSubnetsEnabled()) {
        eventChannels.subscribe(SlotEventsChannel.class, attestationTopicSubscriber).subscribe(SlotEventsChannel.class, syncCommitteeSubscriptionManager);
    }
}
Also used : ValidatorApiHandler(tech.pegasys.teku.validator.coordinator.ValidatorApiHandler) AllSyncCommitteeSubscriptions(tech.pegasys.teku.networking.eth2.gossip.subnets.AllSyncCommitteeSubscriptions) BlockGossipChannel(tech.pegasys.teku.networking.eth2.gossip.BlockGossipChannel) SlotEventsChannel(tech.pegasys.teku.ethereum.events.SlotEventsChannel) BlockFactory(tech.pegasys.teku.validator.coordinator.BlockFactory) BlockOperationSelectorFactory(tech.pegasys.teku.validator.coordinator.BlockOperationSelectorFactory) ChainDataProvider(tech.pegasys.teku.api.ChainDataProvider) SyncCommitteeSubscriptionManager(tech.pegasys.teku.networking.eth2.gossip.subnets.SyncCommitteeSubscriptionManager) BlockImportChannel(tech.pegasys.teku.statetransition.block.BlockImportChannel)

Example 2 with BlockGossipChannel

use of tech.pegasys.teku.networking.eth2.gossip.BlockGossipChannel in project teku by ConsenSys.

the class NodeManager method create.

public static NodeManager create(final Spec spec, Eth2P2PNetworkFactory networkFactory, final List<BLSKeyPair> validatorKeys, Consumer<Eth2P2PNetworkBuilder> configureNetwork) throws Exception {
    final EventChannels eventChannels = EventChannels.createSyncChannels(ChannelExceptionHandler.THROWING_HANDLER, new NoOpMetricsSystem());
    final RecentChainData storageClient = MemoryOnlyRecentChainData.create(spec);
    final BeaconChainUtil chainUtil = BeaconChainUtil.create(spec, storageClient, validatorKeys);
    chainUtil.initializeStorage();
    final Eth2P2PNetworkBuilder networkBuilder = networkFactory.builder().spec(spec).eventChannels(eventChannels).recentChainData(storageClient);
    configureNetwork.accept(networkBuilder);
    final BlockGossipChannel blockGossipChannel = eventChannels.getPublisher(BlockGossipChannel.class);
    final Eth2P2PNetwork eth2P2PNetwork = networkBuilder.startNetwork();
    return new NodeManager(blockGossipChannel, storageClient, chainUtil, eth2P2PNetwork);
}
Also used : RecentChainData(tech.pegasys.teku.storage.client.RecentChainData) MemoryOnlyRecentChainData(tech.pegasys.teku.storage.client.MemoryOnlyRecentChainData) BlockGossipChannel(tech.pegasys.teku.networking.eth2.gossip.BlockGossipChannel) Eth2P2PNetworkBuilder(tech.pegasys.teku.networking.eth2.Eth2P2PNetworkFactory.Eth2P2PNetworkBuilder) EventChannels(tech.pegasys.teku.infrastructure.events.EventChannels) NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) BeaconChainUtil(tech.pegasys.teku.statetransition.BeaconChainUtil)

Aggregations

BlockGossipChannel (tech.pegasys.teku.networking.eth2.gossip.BlockGossipChannel)2 NoOpMetricsSystem (org.hyperledger.besu.metrics.noop.NoOpMetricsSystem)1 ChainDataProvider (tech.pegasys.teku.api.ChainDataProvider)1 SlotEventsChannel (tech.pegasys.teku.ethereum.events.SlotEventsChannel)1 EventChannels (tech.pegasys.teku.infrastructure.events.EventChannels)1 Eth2P2PNetworkBuilder (tech.pegasys.teku.networking.eth2.Eth2P2PNetworkFactory.Eth2P2PNetworkBuilder)1 AllSyncCommitteeSubscriptions (tech.pegasys.teku.networking.eth2.gossip.subnets.AllSyncCommitteeSubscriptions)1 SyncCommitteeSubscriptionManager (tech.pegasys.teku.networking.eth2.gossip.subnets.SyncCommitteeSubscriptionManager)1 BeaconChainUtil (tech.pegasys.teku.statetransition.BeaconChainUtil)1 BlockImportChannel (tech.pegasys.teku.statetransition.block.BlockImportChannel)1 MemoryOnlyRecentChainData (tech.pegasys.teku.storage.client.MemoryOnlyRecentChainData)1 RecentChainData (tech.pegasys.teku.storage.client.RecentChainData)1 BlockFactory (tech.pegasys.teku.validator.coordinator.BlockFactory)1 BlockOperationSelectorFactory (tech.pegasys.teku.validator.coordinator.BlockOperationSelectorFactory)1 ValidatorApiHandler (tech.pegasys.teku.validator.coordinator.ValidatorApiHandler)1