Skip to content

Conversation

giunatale
Copy link
Collaborator

@giunatale giunatale commented Jan 14, 2025

iterating over the work started in #16, this PR adds governors to the x/gov module.

More details can be also read in #16

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
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label Jun 20, 2025
@github-actions github-actions bot closed this Jun 26, 2025
@giunatale giunatale removed the Stale label Jul 11, 2025
@giunatale giunatale reopened this Jul 11, 2025
Copy link
Collaborator

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

preliminary review, i haven't check the whole business logic yet.

- The system tracks each governor’s address, description, status (e.g., active),
and last status change time (to limit frequent status toggles).

2. Delegation and Undelegation:
Copy link
Collaborator

Choose a reason for hiding this comment

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

(When I am making this comment I haven't read the implementation yet).

I suppose the governor inherits the votes of whoever delegate to them at proposal execution and not voting right?

Given a proposal passing expects super majority it makes sense I think it is okay to have no timeout or maximum redelegation amount (like you have in normal x/gov due to the x/staking redelegation limitations).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, at proposal tally.

Also, the limitations to x/gov for the canonical module are indeed inherited from the dependency with x/staking that we don't have here. So indeed there is no need to have these limitations in place. The representative voting system can be more "liquid" as a result.

`MsgUpdateGovernorStatus`. Governors that set themselves to inactive are allowed
to delegate their governance voting power to another governor. A status change
can however only occur after a waiting period (`GovernorStatusChangePeriod`).
- Attempts to rapidly change status are disallowed; changes can only occur
Copy link
Collaborator

@julienrbrt julienrbrt Jul 23, 2025

Choose a reason for hiding this comment

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

Can a governor having voted to a current proposal, with users delegated to it change its status during the voting period? If so, should it really?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So you are proposing to prevent a status change if there is at least a proposal active (i.e. in voting period?)

Anyway, it would be the same as validators, that can unbond regardless of the status of proposals. We can further discuss this, but on a first level, what is your concern?

Copy link
Collaborator

@julienrbrt julienrbrt Jul 23, 2025

Choose a reason for hiding this comment

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

My concern is that a governor can abruptly become inactive during a vote, or right before the voting period ends, meaning their delegators that didn't vote because their delegators had voted and no more represented.
It could even change the proposal outcome in some very close scenario.

I agree that a waiting period is required, but instead of having it "in between", i'd instead queue that change for the waiting period duration.
So for any change, force the waiting period before the change takes place, not depending if you have just changed your status or if you waited a long time.
Right now, if you changed a long time ago, the change would be instant.

Copy link
Collaborator

@tbruyelle tbruyelle Sep 24, 2025

Choose a reason for hiding this comment

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

@julienrbrt Similarly, a governor can change this vote, which might also change the outcome of the proposal.
Given that, I'm not sure we should try to delay or prevent a change in his status.

Same for validators, a validator can be rejected from the set or being tombstoned, which immediately affects the votes (for other chains).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, @tbruyelle brings up a great point. I think it's ok to leave the system as is for this reason. Moreover, even if we wanted to change it (something which I actually worked on), we would have the issue of having to also prevent staking undelegations which bring the bonded amount below the min stake requirement, otherwise that would also be a way to bypass the queued change. And in practice the hooks do not allow to distinguish between an undelegation and a redelegation, which make doing this very challenging.

For the reason above and the observation from Thomas, I think it's better if we keep this as is

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe a good exercice to use collections here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Aside from the exercise what would be the benefit of using collections here exactly? Don't get me wrong this is a genuine question I don't know the answer to and would like to understand

Copy link
Collaborator

Choose a reason for hiding this comment

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

less boilerplate basically, you define the collections in the keeper and you do not need this whole boilerplate of getters and setters.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I love collections, it is great piece of work. It has just the required abstraction to make dev life easier w/o losing control. That said, to use it for governor we need to wait for SDK50 merge (or to use the port I made for onchain multisig, but that's not reasonnsable since sdk50 upgrade is close ^^)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The x/gov module in main is not in sync with the v0.50 one, it is not using collections . We need to update it so that using collections for delegations and governors is aligned with the rest. Otherwise tbh it would look a pretty ugly frankenstein.

https://github.com/atomone-hub/atomone/blob/main/x/gov/keeper/keeper.go#L20 vs https://github.com/atomone-hub/cosmos-sdk/blob/release/v0.50.x/x/gov/keeper/keeper.go#L21 makes it evident as the keeper does not contain the collections, and they aren't used anywhere contrary to the v0.50 version.

@julienrbrt do you mind working on it?

cc @tbruyelle

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For the time being, I won't be using collections. Once #217 is addressed, I will update this PR accordingly

Copy link
Collaborator

Choose a reason for hiding this comment

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

I commented #217 (comment)

@julienrbrt
Copy link
Collaborator

im realizing now that will have to come too to my gigantic PR 😅

@giunatale
Copy link
Collaborator Author

im realizing now that will have to come too to my gigantic PR 😅

I will deal with it, once the gov module update is done I will adapt this PR to port the governors.
It will definitely will be painful, but it is what it is

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.

3 participants