-
Notifications
You must be signed in to change notification settings - Fork 190
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
Refine SubList and SubListWithProposer #551
Conversation
The last commit revoked changes in the previous commit restricting committee size. |
if committeeSize >= validatorSize { | ||
return validators | ||
} |
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.
how about moving these codes to top of the function.
we can just return if the commiteeSize is bigger than validatorSize
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. I moved it!
// seed will be used to select a random committee | ||
seed, err := ConvertHashToSeed(prevHash) | ||
if err != nil { | ||
logger.Error("failed to covert hash to seed", "prevHash", prevHash, "err", err) |
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.
logger.Error("failed to covert hash to seed", "prevHash", prevHash, "err", err) | |
logger.Error("failed to convert hash to seed", "prevHash", prevHash, "err", err) |
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!
Reviewers, please take a look. |
// SelectRandomCommittee composes a committee selecting validators randomly based on the seed value. | ||
// It returns nil if the given committeeSize is bigger than validatorSize or proposer indexes are invalid. | ||
func SelectRandomCommittee(validators []istanbul.Validator, committeeSize uint64, seed int64, proposerIdx int, nextProposerIdx int) []istanbul.Validator { | ||
// ensure validator indexes are valid |
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.
// ensure validator indexes are valid | |
// ensure proposer indexes are valid |
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 think "validator" is good to go because the index is indexes of validators
variable
func (valSet *weightedCouncil) SetSubGroupSize(size uint64) { | ||
if size == 0 { | ||
logger.Error("cannot assign committee size to 0") |
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.
Crit?
logger.Error("cannot assign committee size to 0") | |
logger.Crit("cannot assign committee size to 0") |
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 think error
is enough. It doesn't change valSet.subSize
value when size
is 0.
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.
LGTM.
@ehnuje PTAL. :) |
Proposed changes
Refine
SubList
andSubListWithProposer
.ConvertHashToSeed
,SelectRandomCommittee
committeeSize
inSubListWithProposer
SetSubGroupSize
I tried to maintain the semantic of the
SubListWithProposer
except for invalid input handling.Types of changes
Please put an x in the boxes related to your change.
Checklist
Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.
$ make test
)