Skip to content

feat(x/gov): dynamic quorum #135

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

Merged
merged 24 commits into from
Jun 16, 2025
Merged

feat(x/gov): dynamic quorum #135

merged 24 commits into from
Jun 16, 2025

Conversation

tbruyelle
Copy link
Collaborator

@tbruyelle tbruyelle commented May 12, 2025

Instead of having a fixed quorum from the parameters, the quorum is adjusted between 2 bounds, given the proposal vote's participation.

TODO:

  • merge main
  • migrate params.LawQuorum and params.ConstitutionAmendmentQuorum to new dynamic model
  • fix types.NewParams to remove deprecated params
  • address Params query that returns the dynamic quorum in TallyParams but the deprecated quorum value in the params struct itself (see also in x/gov/client/cli/query.go)
  • Migration to init the values of new parameters (min/max quorum and participation for each kind of kind of proposal)
  • use specific participation for constitution amendment and law proposals
  • instead of adding a new Quorum query, consider adding a quorum field to the proposal response (but that could break the compatibility)
  • add missing CLI for quorum query (if we decide to keep it and not adding new field in proposal response)
  • docs: the genesis EMA fields need to be set careful because they will define the initial quorums for the proposals.
  • unit tests
  • ADR
  • e2e tests
  • Add section in gov module README

@giuliostramondo giuliostramondo self-assigned this May 14, 2025
@tbruyelle tbruyelle force-pushed the giunatale/gov/dynamic-quorum branch from ce6987a to 5a79faf Compare June 8, 2025 12:10
Copy link
Collaborator

@giunatale giunatale left a comment

Choose a reason for hiding this comment

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

I would like to see the EMAs as separate per different proposals types, not just the quorum values. So if a proposal is a law or an amendment they contribute to that specific ema otherwise they contribute to the default one

Comment on lines 354 to 369
string max_quorum = 26 [(cosmos_proto.scalar) = "cosmos.Dec"];

// Minimum achievable quorum
string min_quorum = 27 [(cosmos_proto.scalar) = "cosmos.Dec"];

// Maximum achievable quorum for constitution amendment proposals
string max_constitution_amendment_quorum = 28 [(cosmos_proto.scalar) = "cosmos.Dec"];

// Minimum achievable quorum for constitution amendment proposals
string min_constitution_amendment_quorum = 29 [(cosmos_proto.scalar) = "cosmos.Dec"];

// Maximum achievable quorum for law proposals
string max_law_quorum = 30 [(cosmos_proto.scalar) = "cosmos.Dec"];

// Minimum achievable quorum for law proposals
string min_law_quorum = 31 [(cosmos_proto.scalar) = "cosmos.Dec"];
Copy link
Collaborator

Choose a reason for hiding this comment

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

wouldn't it be better to have a struct with both caps inside for each quorum? (like for dynamic deposit) instead of separate min/max params?

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, what about embedding the threshold as well ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hmm that will break the API if we embed the threshold

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok but I still don't see the two params in a single struct though :P

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 I didn't forget but given the ongoing audit I think it's preferrable to merge this now and address this after the audit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I created an issue to track the remaining work #145

@giunatale
Copy link
Collaborator

giunatale commented Jun 9, 2025

Moreover, we need a starting value in genesis for the 3 quorums, not just the EMAs (which for a fresh chains are 0). Unless we use the EMAs as starting values, but that's kinda confusing imho. Maybe it could be ok to rely on the EMAs as starting values (since otherwise we would need a separate genesis value and that gets messy probably) but we should make it explicit also in the comments that the EMA should be non-zero for a fresh chain and error in case it's 0

@tbruyelle
Copy link
Collaborator Author

I would like to see the EMAs as separate per different proposals types, not just the quorum values. So if a proposal is a law or an amendment they contribute to that specific ema otherwise they contribute to the default one

Yes, this is part of the TODOs in the PR body.

@tbruyelle
Copy link
Collaborator Author

Moreover, we need a starting value in genesis for the 3 quorums, not just the EMAs (which for a fresh chains are 0). Unless we use the EMAs as starting values, but that's kinda confusing imho. Maybe it could be ok to rely on the EMAs as starting values (since otherwise we would need a separate genesis value and that gets messy probably) but we should make it explicit also in the comments that the EMA should be non-zero for a fresh chain and error in case it's 0

Good point. On the other hand, if you start a chain with 0 EMA, you just end up with the minQuorum value for the quorum, that's not catastrophic. But I agree this needs to be well documented. Adding this in the TODO list.

@tbruyelle
Copy link
Collaborator Author

@giunatale I think we're good with that PR, let's address the e2e tests and the README update later.

@tbruyelle tbruyelle marked this pull request as ready for review June 12, 2025 16:57
Copy link
Collaborator

@giunatale giunatale left a comment

Choose a reason for hiding this comment

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

It looks good except for my comment about merging the min/max

@giunatale
Copy link
Collaborator

should be good now, I am fine if the last two points of #145 aren't yet addressed since they don't modify the core logic at all (tests and the readme should not matter in that sense). Thanks for taking care of adding the ranges

@giunatale giunatale merged commit 512ff6d into main Jun 16, 2025
14 checks passed
@tbruyelle tbruyelle deleted the giunatale/gov/dynamic-quorum branch June 17, 2025 08:30
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