use of tech.pegasys.teku.networking.eth2.gossip.subnets.SyncCommitteeSubnetSubscriptions 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));
}
use of tech.pegasys.teku.networking.eth2.gossip.subnets.SyncCommitteeSubnetSubscriptions 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));
}
use of tech.pegasys.teku.networking.eth2.gossip.subnets.SyncCommitteeSubnetSubscriptions in project teku by ConsenSys.
the class GossipForkSubscriptionsAltair method addGossipManagers.
@Override
protected void addGossipManagers(final ForkInfo forkInfo) {
super.addGossipManagers(forkInfo);
final SchemaDefinitionsAltair schemaDefinitions = SchemaDefinitionsAltair.required(spec.atEpoch(getActivationEpoch()).getSchemaDefinitions());
syncCommitteeContributionGossipManager = new SignedContributionAndProofGossipManager(recentChainData, schemaDefinitions, asyncRunner, discoveryNetwork, gossipEncoding, forkInfo, signedContributionAndProofOperationProcessor, getMessageMaxSize());
addGossipManager(syncCommitteeContributionGossipManager);
final SyncCommitteeSubnetSubscriptions syncCommitteeSubnetSubscriptions = new SyncCommitteeSubnetSubscriptions(spec, recentChainData, discoveryNetwork, gossipEncoding, schemaDefinitions, asyncRunner, syncCommitteeMessageOperationProcessor, forkInfo, getMessageMaxSize());
syncCommitteeMessageGossipManager = new SyncCommitteeMessageGossipManager(metricsSystem, spec, new SyncCommitteeStateUtils(spec, recentChainData), syncCommitteeSubnetSubscriptions);
addGossipManager(syncCommitteeMessageGossipManager);
}
Aggregations