Skip to content

Commit

Permalink
Update committee cache size to 32 (#7018)
Browse files Browse the repository at this point in the history
* Update committee cache size to 32
* Merge branch 'master' into update-committee-cache-size
* Cache: fixed rotating test
* Merge branch 'update-committee-cache-size' of github.com:prysmaticlabs/prysm into update-committee-cache-size
* Merge refs/heads/master into update-committee-cache-size
* Merge refs/heads/master into update-committee-cache-size
* Merge refs/heads/master into update-committee-cache-size
  • Loading branch information
terencechain authored Aug 17, 2020
1 parent d66f729 commit a2f7815
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 2 additions & 3 deletions beacon-chain/cache/committee.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ var (
ErrNotCommittee = errors.New("object is not a committee struct")

// maxCommitteesCacheSize defines the max number of shuffled committees on per randao basis can cache.
// Due to reorgs, it's good to keep the old cache around for quickly switch over. 10 is a generous
// cache size as it considers 3 concurrent branches over 3 epochs.
maxCommitteesCacheSize = uint64(10)
// Due to reorgs and long finality, it's good to keep the old cache around for quickly switch over.
maxCommitteesCacheSize = uint64(32)

// CommitteeCacheMiss tracks the number of committee requests that aren't present in the cache.
CommitteeCacheMiss = promauto.NewCounter(prometheus.CounterOpts{
Expand Down
7 changes: 5 additions & 2 deletions beacon-chain/cache/committee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ func TestCommitteeCache_CanRotate(t *testing.T) {
cache := NewCommitteesCache()

// Should rotate out all the epochs except 190 through 199.
for i := 100; i < 200; i++ {
start := 100
end := 200
for i := start; i < end; i++ {
s := []byte(strconv.Itoa(i))
item := &Committees{Seed: bytesutil.ToBytes32(s)}
require.NoError(t, cache.AddCommitteeShuffledList(item))
Expand All @@ -134,7 +136,8 @@ func TestCommitteeCache_CanRotate(t *testing.T) {
sort.Slice(k, func(i, j int) bool {
return k[i] < k[j]
})
s := bytesutil.ToBytes32([]byte(strconv.Itoa(190)))
wanted := end - int(maxCommitteesCacheSize)
s := bytesutil.ToBytes32([]byte(strconv.Itoa(wanted)))
assert.Equal(t, key(s), k[0], "incorrect key received for slot 190")

s = bytesutil.ToBytes32([]byte(strconv.Itoa(199)))
Expand Down

0 comments on commit a2f7815

Please sign in to comment.