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

Refactors Consensus::enterCommittee #161

Closed
wants to merge 7 commits into from

Conversation

pgev
Copy link
Collaborator

@pgev pgev commented Jan 8, 2020

No description provided.

@abhayks1
Copy link
Collaborator

abhayks1 commented Jan 9, 2020

@pgev Is it available for review?
Travis tests are red 🔴

@pgev
Copy link
Collaborator Author

pgev commented Jan 9, 2020

@abhayks1 I've rebased and fixed failing tests. It's again ready for review.

@abhayks1 abhayks1 self-assigned this Jan 9, 2020
Copy link
Collaborator

@abhayks1 abhayks1 left a comment

Choose a reason for hiding this comment

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

Nice work 👍
Please see inline comments.

* - and, less or equal than validator's end height
* - was not slashed
*/
function isValidator(address _account, uint256 _metablockHeight)
Copy link
Collaborator

Choose a reason for hiding this comment

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

A lot of code between isActiveValidator and isValidator is common. We can refactor the common code to a private method with parameters account, metablockHeight. isActiveValidator can pass openKernelHeight as metablockHeight

What do you think?

* - greater or equal than validator's begin height
* - and, less or equal than validator's end height
* - was not slashed
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should add documentation for function arguments and and return values as per dev guidelines.
Similar comment for isActiveValidator method.

CoreI _core,
bytes32 _committeeMetachainId,
bytes32 _validatorMetachainId,
uint256 _validatorMetablockHeight,
address _validator,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel _validator argument should come before _validatorMetachainId, _validatorMetablockHeight.
A validator is entering into committee. _validatorMetachainId and _validatorMetablockHeight seems like they are the properties of a validator. The _validator argument significance is strong enough to be prefixed before _validatorMetachainId and _validatorMetablockHeight
@pgev @deepesh-kn what do you think? It's an interface change.

Metablock storage currentMetablock = metablockchains[_metachainId][currentHeight];
uint256 formationHeight = committeeMetablock.roundBlockNumber;
uint256 checkValidatorForHeight = 0;
if (validatorMetablock.roundBlockNumber >= formationHeight) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the logic of evaluating checkValidatorForHeight can be refactored to private/internal method 🤔.
enterCommittee method has grown significantly.

@abhayks1 abhayks1 removed their assignment Jan 10, 2020
@deepesh-kn deepesh-kn changed the base branch from feature/consensus to develop January 22, 2020 11:37
@pgev
Copy link
Collaborator Author

pgev commented Feb 11, 2020

Closing the PR for now. Will add into #147 as a note for later reference if needed.

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