Skip to content
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

Refactor validator roles into an array #4081

Merged
merged 8 commits into from
Nov 21, 2019
Merged

Conversation

terencechain
Copy link
Member

Previously we have roles defined in PB as attester, proposer and both. This becomes not extensible as we introduce more roles. This PR refactors to validator client treat these roles as an array.

Before:
pb.Both // attester and proposer both assigned to slot N
After:
[]pb.Roles{pb.Attester, pb.Proposer} // attester and proposer both assigned to slot N

validator/client/runner.go Outdated Show resolved Hide resolved
validator/client/runner.go Outdated Show resolved Hide resolved
switch {
case assignment == nil:
role = pb.ValidatorRole_UNKNOWN
roles = append(roles, pb.ValidatorRole_UNKNOWN)
case assignment.ProposerSlot == slot && assignment.AttesterSlot == slot:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this case all together

Co-Authored-By: Preston Van Loon <preston@prysmaticlabs.com>
@codecov
Copy link

codecov bot commented Nov 21, 2019

Codecov Report

Merging #4081 into master will decrease coverage by 5.04%.
The diff coverage is 75%.

@@            Coverage Diff             @@
##           master    #4081      +/-   ##
==========================================
- Coverage   21.54%   16.49%   -5.05%     
==========================================
  Files         167       82      -85     
  Lines       10899     4923    -5976     
==========================================
- Hits         2348      812    -1536     
+ Misses       8249     4007    -4242     
+ Partials      302      104     -198

terencechain and others added 3 commits November 21, 2019 13:52
var roles []pb.ValidatorRole

if assignment == nil {
roles = append(roles, pb.ValidatorRole_UNKNOWN)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just leave it empty? No need to insert UNKNOWN when an empty roles array means no work to do

@terencechain terencechain merged commit 976a3af into master Nov 21, 2019
@delete-merged-branch delete-merged-branch bot deleted the refactor-validator-roles branch November 21, 2019 22:35
cryptomental pushed a commit to cryptomental/prysm that referenced this pull request Feb 24, 2020
cryptomental pushed a commit to cryptomental/prysm that referenced this pull request Feb 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants