use of tech.pegasys.teku.networking.eth2.P2PConfig in project teku by ConsenSys.
the class Eth2P2PNetworkBuilder method buildNetwork.
protected DiscoveryNetwork<?> buildNetwork(final GossipEncoding gossipEncoding, final SubnetSubscriptionService syncCommitteeSubnetService) {
final ReputationManager reputationManager = new ReputationManager(metricsSystem, timeProvider, Constants.REPUTATION_MANAGER_CAPACITY);
PreparedGossipMessageFactory defaultMessageFactory = gossipEncoding.createPreparedGossipMessageFactory(recentChainData::getMilestoneByForkDigest);
final GossipTopicFilter gossipTopicsFilter = new Eth2GossipTopicFilter(recentChainData, gossipEncoding, spec);
final NetworkConfig networkConfig = config.getNetworkConfig();
final DiscoveryConfig discoConfig = config.getDiscoveryConfig();
final P2PNetwork<Peer> p2pNetwork = createLibP2PNetworkBuilder().asyncRunner(asyncRunner).metricsSystem(metricsSystem).config(networkConfig).privateKeyProvider(new LibP2PPrivateKeyLoader(keyValueStore, networkConfig.getPrivateKeySource())).reputationManager(reputationManager).rpcMethods(rpcMethods).peerHandlers(peerHandlers).preparedGossipMessageFactory(defaultMessageFactory).gossipTopicFilter(gossipTopicsFilter).build();
final AttestationSubnetTopicProvider attestationSubnetTopicProvider = new AttestationSubnetTopicProvider(recentChainData, gossipEncoding);
final SyncCommitteeSubnetTopicProvider syncCommitteeSubnetTopicProvider = new SyncCommitteeSubnetTopicProvider(recentChainData, gossipEncoding);
final TargetPeerRange targetPeerRange = new TargetPeerRange(discoConfig.getMinPeers(), discoConfig.getMaxPeers(), discoConfig.getMinRandomlySelectedPeers());
final SchemaDefinitionsSupplier currentSchemaDefinitions = () -> recentChainData.getCurrentSpec().getSchemaDefinitions();
return createDiscoveryNetworkBuilder().metricsSystem(metricsSystem).asyncRunner(asyncRunner).kvStore(keyValueStore).p2pNetwork(p2pNetwork).peerSelectionStrategy(new Eth2PeerSelectionStrategy(targetPeerRange, network -> PeerSubnetSubscriptions.create(currentSchemaDefinitions, network, attestationSubnetTopicProvider, syncCommitteeSubnetTopicProvider, syncCommitteeSubnetService, config.getTargetSubnetSubscriberCount()), reputationManager, Collections::shuffle)).discoveryConfig(discoConfig).p2pConfig(networkConfig).spec(config.getSpec()).currentSchemaDefinitionsSupplier(currentSchemaDefinitions).build();
}
use of tech.pegasys.teku.networking.eth2.P2PConfig in project teku by ConsenSys.
the class P2POptionsTest method shouldReadFromConfigurationFile.
@Test
public void shouldReadFromConfigurationFile() {
final TekuConfiguration tekuConfig = getTekuConfigurationFromFile("P2POptions_config.yaml");
final P2PConfig p2pConfig = tekuConfig.p2p();
assertThat(p2pConfig.getTargetSubnetSubscriberCount()).isEqualTo(5);
final DiscoveryConfig discoConfig = tekuConfig.discovery();
assertThat(discoConfig.isDiscoveryEnabled()).isTrue();
assertThat(discoConfig.getMinPeers()).isEqualTo(70);
assertThat(discoConfig.getMaxPeers()).isEqualTo(85);
assertThat(discoConfig.getMinRandomlySelectedPeers()).isEqualTo(1);
assertThat(discoConfig.getStaticPeers()).isEqualTo(List.of("127.1.0.1", "127.1.1.1"));
final NetworkConfig networkConfig = tekuConfig.network();
assertThat(networkConfig.isEnabled()).isTrue();
assertThat(networkConfig.getAdvertisedIp()).isEqualTo("127.200.0.1");
assertThat(networkConfig.getNetworkInterface()).isEqualTo("127.100.0.1");
assertThat(networkConfig.getListenPort()).isEqualTo(4321);
assertThat(networkConfig.getPrivateKeySource()).containsInstanceOf(FilePrivateKeySource.class);
assertThat(((FilePrivateKeySource) networkConfig.getPrivateKeySource().get()).getFileName()).isEqualTo("/the/file");
}
use of tech.pegasys.teku.networking.eth2.P2PConfig in project teku by ConsenSys.
the class BeaconChainController method initSignatureVerificationService.
protected void initSignatureVerificationService() {
final P2PConfig p2PConfig = beaconConfig.p2pConfig();
signatureVerificationService = p2PConfig.batchVerifyAttestationSignatures() ? new AggregatingSignatureVerificationService(metricsSystem, asyncRunnerFactory, beaconAsyncRunner, p2PConfig.getBatchVerifyMaxThreads(), p2PConfig.getBatchVerifyQueueCapacity(), p2PConfig.getBatchVerifyMaxBatchSize(), p2PConfig.isBatchVerifyStrictThreadLimitEnabled()) : SignatureVerificationService.createSimple();
}
use of tech.pegasys.teku.networking.eth2.P2PConfig in project teku by ConsenSys.
the class Eth2P2PNetworkOptionsTest method setPeerRateLimit.
@Test
public void setPeerRateLimit() {
TekuConfiguration tekuConfiguration = getTekuConfigurationFromArguments("--Xpeer-rate-limit", "10");
final P2PConfig config = tekuConfiguration.beaconChain().p2pConfig();
assertThat(config.getPeerRateLimit()).isEqualTo(10);
assertThat(createConfigBuilder().p2p(b -> b.peerRateLimit(10)).build()).usingRecursiveComparison().isEqualTo(tekuConfiguration);
}
use of tech.pegasys.teku.networking.eth2.P2PConfig in project teku by ConsenSys.
the class Eth2P2PNetworkOptionsTest method setPeerRequestLimit.
@Test
public void setPeerRequestLimit() {
TekuConfiguration tekuConfiguration = getTekuConfigurationFromArguments("--Xpeer-request-limit", "10");
final P2PConfig config = tekuConfiguration.beaconChain().p2pConfig();
assertThat(config.getPeerRequestLimit()).isEqualTo(10);
assertThat(createConfigBuilder().p2p(b -> b.peerRequestLimit(10)).build()).usingRecursiveComparison().isEqualTo(tekuConfiguration);
}
Aggregations