Skip to content

Sort validator set in public key order#388

Merged
majecty merged 3 commits intoCodeChain-io:masterfrom
majecty:f/fix-validator-set-order
May 20, 2020
Merged

Sort validator set in public key order#388
majecty merged 3 commits intoCodeChain-io:masterfrom
majecty:f/fix-validator-set-order

Conversation

@majecty
Copy link

@majecty majecty commented May 13, 2020

By sorting the validator set using public keys, we can make validator set hash consistent. We can use this property to omit the validator set hash in Header Sync.

If two validators have the same delegation and deposit, the one who became the candidate first will be validator first. We didn't change the rule in this commit. Previously we kept the order of Candidates and Validators to remember who became the candidate first. Now we are saving nomination_starts_at variable to remember it.

@majecty majecty force-pushed the f/fix-validator-set-order branch 2 times, most recently from cef6fa7 to 4c5e0f4 Compare May 14, 2020 09:35
@majecty majecty changed the title [WIP] Fix the order of validator set Sort validator set in public key order May 14, 2020
@majecty majecty marked this pull request as ready for review May 14, 2020 09:38
@majecty majecty requested a review from sgkim126 May 14, 2020 09:39
@majecty majecty force-pushed the f/fix-validator-set-order branch 2 times, most recently from 2de4a4c to 7b2a2c4 Compare May 18, 2020 05:02
@majecty
Copy link
Author

majecty commented May 18, 2020

@sgkim126 I fixed them.

@majecty majecty force-pushed the f/fix-validator-set-order branch 2 times, most recently from 5d4efbb to c8e7110 Compare May 18, 2020 09:25
@majecty majecty requested a review from sgkim126 May 19, 2020 01:16
@majecty
Copy link
Author

majecty commented May 19, 2020

Failed tests succeed in my local MacOS and Linux machines except discovery 5 test.

sgkim126
sgkim126 previously approved these changes May 19, 2020
Copy link
Contributor

@sgkim126 sgkim126 left a comment

Choose a reason for hiding this comment

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

LGTM for change. But please merge the commits that change the test into the commit that changes the implementation.

@majecty
Copy link
Author

majecty commented May 19, 2020

I merged the commits that change the test into the commit that changes the implementation!

@majecty majecty requested a review from sgkim126 May 19, 2020 08:34
@majecty
Copy link
Author

majecty commented May 19, 2020

It seems that this PR makes tests to use more time. I'll dig into it.

HoOngEe added a commit to HoOngEe/foundry that referenced this pull request May 19, 2020
It applies the changes in CodeChain-io#388. NextValidators and CurrentValidators
are sorted by public key. As a tiebreaker Candidate and Validator
utilize the nomination start block number and transaction index.
HoOngEe added a commit to HoOngEe/foundry that referenced this pull request May 19, 2020
It applies the changes in CodeChain-io#388. NextValidators and CurrentValidators
are sorted by public key. As a tiebreaker Candidate and Validator
utilize the nomination start block number and transaction index.
HoOngEe added a commit that referenced this pull request May 19, 2020
It applies the changes in #388. NextValidators and CurrentValidators
are sorted by public key. As a tiebreaker Candidate and Validator
utilize the nomination start block number and transaction index.
Park Juhyung added 2 commits May 20, 2020 14:54
If two validators have the same delegation and deposit, the one who
became the candidate first will be validator first. We didn't change the
rule in this commit. Previously we kept the order of Candidates and
Validators to remember who became the candidate first. Now we are saving
nomination_starts_at variable to remember it.

By saving the nomination_starts_at, we can sort validators using public keys.
Sorting validators using public key makes validator set hash consistent.
@majecty majecty force-pushed the f/fix-validator-set-order branch from 69f2f79 to 50570e1 Compare May 20, 2020 05:55
By sorting the validator set using public keys, we can make validator
set hash consistent.
@majecty majecty force-pushed the f/fix-validator-set-order branch from 50570e1 to ccf8b4b Compare May 20, 2020 05:57
@majecty majecty merged commit df5d7b4 into CodeChain-io:master May 20, 2020
@majecty majecty deleted the f/fix-validator-set-order branch May 20, 2020 07:03
sgkim126 pushed a commit to sgkim126/foundry that referenced this pull request May 23, 2020
It applies the changes in CodeChain-io#388. NextValidators and CurrentValidators
are sorted by public key. As a tiebreaker Candidate and Validator
utilize the nomination start block number and transaction index.
sgkim126 pushed a commit to sgkim126/foundry that referenced this pull request May 23, 2020
It applies the changes in CodeChain-io#388. NextValidators and CurrentValidators
are sorted by public key. As a tiebreaker Candidate and Validator
utilize the nomination start block number and transaction index.
sgkim126 pushed a commit to sgkim126/foundry that referenced this pull request May 23, 2020
It applies the changes in CodeChain-io#388. NextValidators and CurrentValidators
are sorted by public key. As a tiebreaker Candidate and Validator
utilize the nomination start block number and transaction index.
sgkim126 pushed a commit to sgkim126/foundry that referenced this pull request May 23, 2020
It applies the changes in CodeChain-io#388. NextValidators and CurrentValidators
are sorted by public key. As a tiebreaker Candidate and Validator
utilize the nomination start block number and transaction index.
sgkim126 pushed a commit to sgkim126/foundry that referenced this pull request May 24, 2020
It applies the changes in CodeChain-io#388. NextValidators and CurrentValidators
are sorted by public key. As a tiebreaker Candidate and Validator
utilize the nomination start block number and transaction index.
sgkim126 pushed a commit to sgkim126/foundry that referenced this pull request May 24, 2020
It applies the changes in CodeChain-io#388. NextValidators and CurrentValidators
are sorted by public key. As a tiebreaker Candidate and Validator
utilize the nomination start block number and transaction index.
sgkim126 pushed a commit to sgkim126/foundry that referenced this pull request May 24, 2020
It applies the changes in CodeChain-io#388. NextValidators and CurrentValidators
are sorted by public key. As a tiebreaker Candidate and Validator
utilize the nomination start block number and transaction index.
sgkim126 pushed a commit to sgkim126/foundry that referenced this pull request May 24, 2020
It applies the changes in CodeChain-io#388. NextValidators and CurrentValidators
are sorted by public key. As a tiebreaker Candidate and Validator
utilize the nomination start block number and transaction index.
sgkim126 pushed a commit to sgkim126/foundry that referenced this pull request May 24, 2020
It applies the changes in CodeChain-io#388. NextValidators and CurrentValidators
are sorted by public key. As a tiebreaker Candidate and Validator
utilize the nomination start block number and transaction index.
sgkim126 pushed a commit to sgkim126/foundry that referenced this pull request May 24, 2020
It applies the changes in CodeChain-io#388. NextValidators and CurrentValidators
are sorted by public key. As a tiebreaker Candidate and Validator
utilize the nomination start block number and transaction index.
sgkim126 pushed a commit to sgkim126/foundry that referenced this pull request May 30, 2020
It applies the changes in CodeChain-io#388. NextValidators and CurrentValidators
are sorted by public key. As a tiebreaker Candidate and Validator
utilize the nomination start block number and transaction index.
sgkim126 pushed a commit to sgkim126/foundry that referenced this pull request Jun 4, 2020
It applies the changes in CodeChain-io#388. NextValidators and CurrentValidators
are sorted by public key. As a tiebreaker Candidate and Validator
utilize the nomination start block number and transaction index.
sgkim126 pushed a commit to sgkim126/foundry that referenced this pull request Jun 6, 2020
It applies the changes in CodeChain-io#388. NextValidators and CurrentValidators
are sorted by public key. As a tiebreaker Candidate and Validator
utilize the nomination start block number and transaction index.
sgkim126 pushed a commit to sgkim126/foundry that referenced this pull request Jun 6, 2020
It applies the changes in CodeChain-io#388. NextValidators and CurrentValidators
are sorted by public key. As a tiebreaker Candidate and Validator
utilize the nomination start block number and transaction index.
majecty pushed a commit that referenced this pull request Jun 10, 2020
It applies the changes in #388. NextValidators and CurrentValidators
are sorted by public key. As a tiebreaker Candidate and Validator
utilize the nomination start block number and transaction index.
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