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

feat: Make voter electing staisfy finality #120

Closed
wants to merge 6 commits into from
Closed

feat: Make voter electing staisfy finality #120

wants to merge 6 commits into from

Conversation

kukugi
Copy link

@kukugi kukugi commented Sep 14, 2020

Closes: #115

Description

Change voter election to satisfy finality.

changes

Sort voters in descending voting power/staking power.
Pick up a voter in order until total staking power of voters equal to total staking power of validators
If total voting power of voters picked up less than 1/3 of total voting power then stop electing

change and write test code to fit new election


For contributor use:

  • Wrote tests
  • Updated CHANGELOG_PENDING.md
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Updated relevant documentation (docs/) and code comments
  • Re-reviewed Files changed in the Github PR explorer

@kukugi kukugi self-assigned this Sep 14, 2020
@kukugi kukugi changed the title feat: Make staisfy finality when elect voter feat: Make voter electing staisfy finality Sep 15, 2020

// sortVoters is function to sort voters in descending votingPower/stakingPower
func sortVoters(candidates []Candidate) []Candidate {
temp := make([]Candidate, len(candidates))
Copy link
Contributor

Choose a reason for hiding this comment

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

You can sort this in-place. And the caller sortVoters(voters) has no effect with out-place sorting.

Copy link
Author

Choose a reason for hiding this comment

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

ok i see, it can solve for changing caller sortVoters(voters) to voters = sortVoters(voters)

@egonspace
Copy link
Contributor

When we first created the Sampling function, we implemented it in libs/land/sampling.go for general use, but now it doensn't need to be in the libs module anymore because it refers to a lot of voter-related contents such as 'voting power'. How about to move this implementation into voter_set.go and get rid of the Candidate interface?

@kukugi
Copy link
Author

kukugi commented Sep 18, 2020

When we first created the Sampling function, we implemented it in libs/land/sampling.go for general use, but now it doensn't need to be in the libs module anymore because it refers to a lot of voter-related contents such as 'voting power'. How about to move this implementation into voter_set.go and get rid of the Candidate interface?

thanks for your review, I'll give it a try.

@egonspace
Copy link
Contributor

When we first created the Sampling function, we implemented it in libs/land/sampling.go for general use, but now it doensn't need to be in the libs module anymore because it refers to a lot of voter-related contents such as 'voting power'. How about to move this implementation into voter_set.go and get rid of the Candidate interface?

thanks for your review, I'll give it a try.

Let's talk about this in next weekly.

@kukugi
Copy link
Author

kukugi commented Sep 29, 2020

Create new PR without private branch to use Circle CI Large docker plan #124

@kukugi kukugi closed this Sep 29, 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