-
Notifications
You must be signed in to change notification settings - Fork 20
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
consortium: implement rotating validators #412
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
minh-bq
force-pushed
the
feat/rotating-validator
branch
from
March 11, 2024 06:08
9b21fa1
to
40b4198
Compare
minh-bq
force-pushed
the
feat/rotating-validator
branch
2 times, most recently
from
April 22, 2024 08:27
765982e
to
178c382
Compare
minh-bq
force-pushed
the
feat/rotating-validator
branch
from
May 20, 2024 09:52
0288c95
to
c2ce3ed
Compare
* consortium-v2: implement RLP encoding for header extra data * consortium-v2: integrate new RLP encoder/decoder for header extra data * consortium-v2: optimize extra data rlp encoding * consortium-v2: benchmark for new rlp encoding * consortium-v2: clean up unit test --------- Co-authored-by: Bui Quang Minh <minh.bui@skymavis.com>
Currently, only block producers can participate in voting process. However, after Tripp, vote permission is granted to a wider range of validator candidates (up to 64). Therefore, this PR differentiates block producers from validator candidates and enables logic for wider voter set. Moreover, voter weight is also introduced in order to determine reward distribution for every eligible candidates. Voter weight is computed based on candidates's staked amounts, according to the formula represented in: https://github.com/phuctd95/REPs/blob/main/REP-0010/REP-0010.md. Additionally, after Tripp, the logic for getting validator set is also changed such that: At the start of period, the first checkpoint block after 00:00 UTC, the list of validator candidates will be get from the contract once for whole period (~1 day). At the start of epoch, the list of block producers will be get from the contract once for every epoch (~10 minutes). * consortium-v2: make finality vote weight proportional to staked amount Currently, the finality vote weights of all validators are the same. After this commit, the finality vote weight is based on the staked amount of the validator. The rule of finality vote weight follows what is stated in REP-0010: Introducing Rotating Validators - If the staked amount of a validator is smaller than or equal to 1/22 of total stake, the weight is directly proportional to the staked amount. - If the staked amount of a validator is bigger than 1/22 of total stake, the weight equals 1/22 of total stake. * consortium-v2: add period concept After Tripp, the number of voters for finality block increases and the set of voters is changed at the first checkpoint block of the new day (in UTC time); therefore, it is necessary to introduce Period concept- the first checkpoint block after the 00:00 UTC time. * consortium-v2: get validator candidates from contract Before, only block producers can vote for finality block. However, after Tripp, most of validator candidates can participate in voting process. Hence, this commit provides function to query validator candidates from smart contract. * consortium-v2: add list of block producers and staked amount of validators to extra data Add two fields to header extra data and fix rlp encoder/decoder to accommodate these fields. * consortium-v2: add logic to get validators based on period and epoch After Tripp, validator candidates are read only once at the start of new period, whereas block producer address is read at the start of every epoch. * fix: replace deep copy with assignment and remove sig equality * consortium-v2: use vote weight in validatorWithBlsPub, rename some functions * consortium-v2: add assembleFinalityVote test, remove rlp optional tag * consortium-v2: update logic checking period block As recursively finding previous epoch is expensive, we provide to store the current period in the snapshot, speeding up reading past current period. In case the past snapshot with absent current period, we retrieved in recursive manner. * consortium-v2: update the NormalizeFinalityVoteWeight * fix: add more check to verifyCascadingFields and log for period check * consortium-v2: make finality vote change effective after Tripp period The finality vote rule change is not effective right after Tripp hardfork but at the start of following period. This commit adds TrippPeriod config to set period of TrippBlock, the finality vote rule change is effective after the current period is higher than that number. * fix: compute isShillin once and remove unnecessary check in encoder * chore: fix float number and add unit test for checking tripp block --------- Co-authored-by: Bui Quang Minh <minh.bui@skymavis.com>
…eader (#447) After Tripp is effective, the checkpoint validators in header's extra data is set only at the period block, not at all checkpoint blocks anymore. So only update snapshot's validator with bls public key when checkpoint validator is not empty.
#449) * consortium-v2: define MarshalJSON on a non-pointer ValidatorWithBlsPub We want json.Marshal to invoke our custom MarshalJSON when be called with non-pointer ValidatorWithBlsPub. In order to do that, we need to define MarshalJSON on a non-pointer receiver. * consortium-v2: add missing weight field to our customized json marshal
…425) * consortium-v2: support consensus address change in profile contract This commit adds a step to query profile id from consensus address to support the consensus change feature. It also switches the function call to get BLS public key to another function due to the breaking change in getId2Profile. * consortium/contract: create contract call helper function Make the contract call a helper function to clean up the code. * consortium-v2: pass **big.Int into contract call's output The maxValidatorNumber returns a *big.Int as an output. In order to get the output value, we must pass an **big.Int to the contratCall not *big.Int. Co-authored-by: andicrypt <keepgoing0901@gmail.com> * consortium-v2: add unit tests for new contract call functions --------- Co-authored-by: andicrypt <keepgoing0901@gmail.com>
minh-bq
force-pushed
the
feat/rotating-validator
branch
from
May 21, 2024 10:19
c2ce3ed
to
6821b38
Compare
andicrypt
approved these changes
May 21, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This branch is used for rotating validators development