-
Notifications
You must be signed in to change notification settings - Fork 10
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(x/gov): add governors #73
base: main
Are you sure you want to change the base?
Conversation
Only sketching out how the tally would work for now. Lots of stuff is left undefined but the strategy is the one outlined in https://gist.github.com/giunatale/95e9b43f6e265ba32b29e2769f7b8a37?permalink_comment_id=5067400#gistcomment-5067400 but with the restriction of being able to delegate a percentage of its bonded tokens to at most one governor (https://gist.github.com/giunatale/95e9b43f6e265ba32b29e2769f7b8a37?permalink_comment_id=5187246#gistcomment-5187246) It assumes that every time someone redelegates, undelegates or adds to its delegations a hook is called to check if there is a governor delegated to in x/gov, and the governor's total shares updated accordingly. The governor's total shares are a collection of share amounts for different validators.
can only delegate all or nothing to governors now
change also the governors election logic, now only voting governors are counted removes a lot of logic that could cause performance issues
no need to limit governors number, all voting governors are counted
* test: keeper governor * test: ValidateGovernorMinSelfDelegation * test: governance delegation * perf: check IsActive first * chore: remove deprecated maxGovernors
since this work was left untouched for a while, we need to give it a final pass to identify potentially missing tests and check test coverage, and add documentation. Ideally we would also want to do some more in depth profiling/benchmarking to assess the performance impact of this addition. |
for _, govInfo := range allGovernors { | ||
governor, _ := k.GetGovernor(ctx, govInfo.Address) | ||
|
||
if k.ValidateGovernorMinSelfDelegation(ctx, governor) && len(govInfo.Vote) > 0 { | ||
governorsInfos = append(governorsInfos, govInfo) | ||
} | ||
} |
Check warning
Code scanning / CodeQL
Iteration over map Warning
for valAddrStr, shares := range governor.ValShares { | ||
if val, ok := currValidators[valAddrStr]; ok { | ||
sharesAfterDeductions := shares.Sub(governor.ValSharesDeductions[valAddrStr]) | ||
votingPower = votingPower.Add(sharesAfterDeductions.MulInt(val.GetBondedTokens()).Quo(val.GetDelegatorShares())) | ||
} | ||
} |
Check warning
Code scanning / CodeQL
Iteration over map Warning
|
||
// GovernanceDelegation queries a delegation | ||
rpc GovernanceDelegation(QueryGovernanceDelegationRequest) returns (QueryGovernanceDelegationResponse) { | ||
option (google.api.http).get = "/atomone/gov/v1/delegations/{delegator_address}"; |
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 would rather see singular delegation
here, as it will always return a single.
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.
This is for consistency, the plural is used in other places too (e.g. proposals)
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.
Understandable, then the first one /atomone/gov/v1/governor/{governor_address}
should be /atomone/gov/v1/governors/{governor_address}
?
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.
but also e.g. validator info for a single validator in x/staking is "validators/{validator-address}"
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.
Understandable, then the first one
/atomone/gov/v1/governor/{governor_address}
should be/atomone/gov/v1/governors/{governor_address}
?
yes
* add governors adr * Update docs/architecture/adr-004-governors.md Co-authored-by: Thomas Bruyelle <[email protected]> --------- Co-authored-by: Thomas Bruyelle <[email protected]>
* add governors documentation * add txs in CLI section
The gov module InitGenesis must happen after staking because governors requires to access the validator delegations.
* perf(x/gov): remove useless bech32 conversion Accessing `delegation.ValidatorAddress` is similar to calling `delegation.GetValidatorAddress().String()` but w/o useless conversions. * perf(x/gov): remove useless address conversion * perf(x/gov): remove useless bech32 conversion * perf(x/gov): remove unused active field from GovernorGovInfo * perf(x/gov): assume vote weight is 1 most of the time
iterating over the work started in #16, this PR adds governors to the x/gov module.
More details can be also read in #16