Skip to content

Commit

Permalink
integrate openGov
Browse files Browse the repository at this point in the history
  • Loading branch information
wangjj9219 committed Oct 23, 2023
1 parent 661a0e3 commit 7bca0f1
Show file tree
Hide file tree
Showing 25 changed files with 1,882 additions and 529 deletions.
18 changes: 18 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions runtime/acala/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ scale-info = { version = "2.9.0", default-features = false, features = ["derive"
serde_json = { version = "1.0.85", default-features = false, features = ["alloc"] }
hex = { version = "0.4", default-features = false }
hex-literal = { version = "0.4.1" }
strum = { version = "0.24", default-features = false, features = [ "derive" ] }
strum_macros = "0.24"
lazy_static = "1.4.0"

# substrate
frame-executive = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
Expand Down Expand Up @@ -53,6 +56,9 @@ sp-staking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "rel
sp-std = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
sp-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
sp-version = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
pallet-conviction-voting = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
pallet-referenda = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
pallet-whitelist = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }

# cumulus
cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
Expand Down Expand Up @@ -149,6 +155,7 @@ std = [
"hex/std",
"scale-info/std",
"serde_json/std",
"strum/std",

"frame-benchmarking/std",
"frame-executive/std",
Expand Down Expand Up @@ -191,6 +198,9 @@ std = [
"sp-transaction-pool/std",
"sp-version/std",
"substrate-wasm-builder",
"pallet-conviction-voting/std",
"pallet-referenda/std",
"pallet-whitelist/std",

"cumulus-pallet-aura-ext/std",
"cumulus-pallet-dmp-queue/std",
Expand Down Expand Up @@ -285,6 +295,9 @@ runtime-benchmarks = [
"pallet-utility/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"sp-staking/runtime-benchmarks",
"pallet-conviction-voting/runtime-benchmarks",
"pallet-referenda/runtime-benchmarks",
"pallet-whitelist/runtime-benchmarks",

"cumulus-pallet-parachain-system/runtime-benchmarks",
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
Expand Down Expand Up @@ -348,6 +361,9 @@ try-runtime = [
"pallet-treasury/try-runtime",
"pallet-utility/try-runtime",
"pallet-bags-list/try-runtime",
"pallet-conviction-voting/try-runtime",
"pallet-referenda/try-runtime",
"pallet-whitelist/try-runtime",

"cumulus-pallet-aura-ext/try-runtime",
"cumulus-pallet-dmp-queue/try-runtime",
Expand Down
144 changes: 144 additions & 0 deletions runtime/acala/src/governance/councils.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
// This file is part of Acala.

// Copyright (C) 2020-2023 Acala Foundation.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! Councils for Gov1 and Gov2

use super::*;

parameter_types! {
pub const GeneralCouncilMotionDuration: BlockNumber = 3 * DAYS;
pub const CouncilDefaultMaxProposals: u32 = 20;
pub const CouncilDefaultMaxMembers: u32 = 30;
pub MaxProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block;
}

impl pallet_collective::Config<GeneralCouncilInstance> for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type MotionDuration = GeneralCouncilMotionDuration;
type MaxProposals = CouncilDefaultMaxProposals;
type MaxMembers = CouncilDefaultMaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type SetMembersOrigin = EnsureRoot<AccountId>;
type WeightInfo = ();
type MaxProposalWeight = MaxProposalWeight;
}

impl pallet_membership::Config<GeneralCouncilMembershipInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type AddOrigin = EnsureRootOrThreeFourthsGeneralCouncil;
type RemoveOrigin = EnsureRootOrThreeFourthsGeneralCouncil;
type SwapOrigin = EnsureRootOrThreeFourthsGeneralCouncil;
type ResetOrigin = EnsureRootOrThreeFourthsGeneralCouncil;
type PrimeOrigin = EnsureRootOrThreeFourthsGeneralCouncil;
type MembershipInitialized = GeneralCouncil;
type MembershipChanged = GeneralCouncil;
type MaxMembers = CouncilDefaultMaxMembers;
type WeightInfo = ();
}

parameter_types! {
pub const FinancialCouncilMotionDuration: BlockNumber = 3 * DAYS;
}

impl pallet_collective::Config<FinancialCouncilInstance> for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type MotionDuration = FinancialCouncilMotionDuration;
type MaxProposals = CouncilDefaultMaxProposals;
type MaxMembers = CouncilDefaultMaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type SetMembersOrigin = EnsureRoot<AccountId>;
type WeightInfo = ();
type MaxProposalWeight = MaxProposalWeight;
}

impl pallet_membership::Config<FinancialCouncilMembershipInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type AddOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type RemoveOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type SwapOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type ResetOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type PrimeOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type MembershipInitialized = FinancialCouncil;
type MembershipChanged = FinancialCouncil;
type MaxMembers = CouncilDefaultMaxMembers;
type WeightInfo = ();
}

parameter_types! {
pub const HomaCouncilMotionDuration: BlockNumber = 3 * DAYS;
}

impl pallet_collective::Config<HomaCouncilInstance> for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type MotionDuration = HomaCouncilMotionDuration;
type MaxProposals = CouncilDefaultMaxProposals;
type MaxMembers = CouncilDefaultMaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type SetMembersOrigin = EnsureRoot<AccountId>;
type WeightInfo = ();
type MaxProposalWeight = MaxProposalWeight;
}

impl pallet_membership::Config<HomaCouncilMembershipInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type AddOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type RemoveOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type SwapOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type ResetOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type PrimeOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type MembershipInitialized = HomaCouncil;
type MembershipChanged = HomaCouncil;
type MaxMembers = CouncilDefaultMaxMembers;
type WeightInfo = ();
}

parameter_types! {
pub const TechnicalCommitteeMotionDuration: BlockNumber = 3 * DAYS;
}

impl pallet_collective::Config<TechnicalCommitteeInstance> for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type MotionDuration = TechnicalCommitteeMotionDuration;
type MaxProposals = CouncilDefaultMaxProposals;
type MaxMembers = CouncilDefaultMaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type SetMembersOrigin = EnsureRoot<AccountId>;
type WeightInfo = ();
type MaxProposalWeight = MaxProposalWeight;
}

impl pallet_membership::Config<TechnicalCommitteeMembershipInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type AddOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type RemoveOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type SwapOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type ResetOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type PrimeOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type MembershipInitialized = TechnicalCommittee;
type MembershipChanged = TechnicalCommittee;
type MaxMembers = CouncilDefaultMaxMembers;
type WeightInfo = ();
}
74 changes: 74 additions & 0 deletions runtime/acala/src/governance/democracy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// This file is part of Acala.

// Copyright (C) 2020-2023 Acala Foundation.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! Democracy config for Gov1

use crate::*;

parameter_types! {
pub const LaunchPeriod: BlockNumber = 5 * DAYS;
pub const VotingPeriod: BlockNumber = 5 * DAYS;
pub const FastTrackVotingPeriod: BlockNumber = 3 * HOURS;
pub MinimumDeposit: Balance = 1000 * dollar(ACA);
pub const EnactmentPeriod: BlockNumber = 2 * DAYS;
pub const VoteLockingPeriod: BlockNumber = 14 * DAYS;
pub const CooloffPeriod: BlockNumber = 7 * DAYS;
}

impl pallet_democracy::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type EnactmentPeriod = EnactmentPeriod;
type LaunchPeriod = LaunchPeriod;
type VotingPeriod = VotingPeriod;
type VoteLockingPeriod = VoteLockingPeriod;
type MinimumDeposit = MinimumDeposit;
/// A straight majority of the council can decide what their next motion is.
type ExternalOrigin = EnsureRootOrHalfGeneralCouncil;
/// A majority can have the next scheduled referendum be a straight majority-carries vote.
type ExternalMajorityOrigin = EnsureRootOrHalfGeneralCouncil;
/// A unanimous council can have the next scheduled referendum be a straight default-carries
/// (NTB) vote.
type ExternalDefaultOrigin = EnsureRootOrAllGeneralCouncil;
/// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote
/// be tabled immediately and with a shorter voting/enactment period.
type FastTrackOrigin = EnsureRootOrTwoThirdsTechnicalCommittee;
type InstantOrigin = EnsureRootOrAllTechnicalCommittee;
type InstantAllowed = ConstBool<true>;
type FastTrackVotingPeriod = FastTrackVotingPeriod;
// To cancel a proposal which has been passed, 2/3 of the council must agree to it.
type CancellationOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type BlacklistOrigin = EnsureRoot<AccountId>;
// To cancel a proposal before it has been passed, the technical committee must be unanimous or
// Root must agree.
type CancelProposalOrigin = EnsureRootOrAllTechnicalCommittee;
// Any single technical committee member may veto a coming council proposal, however they can
// only do it once and it lasts only for the cooloff period.
type VetoOrigin = pallet_collective::EnsureMember<AccountId, TechnicalCommitteeInstance>;
type CooloffPeriod = CooloffPeriod;
type Slash = Treasury;
type Scheduler = Scheduler;
type PalletsOrigin = OriginCaller;
type MaxVotes = ConstU32<100>;
type WeightInfo = pallet_democracy::weights::SubstrateWeight<Runtime>;
type MaxProposals = ConstU32<100>;
type Preimages = Preimage;
type MaxDeposits = ConstU32<100>;
type MaxBlacklisted = ConstU32<100>;
type SubmitOrigin = EnsureSigned<AccountId>;
}
Loading

0 comments on commit 7bca0f1

Please sign in to comment.