-
Notifications
You must be signed in to change notification settings - Fork 346
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
Introduces Governance v2 in Moonbase Alpha #1838
Conversation
type Event = Event; | ||
type Call = Call; | ||
type WhitelistOrigin = EitherOf< | ||
EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear what this ConstU16<65535>
is doing, and I don't see any useful documentation around EnsureRootWithSuccess
. Can you point me in the right direction?
The impl for it is:
pub struct EnsureRootWithSuccess<AccountId, Success>(
sp_std::marker::PhantomData<(AccountId, Success)>,
);
impl<
O: Into<Result<RawOrigin<AccountId>, O>> + From<RawOrigin<AccountId>>,
AccountId,
Success: TypedGet,
> EnsureOrigin<O> for EnsureRootWithSuccess<AccountId, Success>
{
type Success = Success::Type;
fn try_origin(o: O) -> Result<Self::Success, O> {
o.into().and_then(|o| match o {
RawOrigin::Root => Ok(Success::get()),
r => Err(O::from(r)),
})
}
#[cfg(feature = "runtime-benchmarks")]
fn try_successful_origin() -> Result<O, ()> {
Ok(O::from(RawOrigin::Root))
}
}
It looks to me like all it will do is return Result::Ok(65535)
in try_origin
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is just the EnsureRoot
required as a generic for EitherOf
. I only used this constant because it is what is used in the Kusama Gov2 PR (used 5 times in that PR with EnsureRootWithSuccess i.e. https://github.com/paritytech/polkadot/pull/5205/files#diff-b2299d42ae2d30e47a174007af1e60a2bf92cec42c2628d7e419a05b2ebbe435R71-R72 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The WhitelistOrigin = Either<EnsureRoot, TechCommitee 2 of 3>. The use of the constants and the map reduce are just to make it work. I followed the conventions of that Kusama Gov2 PR for these conventions, but I do not understand them (the constants).
use super::*; | ||
use crate::currency::{KILOUNIT, SUPPLY_FACTOR, UNIT}; | ||
|
||
const fn percent(x: i32) -> sp_runtime::FixedI64 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you will get the same precision and useful range out of a Perbill
with only 32 bits.
Perbill: 32 bits, range: [0, 1] with 9 decimal points of precision
FixedI64: 64 bits, range [-9223372036.854775808, 9223372036.854775807]
Both have 9 points of decimal precision, the difference is in the integer portion, which we aren't using here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see this explicitly used as storage, though. The point is irrelevant unless we're trying to save space somewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This helper function is used to form the inputs for all the curves via the curve helpers make_linear
and make_reciprocal
. These functions take FixedI64
so that is the reason for it being returned here.
.min_support | ||
.info(decision_period_days, track_info.name); | ||
} | ||
assert!(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does this need to panic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is annotated by #[should_panic]
. Then I comment that line out and run it to get the curve evolution for all tracks (the curve evolution output does not print unless the test fails).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If anyone has suggestions on how to better organize this, let me know. I think it's fine for now.
_ => Err(()), | ||
} | ||
} else if let Ok(custom_origin) = origins::Origin::try_from(id.clone()) { | ||
match custom_origin { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this have a default branch to induce an Err just to be safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This refers to the match
starting on line 248, nothing to do with line 245)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rust compiler would complain if the match did not have a branch for all enum variants.
I don't even think we can add an additional branch without the compiler complaining (because it already has a branch for every variant of the origins::Origin enum)
type WeightInfo = pallet_democracy::weights::SubstrateWeight<Runtime>; | ||
type MaxProposals = ConstU32<100>; | ||
type ManagerOrigin = EnsureRoot<AccountId>; | ||
type MaxSize = ConstU32<{ 4096 * 1024 }>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this meant to allow for up to a runtime upgrade? Or something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...if so, it might be safer to reduce this if we don't intend to use it for a runtime upgrade any time soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was copied from Kusama so need to look into how they got this number. Maybe we don't need it so high...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this meant to allow for up to a runtime upgrade? Or something else?
Preimage pallet is used for all governance that goes through pallet-referenda as well as whitelisted calls in the whitelist pallet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved with some dumb questions...
* move democracy to old and councils to own file until decided how to migrate councils * fix * Gov2 (moonbeam-foundation#1839) * gov2 config init with whitelist origin configured with tech committee 2 of 3 * test * clean * fix and docs * fix * try fix * try fix * fix and clean * fix * fix test and add curve docs above curves * revert accidental change * give power to Treasurer and rename GeneralAdmin to IdentityAdmin * finish rename of general admin to identity admin as it only manages the identity registrar * accept suggestion to use SUPPLY FACTOR in Spender definition * use supply factor for all currency * fix import * Playing with tracks values * fix build and update tracks curve evolution gist * update track curve format * improve * Configure referendum tracks Co-authored-by: Crystalin <alan@purestake.com>
Supercedes #1762 to add the moonbase Gov2 config. Follows conventions of paritytech/polkadot#5205 to split
governance
config into own folder.This PR preserves the existing Governance config with the intention of only including the new Gov2 config for testing purposes (both Gov1 and Gov2 will be supported initially). This PR adds following pallet configs to moonbase:
pallet-preimage
: allows storing the preimage of a hash on chain; we configurepallet_scheduler::Config::PreimageProvider = Preimage
pallet-whitelist
: queues calls to be dispatched later by rootpallet-conviction-voting
: manages tally and votes for pallet-referenda in decoupled waypallet-referenda
: pallet for executing referenda wherein referendum is a vote on whether a proposal should be dispatched from a particular origin such that each origin has its own governance parameters i.e. for rootThis PR does NOT include Fellowship configuration
No migration required. We do not need another migration to set the scheduler::Config::PreimageProvider to the newly configured preimage pallet. Democracy does not use the preimages pallet, it uses its own internal storage item. The scheduler pallet will now set the preimage pallet as the preimage provider. Pallet referenda only uses the preimage pallet through its usage of the scheduler pallet configured with PreimageProvider = Preimage.
Tracks
evolution of configured curves over decision period, TODO make graphs
Fast Track
Whitelist track is the fast track. Here are the steps:
whitelist::whitelist_call(call_hash: T::Hash)
from configuredWhitelistOrigin = EitherOf<Root, TechCommittee 2 of 3>
referenda::submit
withOrigins::WhitelistedCaller
and proposal hash ofwhitelist::dispatch_whitelisted_call(...)
with the inner call argument equal to thecall_hash
passed in (1)