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 List Validator Assignments #4456
Conversation
nisdas
commented
Jan 8, 2020
- Only retrieves the committee cache once, to prevent redundant computation
- Retrieves archival data from epoch only once per call
Codecov Report
@@ Coverage Diff @@
## master #4456 +/- ##
=======================================
Coverage 18.17% 18.17%
=======================================
Files 193 193
Lines 12822 12822
=======================================
Hits 2330 2330
Misses 10206 10206
Partials 286 286 |
archivedBalances := []uint64{} | ||
|
||
if shouldFetchFromArchive { | ||
archivedInfo, err = bs.BeaconDB.ArchivedCommitteeInfo(ctx, requestedEpoch) |
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.
I know this is not new code, but can you refactor everything within shouldFetchFromArchive
into its function?
if shouldFetchFromArchive {
bs.archivedCommitteeAssignment(ctx, requestedEpoch)
...
} else {
committeeAssignments, proposerIndexToSlot, err = helpers.CommitteeAssignments(headState, requestedEpoch)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not compute committee assignments: %v", err)
}
}
@@ -157,15 +171,12 @@ func (bs *Server) ListValidatorAssignments( | |||
res = append(res, assign) | |||
continue | |||
} | |||
committee, committeeIndex, attesterSlot, proposerSlot, err := helpers.CommitteeAssignment(headState, requestedEpoch, index) |
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.
Yikes, this was the really slow one!
if err != nil { | ||
return nil, status.Errorf(codes.Internal, "Could not retrieve assignment for validator %d: %v", index, err) | ||
} | ||
comAssingnment := committeeAssignments[index] |
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.
Typo here
…iclabs/geth-sharding into listValidatorAssingments
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.
Thank you for the changes!
* optimize * Merge refs/heads/master into listValidatorAssingments * Merge refs/heads/master into listValidatorAssingments * Merge refs/heads/master into listValidatorAssingments * Merge refs/heads/master into listValidatorAssingments * Merge refs/heads/master into listValidatorAssingments * Merge refs/heads/master into listValidatorAssingments * Merge refs/heads/master into listValidatorAssingments * Merge refs/heads/master into listValidatorAssingments * Merge refs/heads/master into listValidatorAssingments * terence's and preston's review * Merge branch 'listValidatorAssingments' of https://github.com/prysmaticlabs/geth-sharding into listValidatorAssingments
* optimize * Merge refs/heads/master into listValidatorAssingments * Merge refs/heads/master into listValidatorAssingments * Merge refs/heads/master into listValidatorAssingments * Merge refs/heads/master into listValidatorAssingments * Merge refs/heads/master into listValidatorAssingments * Merge refs/heads/master into listValidatorAssingments * Merge refs/heads/master into listValidatorAssingments * Merge refs/heads/master into listValidatorAssingments * Merge refs/heads/master into listValidatorAssingments * terence's and preston's review * Merge branch 'listValidatorAssingments' of https://github.com/prysmaticlabs/geth-sharding into listValidatorAssingments