use of tech.pegasys.teku.networking.p2p.gossip.config.GossipTopicScoringConfig in project teku by ConsenSys.
the class GossipScoringConfiguratorTest method validateBlockTopicParams.
private void validateBlockTopicParams(final Map<String, GossipTopicScoringConfig> allTopics, final boolean penaltiesActive) {
final GossipTopicScoringConfig blockTopicScoring = getBlockTopicScoring(allTopics);
assertThat(blockTopicScoring.getTopicWeight()).isEqualTo(0.5);
assertThat(blockTopicScoring.getTimeInMeshWeight()).isCloseTo(0.03333, within(TOLERANCE));
assertThat(blockTopicScoring.getTimeInMeshQuantum()).isEqualTo(Duration.ofSeconds(12));
assertThat(blockTopicScoring.getTimeInMeshCap()).isEqualTo(300.0);
assertThat(blockTopicScoring.getFirstMessageDeliveriesWeight()).isCloseTo(1.14716, within(TOLERANCE));
assertThat(blockTopicScoring.getFirstMessageDeliveriesDecay()).isCloseTo(0.99283, within(TOLERANCE));
assertThat(blockTopicScoring.getFirstMessageDeliveriesCap()).isCloseTo(34.8687, within(TOLERANCE));
assertThat(blockTopicScoring.getInvalidMessageDeliveriesWeight()).isCloseTo(-215.0, within(TOLERANCE));
assertThat(blockTopicScoring.getInvalidMessageDeliveriesDecay()).isCloseTo(0.99713, within(TOLERANCE));
// Check message rate penalty params
assertThat(blockTopicScoring.getMeshMessageDeliveriesDecay()).isCloseTo(0.97163, within(TOLERANCE));
assertThat(blockTopicScoring.getMeshMessageDeliveriesCap()).isCloseTo(2.0547574, within(TOLERANCE));
assertThat(blockTopicScoring.getMeshMessageDeliveriesActivation()).isEqualTo(Duration.ofSeconds(384));
assertThat(blockTopicScoring.getMeshMessageDeliveryWindow()).isEqualTo(Duration.ofSeconds(2));
assertThat(blockTopicScoring.getMeshFailurePenaltyWeight()).isCloseTo(-458.31055, within(TOLERANCE));
assertThat(blockTopicScoring.getMeshFailurePenaltyDecay()).isCloseTo(0.97163, within(TOLERANCE));
if (penaltiesActive) {
assertThat(blockTopicScoring.getMeshMessageDeliveriesWeight()).isCloseTo(-458.31055, within(TOLERANCE));
assertThat(blockTopicScoring.getMeshMessageDeliveriesThreshold()).isCloseTo(0.68491, within(TOLERANCE));
} else {
assertThat(blockTopicScoring.getMeshMessageDeliveriesWeight()).isEqualTo(0.0);
assertThat(blockTopicScoring.getMeshMessageDeliveriesThreshold()).isEqualTo(0.0);
}
}
use of tech.pegasys.teku.networking.p2p.gossip.config.GossipTopicScoringConfig in project teku by ConsenSys.
the class GossipScoringConfiguratorTest method validateSlashingTopicParams.
private void validateSlashingTopicParams(final Map<String, GossipTopicScoringConfig> allTopics) {
final GossipTopicScoringConfig attesterSlashingParams = getAttesterSlashingTopicScoring(allTopics);
final GossipTopicScoringConfig proposerSlashingParams = getProposerSlashingTopicScoring(allTopics);
validateSlashingTopicParams(attesterSlashingParams);
validateSlashingTopicParams(proposerSlashingParams);
}
use of tech.pegasys.teku.networking.p2p.gossip.config.GossipTopicScoringConfig 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.GossipTopicScoringConfig in project teku by ConsenSys.
the class GossipScoringConfiguratorTest method validateVoluntaryExitTopicParams.
private void validateVoluntaryExitTopicParams(final Map<String, GossipTopicScoringConfig> allTopics) {
final GossipTopicScoringConfig params = getVoluntaryExitTopicScoring(allTopics);
assertMessageRatePenaltiesDisabled(params);
assertThat(params.getTopicWeight()).isEqualTo(0.05);
assertThat(params.getTimeInMeshWeight()).isCloseTo(0.03333, within(TOLERANCE));
assertThat(params.getTimeInMeshQuantum()).isEqualTo(Duration.ofSeconds(12));
assertThat(params.getTimeInMeshCap()).isEqualTo(300.0);
assertThat(params.getFirstMessageDeliveriesWeight()).isCloseTo(1.8407, within(TOLERANCE));
assertThat(params.getFirstMessageDeliveriesDecay()).isCloseTo(0.99856, within(TOLERANCE));
assertThat(params.getFirstMessageDeliveriesCap()).isCloseTo(21.73035, within(TOLERANCE));
assertThat(params.getInvalidMessageDeliveriesWeight()).isCloseTo(-2150.0, within(TOLERANCE));
assertThat(params.getInvalidMessageDeliveriesDecay()).isCloseTo(0.99713, within(TOLERANCE));
}
use of tech.pegasys.teku.networking.p2p.gossip.config.GossipTopicScoringConfig in project teku by ConsenSys.
the class GossipScoringConfiguratorTest method validateAggregateTopicParams.
private void validateAggregateTopicParams(final Map<String, GossipTopicScoringConfig> allTopics, final boolean penaltiesActive) {
final GossipTopicScoringConfig params = getAggregateTopicScoring(allTopics);
assertThat(params.getTopicWeight()).isEqualTo(0.5);
assertThat(params.getTimeInMeshWeight()).isCloseTo(0.03333, within(TOLERANCE));
assertThat(params.getTimeInMeshQuantum()).isEqualTo(Duration.ofSeconds(12));
assertThat(params.getTimeInMeshCap()).isEqualTo(300.0);
assertThat(params.getFirstMessageDeliveriesWeight()).isCloseTo(0.33509, within(TOLERANCE));
assertThat(params.getFirstMessageDeliveriesDecay()).isCloseTo(0.86596, within(TOLERANCE));
assertThat(params.getFirstMessageDeliveriesCap()).isCloseTo(119.3712, within(TOLERANCE));
assertThat(params.getInvalidMessageDeliveriesWeight()).isCloseTo(-215.0, within(TOLERANCE));
assertThat(params.getInvalidMessageDeliveriesDecay()).isCloseTo(0.99713, within(TOLERANCE));
// Check message rate penalty params
assertThat(params.getMeshMessageDeliveriesDecay()).isCloseTo(0.930572, within(TOLERANCE));
assertThat(params.getMeshMessageDeliveriesCap()).isCloseTo(68.6255, within(TOLERANCE));
assertThat(params.getMeshMessageDeliveriesActivation()).isEqualTo(Duration.ofSeconds(384));
assertThat(params.getMeshMessageDeliveryWindow()).isEqualTo(Duration.ofSeconds(2));
assertThat(params.getMeshFailurePenaltyWeight()).isCloseTo(-0.73044, within(TOLERANCE));
assertThat(params.getMeshFailurePenaltyDecay()).isCloseTo(0.93057, within(TOLERANCE));
if (penaltiesActive) {
assertThat(params.getMeshMessageDeliveriesWeight()).isCloseTo(-0.7304, within(TOLERANCE));
assertThat(params.getMeshMessageDeliveriesThreshold()).isCloseTo(17.15638, within(TOLERANCE));
} else {
assertThat(params.getMeshMessageDeliveriesWeight()).isEqualTo(0.0);
assertThat(params.getMeshMessageDeliveriesThreshold()).isEqualTo(0.0);
}
}
Aggregations