Skip to content

Commit

Permalink
Fix Seen Cache Interval (#7751)
Browse files Browse the repository at this point in the history
* fix

* var

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
Co-authored-by: Victor Farazdagi <simple.square@gmail.com>
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
  • Loading branch information
4 people committed Nov 10, 2020
1 parent b4bce7c commit 742808c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 1 addition & 6 deletions beacon-chain/p2p/parameter_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package p2p

import (
"math"
"testing"
"time"

pubsub "github.com/libp2p/go-libp2p-pubsub"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
)

Expand Down Expand Up @@ -42,10 +40,7 @@ func TestGossipParameters(t *testing.T) {
setPubSubParameters()
assert.Equal(t, gossipSubMcacheLen, pubsub.GossipSubHistoryLength, "gossipSubMcacheLen")
assert.Equal(t, gossipSubMcacheGossip, pubsub.GossipSubHistoryGossip, "gossipSubMcacheGossip")
val := (params.BeaconConfig().SlotsPerEpoch * params.BeaconConfig().SecondsPerSlot * 1000) /
uint64(pubsub.GossipSubHeartbeatInterval.Milliseconds())
roundedUp := math.Round(float64(val) / 10)
assert.Equal(t, gossipSubSeenTTL, int(roundedUp)*10, "gossipSubSeenTtl")
assert.Equal(t, gossipSubSeenTTL, int(pubsub.TimeCacheDuration.Milliseconds()/pubsub.GossipSubHeartbeatInterval.Milliseconds()), "gossipSubSeenTtl")
}

func TestFanoutParameters(t *testing.T) {
Expand Down
4 changes: 3 additions & 1 deletion beacon-chain/p2p/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ func msgIDFunction(pmsg *pubsub_pb.Message) string {
}

func setPubSubParameters() {
heartBeatInterval := 700 * time.Millisecond
pubsub.GossipSubDlo = 5
pubsub.GossipSubHeartbeatInterval = 700 * time.Millisecond
pubsub.GossipSubHeartbeatInterval = heartBeatInterval
pubsub.GossipSubHistoryLength = 6
pubsub.GossipSubHistoryGossip = 3
pubsub.TimeCacheDuration = 550 * heartBeatInterval
}

0 comments on commit 742808c

Please sign in to comment.