use of tech.pegasys.teku.networking.p2p.gossip.config.GossipScoringConfig in project teku by ConsenSys.
the class GossipScoringConfiguratorTest method configure_preGenesis.
@Test
public void configure_preGenesis() {
final GossipConfig.Builder builder = GossipConfig.builder();
configurator.configure(builder, preGenesisEth2Context());
final GossipConfig config = builder.build();
final GossipScoringConfig scoringConfig = config.getScoringConfig();
assertThat(scoringConfig.getGossipThreshold()).isEqualTo(-4000);
assertThat(scoringConfig.getPublishThreshold()).isEqualTo(-8000);
assertThat(scoringConfig.getGraylistThreshold()).isEqualTo(-16000);
assertThat(scoringConfig.getAcceptPXThreshold()).isEqualTo(100);
assertThat(scoringConfig.getOpportunisticGraftThreshold()).isEqualTo(5);
final GossipPeerScoringConfig peerScoring = scoringConfig.getPeerScoringConfig();
assertThat(peerScoring.getTopicScoreCap()).isCloseTo(53.75, within(TOLERANCE));
assertThat(peerScoring.getIpColocationFactorWeight()).isCloseTo(-53.75, within(TOLERANCE));
assertThat(peerScoring.getIpColocationFactorThreshold()).isEqualTo(3);
assertThat(peerScoring.getBehaviourPenaltyDecay()).isCloseTo(0.9857, within(TOLERANCE));
assertThat(peerScoring.getBehaviourPenaltyWeight()).isCloseTo(-15.8793, within(TOLERANCE));
assertThat(peerScoring.getBehaviourPenaltyThreshold()).isEqualTo(6.0);
assertThat(peerScoring.getDecayToZero()).isEqualTo(0.01);
assertThat(peerScoring.getDecayInterval().toSeconds()).isEqualTo(12);
assertThat(peerScoring.getRetainScore().toSeconds()).isEqualTo(38400);
// Check topics
final Map<String, GossipTopicScoringConfig> topicsConfig = scoringConfig.getTopicScoringConfig();
assertThat(topicsConfig).isEmpty();
}
use of tech.pegasys.teku.networking.p2p.gossip.config.GossipScoringConfig in project teku by ConsenSys.
the class LibP2PParamsFactory method createTopicsScoreParams.
public static GossipTopicsScoreParams createTopicsScoreParams(final GossipScoringConfig config) {
final GossipTopicScoreParams defaultTopicParams = createTopicScoreParams(config.getDefaultTopicScoringConfig());
final Map<String, GossipTopicScoreParams> topicParams = config.getTopicScoringConfig().entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> createTopicScoreParams(e.getValue())));
return new GossipTopicsScoreParams(defaultTopicParams, topicParams);
}
Aggregations