Skip to content

Commit

Permalink
Add Remaining Gossip Scoring Topics (#8678)
Browse files Browse the repository at this point in the history
* add for topics

* Apply suggestions from code review

Co-authored-by: Victor Farazdagi <simple.square@gmail.com>
  • Loading branch information
nisdas and farazdagi authored Mar 28, 2021
1 parent 54cf5f3 commit 4886a4e
Showing 1 changed file with 83 additions and 1 deletion.
84 changes: 83 additions & 1 deletion beacon-chain/p2p/gossip_scoring_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ const (
// attestationTotalWeight specifies the scoring weight that we apply to
// our attestation subnet topic.
attestationTotalWeight = 1
// attesterSlashingWeight specifies the scoring weight that we apply to
// our attester slashing topic.
attesterSlashingWeight = 0.05
// proposerSlashingWeight specifies the scoring weight that we apply to
// our proposer slashing topic.
proposerSlashingWeight = 0.05
// voluntaryExitWeight specifies the scoring weight that we apply to
// our voluntary exit topic.
voluntaryExitWeight = 0.05

// decayToZero specifies the terminal value that we will use when decaying
// a value.
decayToZero = 0.01
Expand Down Expand Up @@ -67,8 +77,14 @@ func (s *Service) topicScoreParams(topic string) (*pubsub.TopicScoreParams, erro
return defaultAggregateTopicParams(activeValidators), nil
case strings.Contains(topic, "beacon_attestation"):
return defaultAggregateSubnetTopicParams(activeValidators), nil
case strings.Contains(topic, "voluntary_exit"):
return defaultVoluntaryExitTopicParams(), nil
case strings.Contains(topic, "proposer_slashing"):
return defaultProposerSlashingTopicParams(), nil
case strings.Contains(topic, "attester_slashing"):
return defaultAttesterSlashingTopicParams(), nil
default:
return nil, nil
return nil, errors.Errorf("unrecognized topic provided for parameter registration: %s", topic)
}
}

Expand Down Expand Up @@ -178,6 +194,72 @@ func defaultAggregateSubnetTopicParams(activeValidators uint64) *pubsub.TopicSco
}
}

func defaultAttesterSlashingTopicParams() *pubsub.TopicScoreParams {
return &pubsub.TopicScoreParams{
TopicWeight: attesterSlashingWeight,
TimeInMeshWeight: 0.0324,
TimeInMeshQuantum: 1 * oneSlotDuration(),
TimeInMeshCap: 300,
FirstMessageDeliveriesWeight: 36,
FirstMessageDeliveriesDecay: scoreDecay(100 * oneEpochDuration()),
FirstMessageDeliveriesCap: 1,
MeshMessageDeliveriesWeight: 0,
MeshMessageDeliveriesDecay: 0,
MeshMessageDeliveriesCap: 0,
MeshMessageDeliveriesThreshold: 0,
MeshMessageDeliveriesWindow: 0,
MeshMessageDeliveriesActivation: 0,
MeshFailurePenaltyWeight: 0,
MeshFailurePenaltyDecay: 0,
InvalidMessageDeliveriesWeight: -2000,
InvalidMessageDeliveriesDecay: scoreDecay(50 * oneEpochDuration()),
}
}

func defaultProposerSlashingTopicParams() *pubsub.TopicScoreParams {
return &pubsub.TopicScoreParams{
TopicWeight: proposerSlashingWeight,
TimeInMeshWeight: 0.0324,
TimeInMeshQuantum: 1 * oneSlotDuration(),
TimeInMeshCap: 300,
FirstMessageDeliveriesWeight: 36,
FirstMessageDeliveriesDecay: scoreDecay(100 * oneEpochDuration()),
FirstMessageDeliveriesCap: 1,
MeshMessageDeliveriesWeight: 0,
MeshMessageDeliveriesDecay: 0,
MeshMessageDeliveriesCap: 0,
MeshMessageDeliveriesThreshold: 0,
MeshMessageDeliveriesWindow: 0,
MeshMessageDeliveriesActivation: 0,
MeshFailurePenaltyWeight: 0,
MeshFailurePenaltyDecay: 0,
InvalidMessageDeliveriesWeight: -2000,
InvalidMessageDeliveriesDecay: scoreDecay(50 * oneEpochDuration()),
}
}

func defaultVoluntaryExitTopicParams() *pubsub.TopicScoreParams {
return &pubsub.TopicScoreParams{
TopicWeight: voluntaryExitWeight,
TimeInMeshWeight: 0.0324,
TimeInMeshQuantum: 1 * oneSlotDuration(),
TimeInMeshCap: 300,
FirstMessageDeliveriesWeight: 2,
FirstMessageDeliveriesDecay: scoreDecay(100 * oneEpochDuration()),
FirstMessageDeliveriesCap: 5,
MeshMessageDeliveriesWeight: 0,
MeshMessageDeliveriesDecay: 0,
MeshMessageDeliveriesCap: 0,
MeshMessageDeliveriesThreshold: 0,
MeshMessageDeliveriesWindow: 0,
MeshMessageDeliveriesActivation: 0,
MeshFailurePenaltyWeight: 0,
MeshFailurePenaltyDecay: 0,
InvalidMessageDeliveriesWeight: -2000,
InvalidMessageDeliveriesDecay: scoreDecay(50 * oneEpochDuration()),
}
}

func oneSlotDuration() time.Duration {
return time.Duration(params.BeaconConfig().SecondsPerSlot) * time.Second
}
Expand Down

0 comments on commit 4886a4e

Please sign in to comment.