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

feat(mainnet): add gov: collective, membership, motion #448

Merged
merged 39 commits into from
Feb 14, 2025
Merged

Conversation

peterwht
Copy link
Collaborator

@peterwht peterwht commented Jan 23, 2025

Adds a Council based governance that:

  • Has NO elections (selected councillors, to start)
  • Han NO membership pallet.
  • Uses pallet-motion to allow council to use Root origin.

  • Relevant configuration:

  • AtLeastThreeFourthsOfCouncil: at least 3/4 * total seats are aye votes.

  • UnanimousCouncilVote: 100% of the votes are aye votes.

  • pallet_collective

type DefaultVote = MoreThanMajorityThenPrimeDefaultVote;
type DisapproveOrigin = EnsureRoot<AccountId>;
type KillOrigin = EnsureRoot<AccountId>;
type SetMembersOrigin = EnsureRoot<AccountId>; // <-- This is the only way to modify the members of council.
  • pallet_motion

This pallet is how for the council achieves dispatch with Root origin.

// Simple majority is disabled.
type SimpleMajorityOrigin = NeverEnsureOrigin<()>;
// At least 3/4 of the council vote is needed.
type SuperMajorityOrigin = AtLeastThreeFourthsOfCouncil;
// A unanimous council vote is needed.
type UnanimousOrigin = UnanimousCouncilVote;

To familiarize yourself with this governance mechanism, please use the following guide.

Guide

Goal Checklist

  • Create a Motion that requires Root
    • Vote on Motion
    • Execute Motion

Create a Motion that requires Root

  1. Launch chain pop up parachain -f networks/mainnet.toml
  2. Navigate to Council page and note Members
  3. Navigate to sub-page for Motions
  4. Press "Propose Motion"
  5. Min threshold is currently 1/2 + 1. I recommend setting threshold to 4 (unanimous)
  6. Set the proposal call to motion.unanimous, providing Root origin
  7. Set the sub-call to something that requires Root. One recommendation is to use balances.forceSetBalance
  8. You will see a council.Proposed event
  9. On the Motions page you will see a new Motion available for vote, along with proposal info
  10. Press the Vote button and vote AYE. Repeat this with 4 dev accounts
  11. After the threshold is surpassed, the Vote button now changes to Close. Press this button and submit. The proposal is now passed! You will see several events such as council.voted, council.Approved, council.Executed

Screenshot 2025-01-23 at 10 10 07 AM


Notes

  • One important thing to confirm for ANY governance we choose: do we have to pay DOT to propose a runtime upgrade. This can be costly if so.

  • By removing the membership pallet the way to change the members of the council is via dispatching the call council.set_members, which requires Root origin, hence needs to be wrapped in a motion and approved via super majority or unanimous vote.

node/src/chain_spec.rs Outdated Show resolved Hide resolved
@peterwht
Copy link
Collaborator Author

[sc-2571]

@al3mart
Copy link
Collaborator

al3mart commented Jan 24, 2025

image

Polakdot js apps seems to crash after inputting an external motion 😓 with the expectation of pallet_democracy being present ?

For the record the call I noted as a preimage was balances.forceSetBalance.

I'd assume this is expected as the runtime doesn't feature a way for non council members to cast votes. I think the app will have just wrapped the noted call as a democracy call.
Though is just ugly that the app presents that message.

Copy link
Collaborator

@al3mart al3mart left a comment

Choose a reason for hiding this comment

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

The inclusion of these seemed like a sensible choice. Provides a little better UX for the accounts voting on the motions.

Also seems more flexible looking ahead.

runtime/mainnet/src/config/governance.rs Outdated Show resolved Hide resolved
runtime/mainnet/src/config/governance.rs Outdated Show resolved Hide resolved
runtime/mainnet/src/config/governance.rs Outdated Show resolved Hide resolved
runtime/mainnet/src/config/governance.rs Outdated Show resolved Hide resolved
runtime/mainnet/src/config/governance.rs Outdated Show resolved Hide resolved
@peterwht peterwht changed the base branch from main to al3mart/refactor-mainnet-governance January 24, 2025 17:44
@peterwht peterwht changed the base branch from al3mart/refactor-mainnet-governance to main January 24, 2025 17:44
@peterwht
Copy link
Collaborator Author

[sc-2200]

@AlexD10S
Copy link
Collaborator

The step-by-step guide in the PR description is great. I've been testing and looks good 👌

@al3mart
Copy link
Collaborator

al3mart commented Feb 5, 2025

I have applied the feedback in this thread.

Introducing a more strict configuration in: 25029be
And adding configuration tests in: 78e9e79

@codecov-commenter
Copy link

codecov-commenter commented Feb 5, 2025

Codecov Report

Attention: Patch coverage is 94.39868% with 34 lines in your changes missing coverage. Please review.

Project coverage is 74.28%. Comparing base (168cf85) to head (8ba715f).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
pallets/motion/src/weights.rs 50.00% 21 Missing ⚠️
node/src/chain_spec.rs 0.00% 7 Missing ⚠️
pallets/motion/src/lib.rs 82.14% 3 Missing and 2 partials ⚠️
pallets/motion/src/benchmarking.rs 85.71% 0 Missing and 1 partial ⚠️
@@            Coverage Diff             @@
##             main     #448      +/-   ##
==========================================
+ Coverage   73.50%   74.28%   +0.78%     
==========================================
  Files          78       84       +6     
  Lines       15696    16301     +605     
  Branches    15696    16301     +605     
==========================================
+ Hits        11538    12110     +572     
- Misses       3897     3927      +30     
- Partials      261      264       +3     
Files with missing lines Coverage Δ
pallets/motion/src/mock.rs 100.00% <100.00%> (ø)
pallets/motion/src/tests.rs 100.00% <100.00%> (ø)
runtime/mainnet/src/config/governance.rs 100.00% <100.00%> (ø)
runtime/mainnet/src/lib.rs 81.37% <ø> (ø)
pallets/motion/src/benchmarking.rs 85.71% <85.71%> (ø)
pallets/motion/src/lib.rs 82.14% <82.14%> (ø)
node/src/chain_spec.rs 9.96% <0.00%> (-0.21%) ⬇️
pallets/motion/src/weights.rs 50.00% <50.00%> (ø)

... and 1 file with indirect coverage changes

@al3mart al3mart marked this pull request as ready for review February 5, 2025 03:39
Copy link
Collaborator Author

@peterwht peterwht left a comment

Choose a reason for hiding this comment

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

Thanks for taking this on!

I left a few comments -- biggest one about the min origin required for root.

In a separate PR (maybe with the genesis config presets), I think it would make our lives easier to have a Dev version of mainnet so we can use the dev accounts. Just noting for later.

FYI: I can't approve this PR as I am the original author.

runtime/mainnet/src/config/governance.rs Outdated Show resolved Hide resolved
runtime/mainnet/src/config/governance.rs Outdated Show resolved Hide resolved
runtime/mainnet/src/config/governance.rs Outdated Show resolved Hide resolved
runtime/mainnet/src/config/governance.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@evilrobot-01 evilrobot-01 left a comment

Choose a reason for hiding this comment

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

Saw that prior comments were never submitted, so submitting now in case they are helpful.

pallets/motion/README.md Show resolved Hide resolved
pallets/motion/src/lib.rs Outdated Show resolved Hide resolved
pallets/motion/src/lib.rs Show resolved Hide resolved
pallets/motion/src/lib.rs Outdated Show resolved Hide resolved
networks/mainnet.toml Show resolved Hide resolved
pallets/motion/src/weights.rs Show resolved Hide resolved
runtime/mainnet/Cargo.toml Outdated Show resolved Hide resolved
runtime/mainnet/src/lib.rs Outdated Show resolved Hide resolved
runtime/mainnet/src/config/governance.rs Outdated Show resolved Hide resolved
runtime/mainnet/src/config/governance.rs Outdated Show resolved Hide resolved
@Daanvdplas Daanvdplas self-requested a review February 7, 2025 10:11
Copy link
Collaborator

@Daanvdplas Daanvdplas left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Collaborator

@evilrobot-01 evilrobot-01 left a comment

Choose a reason for hiding this comment

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

High level review only, with various suggestions which is left up to author to decide on whether they should be addressed or not.

Note: did not look at any of the tests.

pallets/motion/Cargo.toml Outdated Show resolved Hide resolved
pallets/motion/src/benchmarking.rs Show resolved Hide resolved
pallets/motion/src/benchmarking.rs Show resolved Hide resolved
pallets/motion/src/benchmarking.rs Show resolved Hide resolved
pallets/motion/src/benchmarking.rs Show resolved Hide resolved
pallets/motion/src/lib.rs Show resolved Hide resolved
runtime/mainnet/Cargo.toml Outdated Show resolved Hide resolved
runtime/mainnet/src/config/governance.rs Show resolved Hide resolved
runtime/mainnet/src/config/governance.rs Outdated Show resolved Hide resolved
runtime/mainnet/src/config/governance.rs Outdated Show resolved Hide resolved
al3mart and others added 2 commits February 7, 2025 12:56
Co-authored-by: Frank Bell <[email protected]>

Update pallets/motion/src/benchmarking.rs

Co-authored-by: Frank Bell <[email protected]>

Update pallets/motion/src/benchmarking.rs

Co-authored-by: Frank Bell <[email protected]>

Update pallets/motion/src/benchmarking.rs

Co-authored-by: Frank Bell <[email protected]>

Update pallets/motion/src/benchmarking.rs

Co-authored-by: Frank Bell <[email protected]>
Copy link
Collaborator

@evilrobot-01 evilrobot-01 left a comment

Choose a reason for hiding this comment

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

Seems good to me. I have not looked at the tests or config in any detail so would not be comfortable giving it an approval.

Great work in gettting it all neatened up and ready for prime time!

@al3mart al3mart requested review from Daanvdplas, evilrobot-01 and a team February 10, 2025 16:54
Copy link
Collaborator

@Daanvdplas Daanvdplas left a comment

Choose a reason for hiding this comment

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

LGTM!

pallets/motion/src/lib.rs Outdated Show resolved Hide resolved
pallets/motion/src/lib.rs Outdated Show resolved Hide resolved
pallets/motion/src/lib.rs Outdated Show resolved Hide resolved
pallets/motion/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@al3mart al3mart left a comment

Choose a reason for hiding this comment

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

Note that I've pushed some of the changes here, this is an approval after a review from @peterwht to my changes.

@al3mart al3mart merged commit 159fef5 into main Feb 14, 2025
15 checks passed
@al3mart al3mart deleted the peter/add-gov branch February 14, 2025 17:19
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.

6 participants