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

[DON'T MERGE] feat(x/gov): add governors #16

Draft
wants to merge 47 commits into
base: main
Choose a base branch
from

Conversation

giunatale
Copy link
Collaborator

@giunatale giunatale commented Sep 17, 2024

  • You can only delegate to a single governor, and 100% of your governance VP or nothing, but you can always override the vote.
  • Governors election is done on "estimated" VP exactly like validators, so only top X (configurable param) active governors by VP are counted for voting
  • Governors can set their status between active and inactive but can change it only once every 4 weeks. Active governors can be elected (inactive governors are skipped) but the base account has automatically a self-delegation of all its VP to the governor and cannot redelegate. Inactive governors can re-delegate.
  • Governors VP is "estimated" (I think it's an exact computation as I think I cover everything) using x/staking hooks so when slashing/bond/unbond/redel happen it triggers a VP update.
  • It should be ok computationally and also ok in how data is stored for easy retrieval, however maybe not optimized for storage itself as there is the need for a couple of additional indexes. Need to also check how much the governor VP computation is accurate because it might allow to further simplify VP computation (skip part of it) in tally
  • I also added an invariant but I am not sure how that impacts performance
  • Currently missing all tests, code is also itself untested, it was a weekend project. No guarantees on quality or if it works at all (or as intended).

Based on discussions as recorded in https://gist.github.com/giunatale/95e9b43f6e265ba32b29e2769f7b8a37

EDIT:

  • Governors need to have at least minSelfDelegation (param) tokens bonded in x/staking to be elegible for tally (active governors always require to "self-delegate" the governance VP from their base account)
  • Added another invariant on governors delegations consistency with cumulative virtual validator shares stored

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
x/gov/keeper/tally.go Dismissed Show resolved Hide resolved
x/gov/keeper/tally.go Fixed Show fixed Hide fixed
x/gov/keeper/invariants.go Fixed Show fixed Hide fixed
@giunatale
Copy link
Collaborator Author

giunatale commented Sep 25, 2024

An alternative system that does not make use of the aggregate VP is also available at:

In brief:

  • It removes the aggregate VP (and related indexing) for governors, so no need to loop over all involved governors in the slashing hook (which is removed here)
  • Governor election is simplified to happen only among governors that voted, so if a governor had a lot of delegations but did not vote it basically gave up its spot. Actually since there is no need to limit the number of governors with this system the max governors param is removed. Only account for active governors that voted and meet the minimum self delegation requirement.
  • Since there is no aggregate VP number, the optimization for quorum is not possible

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.

1 participant