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

docs: ADR 069 - x/gov modularity, multiple choice and optimistic proposal #18498

Merged
merged 12 commits into from
Nov 30, 2023

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented Nov 17, 2023

Description

ref: #14403, #17781

RENDERED

Follow the ADR implementation along: https://github.com/orgs/cosmos/projects/26/views/36


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • run make lint and make test
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

Summary by CodeRabbit

  • Documentation
    • Added ADR 069 detailing enhancements to the x/gov module, including the introduction of multiple choice and optimistic proposals, new voting options, and updated tallying methods.
    • Outlined potential consequences and compatibility considerations for the proposed governance changes.

@julienrbrt julienrbrt requested a review from a team as a code owner November 17, 2023 16:34
Copy link
Contributor

coderabbitai bot commented Nov 17, 2023

Note

Reviews Paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Walkthrough

The Cosmos SDK's x/gov module is being enhanced with the addition of ADR 069, which introduces multiple choice and optimistic proposals, a new "SPAM" vote option, and changes to the tallying method. These updates aim to improve governance mechanisms by providing more flexibility and addressing potential governance spam.

Changes

File Path Change Summary
docs/architecture/README.md Added ADR 069: "x/gov modularity, multiple choice, and optimistic proposals".
docs/architecture/adr-069-gov-improvements.md Introduced multiple choice and optimistic proposals, new voting options including "SPAM", changes to tallying methods, and new governance parameters in the x/gov module.

🐇 In the Cosmos, where stars align, 🌌
A new ADR comes to shine. ✨
With choices more and spam votes less,
Governance blooms in spring's caress. 🌸


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c0ebebb and add0a1c.
Files selected for processing (2)
  • docs/architecture/README.md (1 hunks)
  • docs/architecture/adr-069-gov-improvements.md (1 hunks)
Files skipped from review due to trivial changes (1)
  • docs/architecture/README.md
Additional comments: 1
docs/architecture/adr-069-gov-improvements.md (1)
  • 1-200: The ADR 069 draft provides a comprehensive overview of the proposed enhancements to the x/gov module in the Cosmos SDK. The introduction of multiple choice and optimistic proposals, along with the new SPAM vote option, are significant changes that aim to improve the governance process within the Cosmos ecosystem. The ADR also outlines the necessary adjustments to the proposal tallying method and governance parameters to accommodate these new features.

Here are some specific points to consider:

  • The addition of ProposalType to the v1.Proposal struct (lines 42-52) is a good approach to extend the functionality without introducing breaking changes. However, it's important to ensure that all existing code that interacts with v1.Proposal is compatible with this change.

  • The concept of optimistic proposals (lines 61-75) is interesting, but it's crucial to ensure that the governance parameters for these proposals are well-documented and understood by the community to prevent any misuse or confusion.

  • The limitation of four voting options for multiple choice proposals (lines 79-85) seems reasonable to keep the voting process manageable. However, the introduction of the SPAM vote option (lines 108-116) could have significant implications for governance, as it introduces a new dynamic to the voting process. It's important to clearly define what constitutes SPAM and ensure that the community is aligned on its usage.

  • The changes to the voting options and the tallying method (lines 120-150) will require careful implementation to maintain backward compatibility and ensure that the new system is robust and secure.

  • The ADR acknowledges the impact on client applications (lines 155-157) and the need for backward compatibility (lines 159-165). It's important to provide clear migration paths and support for client developers to adapt to these changes.

  • The ADR mentions further discussions and potential future improvements to the x/gov module (lines 180-185). It would be beneficial to track these discussions and ensure that any subsequent changes are consistent with the goals outlined in this ADR.

Overall, the ADR seems to be a well-thought-out proposal that could significantly enhance the governance capabilities of the Cosmos SDK. It's important to ensure that the community is involved in the discussion and that there is clear documentation and support for implementing these changes.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between add0a1c and 570547c.
Files selected for processing (1)
  • docs/architecture/adr-069-gov-improvements.md (1 hunks)
Additional comments: 1
docs/architecture/adr-069-gov-improvements.md (1)
  • 1-200: The ADR is well-structured and provides a comprehensive overview of the proposed enhancements to the x/gov module. The introduction of multiple choice and optimistic proposals, along with the new SPAM vote option, are significant changes that aim to improve the flexibility and responsiveness of the governance process.
  • The addition of optimistic_authorized_addresses and optimistic_rejected_threshold parameters (lines 69-74) should be carefully reviewed to ensure they align with the intended permission and security model.
  • The limitation of four options for multiple choice proposals (line 81) seems reasonable to prevent decision fatigue and maintain clarity, but it's important to ensure that this limit is well-justified and documented.
  • The introduction of a SPAM vote (lines 108-116) is an interesting approach to filter out non-serious proposals, but the mechanism for penalizing incorrect SPAM votes (line 116) should be clear and fair to avoid deterring participation.
  • The renaming of vote options to accommodate multiple choice proposals (lines 120-129) and the attempt to make these changes non-breaking (line 132) are important for maintaining backward compatibility.
  • The custom tallying function interface (lines 144-150) adds modularity, but it's crucial to ensure that the implementation details are secure and do not introduce any vulnerabilities.
  • The backward compatibility section (lines 159-165) acknowledges the impact on legacy systems, which is important for a smooth transition.
  • The further discussions section (lines 180-187) indicates ongoing development and potential future changes, which stakeholders should be aware of.

Overall, the ADR seems to address the community's needs and requests effectively while also considering the implications of the changes. It's important to ensure that the proposed features are implemented securely and that they integrate well with the existing system.

@julienrbrt
Copy link
Member Author

@coderabbitai pause

@alexanderbez alexanderbez self-assigned this Nov 17, 2023
docs/architecture/adr-069-gov-improvements.md Outdated Show resolved Hide resolved
docs/architecture/adr-069-gov-improvements.md Outdated Show resolved Hide resolved
docs/architecture/adr-069-gov-improvements.md Outdated Show resolved Hide resolved
docs/architecture/adr-069-gov-improvements.md Outdated Show resolved Hide resolved
docs/architecture/adr-069-gov-improvements.md Show resolved Hide resolved
// optimistic_authorized_addreses is an optional governance parameter that limits the authorized accounts than can submit optimisitc proposals
repeated string optimistic_authorized_addreses = 17 [(cosmos_proto.scalar) = "cosmos.AddressString"];

// Optimistic rejected threshold defines at which percentage of NO votes, the optimistic proposal should fail and be converted to a normal proposal.
Copy link
Contributor

Choose a reason for hiding this comment

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

Are optimistic props subject to the same VP? So if enough NO votes come in at the last second, it then gets converted to a normal prop and the entire VP starts again?

Copy link
Member Author

Choose a reason for hiding this comment

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

There will be just one option, which will be no. So nothing can come second. You won't be able to vote yes or abstain.

julienrbrt and others added 3 commits November 17, 2023 19:46
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

A multiple choice proposal is a proposal where the voting options can be defined by the proposer.

The number of voting option will be limited to a maximum of 4. A new vote option `SPAM` will be added and distinguished of those voting options.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why limit to 4? I agree with limiting the number of options, but why not 6 or 8?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I think I got it, this is because you want to keep the existing tally function which only handles 4 options.

Copy link
Member Author

Choose a reason for hiding this comment

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

That would indeed simplify everything if we keep it 4, but we can maybe consider increasing it, if it is really wanted.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if it's really wanted, but for sure this is a smart way to bring the feature with minimal changes 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it really depends how this feature would be practically used.

Have you guys thought of some example proposals that would be suited to use the multiple choices and how they may fit within the 4 options limits? Maybe worth providing these examples in the ADR (just a bulleted list)?

Off the top of my head, I could see e.g. voting on electing group of peoples for some task. And the options might be different sets of candidates, in which case limiting it to 4 kinda makes sense since I assume we also want to not overwhelm the voters.

I also like the fact that we are reusing the existing VoteOption a lot. No point in adding complexity if not needed.

I am missing an aspect, how do you handle the case when the proposer wants to have less than 4 options, say 3?

Copy link
Member Author

@julienrbrt julienrbrt Nov 23, 2023

Choose a reason for hiding this comment

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

This feature will be used for signaling proposals (given that a multiple choice won't execute any message).
This leaves to many possibilities: choosing the canonical bridge for a chain, elections as you said, or surveys (hopefully not too much 😅),..

Voting on multiple choice proposal will make an extra query to get the options. That way, we will be able to refuse non set options.

Copy link
Contributor

Choose a reason for hiding this comment

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

This feature will be used for signaling proposals (given that a multiple choice won't execute any message).

Yeah, I appreciated a lot that this is just for text proposals.

This leaves to many possibilities: choosing the canonical bridge for a chain, elections as you said, or surveys (hopefully not too much 😅),..

Right, and if the community is civil enough they should be able to boil down the final choices to go on-chain to a max of 4 using forum discussions.

He knew it

Jokes aside, I think it's better to implement the feature reusing as much of the existing as possible for now as you are planning. We don't need to overcomplicate things unless there's an explicit need, and until this feature is out and tested in the field we can't really know.

Voting on multiple choice proposal will make an extra query to get the options. That way, we will be able to refuse non set options.

This makes sense, thanks.

Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

This is great and very much needed. Thanks @julienrbrt and @tac0turtle for the work here!

I suggest restructuring the Proposals section in the same order as the proposal types, i.e first sub-section for standard text proposal, second for multiple choice, etc.

I also added a bunch of comments for things that didn't have context (eg. mentioning the SPAM vote option without introducing the concept or context). I suggest adding more context for first-time readers of this ADR.

Happy to also provide eng resources in this initiative once it's approved

docs/architecture/adr-069-gov-improvements.md Outdated Show resolved Hide resolved
Comment on lines 48 to 50
> An expedited proposal is by design a normal proposal with a quicker voting period and higher threshold. When an expedited proposal fails, it gets converted to a normal proposal.

An expedited optimistic proposal and an expedited multiple choice proposal do not make sense based on the definition above and is a proposal type instead of a proposal characteristic.
Copy link
Collaborator

Choose a reason for hiding this comment

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

curious why these don't have their corresponding sections

Copy link
Member Author

@julienrbrt julienrbrt Nov 20, 2023

Choose a reason for hiding this comment

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

This one already exists, this is for context. I can add a section if you think it is clearer.


Note, that expedited becomes a proposal type itself instead of a boolean on the `v1.Proposal` struct.

> An expedited proposal is by design a normal proposal with a quicker voting period and higher threshold. When an expedited proposal fails, it gets converted to a normal proposal.
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you define an expedited proposal with the same threshold?

Copy link
Collaborator

Choose a reason for hiding this comment

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

it gets converted to a normal proposal.
Does this mean that it continues to be open for voting until the end of the voting period?

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently, if an expedited proposal fails it becomes a standard proposal:

case proposal.Expedited:

We are proposing to do the same for rejected optimistic proposals

docs/architecture/adr-069-gov-improvements.md Outdated Show resolved Hide resolved
docs/architecture/adr-069-gov-improvements.md Show resolved Hide resolved
docs/architecture/adr-069-gov-improvements.md Outdated Show resolved Hide resolved

However, chains may want to change the tallying function (weighted vote per voting power) of `x/gov` for a different algorithm (using a quadratic function on the voter stake, for instance).

The custom tallying function can be passed to the `x/gov` keeper with the following interface:
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is extremely useful

The custom tallying function can be passed to the `x/gov` keeper with the following interface:

```go
type Tally interface{
Copy link
Collaborator

Choose a reason for hiding this comment

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

I need to think a bit more of what exactly we need but at a high level you should be able to process a custom result with the voting power that has voted so far

Copy link
Member

Choose a reason for hiding this comment

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

at a high level you should be able to process a custom result with the voting power that has voted so far

could you elaborate here? I dont understand what you mean

docs/architecture/adr-069-gov-improvements.md Outdated Show resolved Hide resolved
docs/architecture/adr-069-gov-improvements.md Outdated Show resolved Hide resolved
Comment on lines +106 to +107
A proposal is marked as `SPAM` when the total of weighted votes for all options is lower than the amount of weighted vote on `SPAM`
(`spam` > `option_one + option_two + option_three + option_four` = proposal marked as spam).
Copy link
Contributor

Choose a reason for hiding this comment

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

Is tallying done at the end of the VP (EndBlock)?

Copy link
Member Author

@julienrbrt julienrbrt Nov 20, 2023

Choose a reason for hiding this comment

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

Yes. Tallying stays in end blocker in this ADR. Future improvements will attempt to make it lazy.
As it's an implementation detail I don't think we need to cover it here.

However we do need methods in the tally interface for that.

julienrbrt and others added 2 commits November 20, 2023 20:54
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

#### Multiple Choice Proposal

A multiple choice proposal is a proposal where the voting options can be defined by the proposer.
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not really a fan of the fact that the options can only be set by the proposer. It relies on the proposer being fair in setting them. But definitely doing anything different would add a lot of complexity and it's not guaranteed to have any benefit.

A voter that is not agreeing with any option - and want none of them to pass - but does not want to abuse the SPAM vote can only choose to not vote, and try to keep the quorum lower than the threshold.
Maybe this is enough, but maybe not?

Copy link
Member Author

@julienrbrt julienrbrt Nov 23, 2023

Choose a reason for hiding this comment

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

When we first thought about it I thought the same. We thought of adding a blank vote option, but eventually decided to let that as well for the proposer to specify.

Usually, chains have an off chain process for before submitting a proposal. The voting option discovery should be done there and if someone decides to skip that process, it makes sense to consider the proposal as spam.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, the voting option discovery should be done on the forum, completely agree with that, and ideally it's what makes the most sense.
I am just a little skeptical that it'll work like this all the times, and it might be very controversial when it doesn't.

Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

looks good to me. I believe we will modify the adr once we get to pulling apart the tally function.

// to be decided

// Calculate calculates the tally result
Calculate(proposal v1.Proposal, govKeeper GovKeeper, stakingKeeper StakingKeeper) govv1.TallyResult
Copy link
Contributor

Choose a reason for hiding this comment

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

I think Tally could be simplified to Tally(ctx context.Context, govKeeper GovKeeper, prop v1.Proposal) (govv1.TallyResult, error)

I assume Tally could be a module's keeper implementing this interface and already holding within it other keepers besides gov. Passing GovKeeper in instead of having it in the tally implementer avoids circular dependencies between the tally interface and gov itself.

Copy link
Member Author

@julienrbrt julienrbrt Nov 29, 2023

Choose a reason for hiding this comment

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

The GovKeeper does not have the other keepers it uses public.
Which I think is good, we will be able to remove staking from the gov keeper as well altogether because it is only used for tallying.

Copy link
Contributor

@testinginprod testinginprod left a comment

Choose a reason for hiding this comment

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

LGTM. nice job!

@julienrbrt
Copy link
Member Author

We've had multiple offline confirmation that the ADR makes sense. I will merge it now. Other ADR PRs (extending this one, or new ADRs) will pop up eventually for improving gov further (most probably for #18595 and #14291).

Thank you everyone for your comments here, it was very useful!

@julienrbrt julienrbrt added this pull request to the merge queue Nov 30, 2023
Merged via the queue into main with commit 71876bb Nov 30, 2023
51 of 53 checks passed
@julienrbrt julienrbrt deleted the julien/adr branch November 30, 2023 11:14

#### Optimistic Proposal

An optimistic proposal is a proposal that passes unless a threshold a NO votes is reached.
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the intended use case?

Copy link
Member Author

Choose a reason for hiding this comment

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

A chain can decide how they want to use it (given the possibility to restrict proposers).
However, we can think of it as a way to alleviate governance burden for recurring proposals or any boring proposals where no governance discussion needs to be involved. In the case of Osmosis, that would be periodic incentive updates for example. I have no example for the Hub however 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants