-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Optimize SubscribeCommitteeSubnets
VC action
#13702
Conversation
e8dc90a
to
818d075
Compare
@@ -3899,7 +3899,7 @@ var file_proto_prysm_v1alpha1_beacon_block_proto_rawDesc = []byte{ | |||
0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x26, 0x70, | |||
0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x65, | |||
0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, | |||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xf4, 0x05, 0x0a, 0x18, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x69, | |||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xee, 0x05, 0x0a, 0x18, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x69, |
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.
Why was this file changed if no proto changed?
@@ -537,6 +537,8 @@ message DutiesResponse { | |||
|
|||
// Whether the validator belongs in the sync committee and has to perform sync committee duty. | |||
bool is_sync_committee = 8; | |||
|
|||
uint64 committees_at_slot = 9; |
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.
All other values in this file have a comment.
@@ -95,6 +95,11 @@ func (c beaconApiValidatorClient) getDutiesForEpoch( | |||
if err != nil { | |||
return nil, errors.Wrapf(err, "failed to get committees for epoch `%d`", epoch) | |||
} | |||
slotCommittees := make(map[string]uint64) | |||
for _, c := range committees { | |||
n := slotCommittees[c.Slot] |
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.
Even if this works correctly, I think it would be better to explicitly handle the case where c.Slot
is not in slotCommittees
, instead of relying on the default missing value of uint64
.
Something like
for _, c := range committees {
n, ok := slotCommittees[c.Slot]
if !ok {
n = 0
}
slotCommittees[c.Slot] = n + 1
}
What type of PR is this?
Other
What does this PR do? Why is it needed?
SubscribeCommitteeSubnets
in the REST VC takes around 1-2 seconds. Almost all of this time is spend on fetching duties to get the number of committees in a slot, but we already return this value when fetching duties at the beginning of the epoch, we just need to pass it into the function. Addingcommittees_at_slot
to the duty proto message allows us to have this value available.This reduces the time needed to subscribe from 1-2 seconds to 1 millisecond.