Search in sources :

Example 1 with AttestationSubnetSubscriptions

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

the class GossipForkSubscriptionsPhase0 method addGossipManagers.

protected void addGossipManagers(final ForkInfo forkInfo) {
    AttestationSubnetSubscriptions attestationSubnetSubscriptions = new AttestationSubnetSubscriptions(spec, asyncRunner, discoveryNetwork, gossipEncoding, recentChainData, attestationProcessor, forkInfo, getMessageMaxSize());
    blockGossipManager = new BlockGossipManager(recentChainData, spec, asyncRunner, discoveryNetwork, gossipEncoding, forkInfo, blockProcessor, getMessageMaxSize());
    addGossipManager(blockGossipManager);
    attestationGossipManager = new AttestationGossipManager(metricsSystem, attestationSubnetSubscriptions);
    addGossipManager(attestationGossipManager);
    aggregateGossipManager = new AggregateGossipManager(spec, recentChainData, asyncRunner, discoveryNetwork, gossipEncoding, forkInfo, aggregateProcessor, getMessageMaxSize());
    addGossipManager(aggregateGossipManager);
    voluntaryExitGossipManager = new VoluntaryExitGossipManager(recentChainData, asyncRunner, discoveryNetwork, gossipEncoding, forkInfo, voluntaryExitProcessor, getMessageMaxSize());
    addGossipManager(voluntaryExitGossipManager);
    proposerSlashingGossipManager = new ProposerSlashingGossipManager(recentChainData, asyncRunner, discoveryNetwork, gossipEncoding, forkInfo, proposerSlashingProcessor, getMessageMaxSize());
    addGossipManager(proposerSlashingGossipManager);
    attesterSlashingGossipManager = new AttesterSlashingGossipManager(spec, recentChainData, asyncRunner, discoveryNetwork, gossipEncoding, forkInfo, attesterSlashingProcessor, getMessageMaxSize());
    addGossipManager(attesterSlashingGossipManager);
}
Also used : BlockGossipManager(tech.pegasys.teku.networking.eth2.gossip.BlockGossipManager) AttestationSubnetSubscriptions(tech.pegasys.teku.networking.eth2.gossip.subnets.AttestationSubnetSubscriptions) VoluntaryExitGossipManager(tech.pegasys.teku.networking.eth2.gossip.VoluntaryExitGossipManager) AttestationGossipManager(tech.pegasys.teku.networking.eth2.gossip.AttestationGossipManager) AttesterSlashingGossipManager(tech.pegasys.teku.networking.eth2.gossip.AttesterSlashingGossipManager) AggregateGossipManager(tech.pegasys.teku.networking.eth2.gossip.AggregateGossipManager) ProposerSlashingGossipManager(tech.pegasys.teku.networking.eth2.gossip.ProposerSlashingGossipManager)

Example 2 with AttestationSubnetSubscriptions

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

the class SubnetScorerTest method shouldScoreCandidatePeersOnSubnetsWithFewPeersMoreHighly.

@Test
void shouldScoreCandidatePeersOnSubnetsWithFewPeersMoreHighly() {
    final MockNodeId node1 = new MockNodeId(0);
    final MockNodeId node2 = new MockNodeId(1);
    final MockNodeId node3 = new MockNodeId(2);
    final SubnetScorer scorer = SubnetScorer.create(PeerSubnetSubscriptions.builder(() -> schemaDefinitions).attestationSubnetSubscriptions(b -> b.addRelevantSubnet(1).addRelevantSubnet(2).addRelevantSubnet(3).addRelevantSubnet(5).addSubscriber(1, node2).addSubscriber(3, node3)).syncCommitteeSubnetSubscriptions(b -> b.addRelevantSubnet(1).addRelevantSubnet(2).addSubscriber(1, node1).addSubscriber(1, node2).addSubscriber(1, node3)).build());
    assertCandidatePeerScores(scorer, entry(candidateWithSubnets(List.of(1, 3), List.of(1)), 562), entry(candidateWithSubnets(List.of(1), List.of(1)), 312), entry(candidateWithSubnets(List.of(2), List.of(1)), 1062), entry(candidateWithSubnets(List.of(3), List.of(1)), 312), entry(candidateWithSubnets(emptyList(), emptyList()), 0), entry(candidateWithSubnets(List.of(5), emptyList()), 1000), entry(candidateWithSubnets(List.of(4), emptyList()), 0), entry(candidateWithSubnets(emptyList(), List.of(2)), 1000), entry(candidateWithSubnets(emptyList(), List.of(3)), 0));
}
Also used : MockNodeId(tech.pegasys.teku.networking.p2p.mock.MockNodeId) PeerScorer(tech.pegasys.teku.networking.eth2.peers.PeerScorer) Collections.emptyList(java.util.Collections.emptyList) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SchemaDefinitions(tech.pegasys.teku.spec.schemas.SchemaDefinitions) MockNodeId(tech.pegasys.teku.networking.p2p.mock.MockNodeId) Assertions.entry(org.assertj.core.api.Assertions.entry) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) List(java.util.List) SszBitvector(tech.pegasys.teku.infrastructure.ssz.collections.SszBitvector) Stream(java.util.stream.Stream) TestSpecFactory(tech.pegasys.teku.spec.TestSpecFactory) Pair(org.apache.commons.lang3.tuple.Pair) Map(java.util.Map) Spec(tech.pegasys.teku.spec.Spec) NodeId(tech.pegasys.teku.networking.p2p.peer.NodeId) Test(org.junit.jupiter.api.Test)

Example 3 with AttestationSubnetSubscriptions

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

the class SubnetScorerTest method shouldScoreExistingPeersOnSubnetsWithFewPeersMoreHighly.

@Test
void shouldScoreExistingPeersOnSubnetsWithFewPeersMoreHighly() {
    final MockNodeId node1 = new MockNodeId(0);
    final MockNodeId node2 = new MockNodeId(1);
    final MockNodeId node3 = new MockNodeId(2);
    final MockNodeId node4 = new MockNodeId(3);
    final MockNodeId node5 = new MockNodeId(4);
    final SubnetScorer scorer = SubnetScorer.create(PeerSubnetSubscriptions.builder(() -> schemaDefinitions).attestationSubnetSubscriptions(b -> b.addRelevantSubnet(1).addRelevantSubnet(2).addRelevantSubnet(3).addRelevantSubnet(4).addSubscriber(1, node1).addSubscriber(1, node2).addSubscriber(1, node3).addSubscriber(1, node4).addSubscriber(2, node1).addSubscriber(2, node2).addSubscriber(3, node3).addSubscriber(5, node2)).syncCommitteeSubnetSubscriptions(b -> b.addRelevantSubnet(3).addSubscriber(3, node1).addSubscriber(3, node4).addSubscriber(2, node3)).build());
    assertExistingPeerScores(scorer, entry(node1, 562), entry(node2, 312), entry(node3, 1062), entry(node4, 312), entry(node5, 0));
}
Also used : MockNodeId(tech.pegasys.teku.networking.p2p.mock.MockNodeId) PeerScorer(tech.pegasys.teku.networking.eth2.peers.PeerScorer) Collections.emptyList(java.util.Collections.emptyList) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SchemaDefinitions(tech.pegasys.teku.spec.schemas.SchemaDefinitions) MockNodeId(tech.pegasys.teku.networking.p2p.mock.MockNodeId) Assertions.entry(org.assertj.core.api.Assertions.entry) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) List(java.util.List) SszBitvector(tech.pegasys.teku.infrastructure.ssz.collections.SszBitvector) Stream(java.util.stream.Stream) TestSpecFactory(tech.pegasys.teku.spec.TestSpecFactory) Pair(org.apache.commons.lang3.tuple.Pair) Map(java.util.Map) Spec(tech.pegasys.teku.spec.Spec) NodeId(tech.pegasys.teku.networking.p2p.peer.NodeId) Test(org.junit.jupiter.api.Test)

Aggregations

Collections.emptyList (java.util.Collections.emptyList)2 List (java.util.List)2 Map (java.util.Map)2 Function (java.util.function.Function)2 Collectors (java.util.stream.Collectors)2 Stream (java.util.stream.Stream)2 Pair (org.apache.commons.lang3.tuple.Pair)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Assertions.entry (org.assertj.core.api.Assertions.entry)2 Test (org.junit.jupiter.api.Test)2 SszBitvector (tech.pegasys.teku.infrastructure.ssz.collections.SszBitvector)2 PeerScorer (tech.pegasys.teku.networking.eth2.peers.PeerScorer)2 MockNodeId (tech.pegasys.teku.networking.p2p.mock.MockNodeId)2 NodeId (tech.pegasys.teku.networking.p2p.peer.NodeId)2 Spec (tech.pegasys.teku.spec.Spec)2 TestSpecFactory (tech.pegasys.teku.spec.TestSpecFactory)2 SchemaDefinitions (tech.pegasys.teku.spec.schemas.SchemaDefinitions)2 AggregateGossipManager (tech.pegasys.teku.networking.eth2.gossip.AggregateGossipManager)1 AttestationGossipManager (tech.pegasys.teku.networking.eth2.gossip.AttestationGossipManager)1 AttesterSlashingGossipManager (tech.pegasys.teku.networking.eth2.gossip.AttesterSlashingGossipManager)1