-
Notifications
You must be signed in to change notification settings - Fork 995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement SubscribeCommitteeSubnet
method
#5299
Changes from 15 commits
79e0674
17b771b
d7cf690
d7615ea
10ca5c8
5950ab6
cd7a236
d8f7690
956e8a5
5a996db
e9d1ee1
de6b1ce
38f9b68
cb1a4c6
3190aa3
81da6d9
a8e0784
62f9817
9155e78
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package cache | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestCommitteeIDCache_RoundTrip(t *testing.T) { | ||
c := newCommitteeIDs() | ||
slot := uint64(100) | ||
committeeIDs := c.GetAggregatorCommitteeIDs(slot) | ||
if len(committeeIDs) != 0 { | ||
t.Errorf("Empty cache returned an object: %v", committeeIDs) | ||
} | ||
|
||
c.AddAggregatorCommiteeID(slot, 1) | ||
res := c.GetAggregatorCommitteeIDs(slot) | ||
if !reflect.DeepEqual(res, []uint64{1}) { | ||
t.Error("Expected equal value to return from cache") | ||
} | ||
|
||
c.AddAggregatorCommiteeID(slot, 2) | ||
res = c.GetAggregatorCommitteeIDs(slot) | ||
if !reflect.DeepEqual(res, []uint64{1, 2}) { | ||
t.Error("Expected equal value to return from cache") | ||
} | ||
|
||
c.AddAggregatorCommiteeID(slot, 3) | ||
res = c.GetAggregatorCommitteeIDs(slot) | ||
if !reflect.DeepEqual(res, []uint64{1, 2, 3}) { | ||
t.Error("Expected equal value to return from cache") | ||
} | ||
|
||
committeeIDs = c.GetAttesterCommitteeIDs(slot) | ||
if len(committeeIDs) != 0 { | ||
t.Errorf("Empty cache returned an object: %v", committeeIDs) | ||
} | ||
|
||
c.AddAttesterCommiteeID(slot, 11) | ||
res = c.GetAttesterCommitteeIDs(slot) | ||
if !reflect.DeepEqual(res, []uint64{11}) { | ||
t.Error("Expected equal value to return from cache") | ||
} | ||
|
||
c.AddAttesterCommiteeID(slot, 22) | ||
res = c.GetAttesterCommitteeIDs(slot) | ||
if !reflect.DeepEqual(res, []uint64{11, 22}) { | ||
t.Error("Expected equal value to return from cache") | ||
} | ||
|
||
c.AddAttesterCommiteeID(slot, 33) | ||
res = c.GetAttesterCommitteeIDs(slot) | ||
if !reflect.DeepEqual(res, []uint64{11, 22, 33}) { | ||
t.Error("Expected equal value to return from cache") | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,6 @@ func (r *Service) committeesCount() int { | |
|
||
func (r *Service) committeeIndices() []uint64 { | ||
currentEpoch := helpers.SlotToEpoch(r.chain.HeadSlot()) | ||
return sliceutil.UnionUint64(cache.CommitteeIDs.GetIDs(currentEpoch), | ||
cache.CommitteeIDs.GetIDs(currentEpoch+1)) | ||
return sliceutil.UnionUint64(cache.CommitteeIDs.GetAttesterCommitteeIDs(currentEpoch), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wouldn't this be wrong ? since we are saving by slots There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah i see, not sure if using head slot there was correct to begin with, i changed it to use |
||
cache.CommitteeIDs.GetAttesterCommitteeIDs(currentEpoch+1)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we will need to add both attester + aggregator indexes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!