Unverified Commit dc41a09f authored by Bastian Köcher's avatar Bastian Köcher Committed by GitHub
Browse files

Companion PR to #5695 (#1030)



* add module ids to kusama runtime

* update kusam with polkadot runtimes to have moduleids configured

* trivial

* define module id for treasury in crowdfund.rs

* crodfund builds without issue

* remove commented out code

* switch crowdfund  to configurable moduleid

* test-runtime passing

* trivial syntax

* add module id to mock

* Update `Cargo.lock`
Co-authored-by: default avatarzeke <emostov@middlebury.edu>
parent e158a623
Pipeline #89502 passed with stages
in 31 minutes and 11 seconds
This diff is collapsed.
...@@ -82,8 +82,6 @@ use codec::{Encode, Decode}; ...@@ -82,8 +82,6 @@ use codec::{Encode, Decode};
use sp_std::vec::Vec; use sp_std::vec::Vec;
use primitives::parachain::{Id as ParaId, HeadData}; use primitives::parachain::{Id as ParaId, HeadData};
const MODULE_ID: ModuleId = ModuleId(*b"py/cfund");
pub type BalanceOf<T> = pub type BalanceOf<T> =
<<T as slots::Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance; <<T as slots::Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
#[allow(dead_code)] #[allow(dead_code)]
...@@ -93,6 +91,9 @@ pub type NegativeImbalanceOf<T> = ...@@ -93,6 +91,9 @@ pub type NegativeImbalanceOf<T> =
pub trait Trait: slots::Trait { pub trait Trait: slots::Trait {
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>; type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
/// ModuleID for the crowdfund module. An appropriate value could be ```ModuleId(*b"py/cfund")```
type ModuleId: Get<ModuleId>;
/// The amount to be held on deposit by the owner of a crowdfund. /// The amount to be held on deposit by the owner of a crowdfund.
type SubmissionDeposit: Get<BalanceOf<Self>>; type SubmissionDeposit: Get<BalanceOf<Self>>;
...@@ -247,6 +248,8 @@ decl_module! { ...@@ -247,6 +248,8 @@ decl_module! {
pub struct Module<T: Trait> for enum Call where origin: T::Origin { pub struct Module<T: Trait> for enum Call where origin: T::Origin {
type Error = Error<T>; type Error = Error<T>;
const ModuleId: ModuleId = T::ModuleId::get();
fn deposit_event() = default; fn deposit_event() = default;
/// Create a new crowdfunding campaign for a parachain slot deposit for the current auction. /// Create a new crowdfunding campaign for a parachain slot deposit for the current auction.
...@@ -525,7 +528,7 @@ impl<T: Trait> Module<T> { ...@@ -525,7 +528,7 @@ impl<T: Trait> Module<T> {
/// This actually does computation. If you need to keep using it, then make sure you cache the /// This actually does computation. If you need to keep using it, then make sure you cache the
/// value and only call this once. /// value and only call this once.
pub fn fund_account_id(index: FundIndex) -> T::AccountId { pub fn fund_account_id(index: FundIndex) -> T::AccountId {
MODULE_ID.into_sub_account(index) T::ModuleId::get().into_sub_account(index)
} }
pub fn id_from_index(index: FundIndex) -> child::ChildInfo { pub fn id_from_index(index: FundIndex) -> child::ChildInfo {
...@@ -632,6 +635,7 @@ mod tests { ...@@ -632,6 +635,7 @@ mod tests {
pub const TipFindersFee: Percent = Percent::from_percent(20); pub const TipFindersFee: Percent = Percent::from_percent(20);
pub const TipReportDepositBase: u64 = 1; pub const TipReportDepositBase: u64 = 1;
pub const TipReportDepositPerByte: u64 = 1; pub const TipReportDepositPerByte: u64 = 1;
pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry");
} }
pub struct Nobody; pub struct Nobody;
impl Contains<u64> for Nobody { impl Contains<u64> for Nobody {
...@@ -655,6 +659,7 @@ mod tests { ...@@ -655,6 +659,7 @@ mod tests {
type TipFindersFee = TipFindersFee; type TipFindersFee = TipFindersFee;
type TipReportDepositBase = TipReportDepositBase; type TipReportDepositBase = TipReportDepositBase;
type TipReportDepositPerByte = TipReportDepositPerByte; type TipReportDepositPerByte = TipReportDepositPerByte;
type ModuleId = TreasuryModuleId;
} }
thread_local! { thread_local! {
...@@ -729,6 +734,7 @@ mod tests { ...@@ -729,6 +734,7 @@ mod tests {
pub const SubmissionDeposit: u64 = 1; pub const SubmissionDeposit: u64 = 1;
pub const MinContribution: u64 = 10; pub const MinContribution: u64 = 10;
pub const RetirementPeriod: u64 = 5; pub const RetirementPeriod: u64 = 5;
pub const CrowdfundModuleId: ModuleId = ModuleId(*b"py/cfund");
} }
impl Trait for Test { impl Trait for Test {
type Event = (); type Event = ();
...@@ -736,6 +742,7 @@ mod tests { ...@@ -736,6 +742,7 @@ mod tests {
type MinContribution = MinContribution; type MinContribution = MinContribution;
type RetirementPeriod = RetirementPeriod; type RetirementPeriod = RetirementPeriod;
type OrphanedFunds = Treasury; type OrphanedFunds = Treasury;
type ModuleId = CrowdfundModuleId;
} }
type System = system::Module<Test>; type System = system::Module<Test>;
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
// GNU General Public License for more details. // GNU General Public License for more details.
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>. // along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! The Polkadot runtime. This can be compiled with `#[no_std]`, ready for Wasm. //! The Polkadot runtime. This can be compiled with `#[no_std]`, ready for Wasm.
...@@ -33,7 +33,7 @@ use runtime_common::{attestations, claims, parachains, registrar, slots, ...@@ -33,7 +33,7 @@ use runtime_common::{attestations, claims, parachains, registrar, slots,
MaximumBlockLength, MaximumBlockLength,
}; };
use sp_runtime::{ use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, create_runtime_str, generic, impl_opaque_keys, ModuleId,
ApplyExtrinsicResult, KeyTypeId, Percent, Permill, Perbill, Perquintill, RuntimeDebug, ApplyExtrinsicResult, KeyTypeId, Percent, Permill, Perbill, Perquintill, RuntimeDebug,
transaction_validity::{ transaction_validity::{
TransactionValidity, InvalidTransaction, TransactionValidityError, TransactionSource, TransactionPriority, TransactionValidity, InvalidTransaction, TransactionValidityError, TransactionSource, TransactionPriority,
...@@ -54,7 +54,7 @@ use sp_core::OpaqueMetadata; ...@@ -54,7 +54,7 @@ use sp_core::OpaqueMetadata;
use sp_staking::SessionIndex; use sp_staking::SessionIndex;
use frame_support::{ use frame_support::{
parameter_types, construct_runtime, debug, parameter_types, construct_runtime, debug,
traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness}, traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness, LockIdentifier},
}; };
use im_online::sr25519::AuthorityId as ImOnlineId; use im_online::sr25519::AuthorityId as ImOnlineId;
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId; use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
...@@ -387,6 +387,7 @@ parameter_types! { ...@@ -387,6 +387,7 @@ parameter_types! {
pub const TermDuration: BlockNumber = 24 * HOURS; pub const TermDuration: BlockNumber = 24 * HOURS;
pub const DesiredMembers: u32 = 13; pub const DesiredMembers: u32 = 13;
pub const DesiredRunnersUp: u32 = 7; pub const DesiredRunnersUp: u32 = 7;
pub const ElectionsPhragmenModuleId: LockIdentifier = *b"phrelect";
} }
impl elections_phragmen::Trait for Runtime { impl elections_phragmen::Trait for Runtime {
...@@ -403,6 +404,7 @@ impl elections_phragmen::Trait for Runtime { ...@@ -403,6 +404,7 @@ impl elections_phragmen::Trait for Runtime {
type DesiredMembers = DesiredMembers; type DesiredMembers = DesiredMembers;
type DesiredRunnersUp = DesiredRunnersUp; type DesiredRunnersUp = DesiredRunnersUp;
type TermDuration = TermDuration; type TermDuration = TermDuration;
type ModuleId = ElectionsPhragmenModuleId;
} }
parameter_types! { parameter_types! {
...@@ -433,6 +435,7 @@ parameter_types! { ...@@ -433,6 +435,7 @@ parameter_types! {
pub const ProposalBondMinimum: Balance = 20 * DOLLARS; pub const ProposalBondMinimum: Balance = 20 * DOLLARS;
pub const SpendPeriod: BlockNumber = 6 * DAYS; pub const SpendPeriod: BlockNumber = 6 * DAYS;
pub const Burn: Permill = Permill::from_percent(0); pub const Burn: Permill = Permill::from_percent(0);
pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry");
pub const TipCountdown: BlockNumber = 1 * DAYS; pub const TipCountdown: BlockNumber = 1 * DAYS;
pub const TipFindersFee: Percent = Percent::from_percent(20); pub const TipFindersFee: Percent = Percent::from_percent(20);
...@@ -455,6 +458,7 @@ impl treasury::Trait for Runtime { ...@@ -455,6 +458,7 @@ impl treasury::Trait for Runtime {
type ProposalBondMinimum = ProposalBondMinimum; type ProposalBondMinimum = ProposalBondMinimum;
type SpendPeriod = SpendPeriod; type SpendPeriod = SpendPeriod;
type Burn = Burn; type Burn = Burn;
type ModuleId = TreasuryModuleId;
} }
impl offences::Trait for Runtime { impl offences::Trait for Runtime {
...@@ -694,6 +698,7 @@ parameter_types! { ...@@ -694,6 +698,7 @@ parameter_types! {
pub const PeriodSpend: Balance = 500 * DOLLARS; pub const PeriodSpend: Balance = 500 * DOLLARS;
pub const MaxLockDuration: BlockNumber = 36 * 30 * DAYS; pub const MaxLockDuration: BlockNumber = 36 * 30 * DAYS;
pub const ChallengePeriod: BlockNumber = 7 * DAYS; pub const ChallengePeriod: BlockNumber = 7 * DAYS;
pub const SocietyModuleId: ModuleId = ModuleId(*b"py/socie");
} }
impl society::Trait for Runtime { impl society::Trait for Runtime {
...@@ -710,6 +715,7 @@ impl society::Trait for Runtime { ...@@ -710,6 +715,7 @@ impl society::Trait for Runtime {
type FounderSetOrigin = collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>; type FounderSetOrigin = collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>;
type SuspensionJudgementOrigin = society::EnsureFounder<Runtime>; type SuspensionJudgementOrigin = society::EnsureFounder<Runtime>;
type ChallengePeriod = ChallengePeriod; type ChallengePeriod = ChallengePeriod;
type ModuleId = SocietyModuleId;
} }
parameter_types! { parameter_types! {
......
...@@ -34,7 +34,7 @@ use primitives::{ ...@@ -34,7 +34,7 @@ use primitives::{
parachain::{self, ActiveParas, AbridgedCandidateReceipt, SigningContext}, ValidityError, parachain::{self, ActiveParas, AbridgedCandidateReceipt, SigningContext}, ValidityError,
}; };
use sp_runtime::{ use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, create_runtime_str, generic, impl_opaque_keys, ModuleId,
ApplyExtrinsicResult, KeyTypeId, Percent, Permill, Perbill, Perquintill, RuntimeDebug, ApplyExtrinsicResult, KeyTypeId, Percent, Permill, Perbill, Perquintill, RuntimeDebug,
transaction_validity::{ transaction_validity::{
TransactionValidity, InvalidTransaction, TransactionValidityError, TransactionSource, TransactionPriority, TransactionValidity, InvalidTransaction, TransactionValidityError, TransactionSource, TransactionPriority,
...@@ -56,7 +56,7 @@ use sp_core::OpaqueMetadata; ...@@ -56,7 +56,7 @@ use sp_core::OpaqueMetadata;
use sp_staking::SessionIndex; use sp_staking::SessionIndex;
use frame_support::{ use frame_support::{
parameter_types, construct_runtime, debug, parameter_types, construct_runtime, debug,
traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness}, traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness, LockIdentifier},
}; };
use im_online::sr25519::AuthorityId as ImOnlineId; use im_online::sr25519::AuthorityId as ImOnlineId;
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId; use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
...@@ -393,6 +393,7 @@ parameter_types! { ...@@ -393,6 +393,7 @@ parameter_types! {
/// 13 members initially, to be increased to 23 eventually. /// 13 members initially, to be increased to 23 eventually.
pub const DesiredMembers: u32 = 13; pub const DesiredMembers: u32 = 13;
pub const DesiredRunnersUp: u32 = 20; pub const DesiredRunnersUp: u32 = 20;
pub const ElectionsPhragmenModuleId: LockIdentifier = *b"phrelect";
} }
impl elections_phragmen::Trait for Runtime { impl elections_phragmen::Trait for Runtime {
...@@ -409,6 +410,7 @@ impl elections_phragmen::Trait for Runtime { ...@@ -409,6 +410,7 @@ impl elections_phragmen::Trait for Runtime {
type DesiredMembers = DesiredMembers; type DesiredMembers = DesiredMembers;
type DesiredRunnersUp = DesiredRunnersUp; type DesiredRunnersUp = DesiredRunnersUp;
type TermDuration = TermDuration; type TermDuration = TermDuration;
type ModuleId = ElectionsPhragmenModuleId;
} }
parameter_types! { parameter_types! {
...@@ -439,6 +441,7 @@ parameter_types! { ...@@ -439,6 +441,7 @@ parameter_types! {
pub const ProposalBondMinimum: Balance = 100 * DOLLARS; pub const ProposalBondMinimum: Balance = 100 * DOLLARS;
pub const SpendPeriod: BlockNumber = 24 * DAYS; pub const SpendPeriod: BlockNumber = 24 * DAYS;
pub const Burn: Permill = Permill::from_percent(1); pub const Burn: Permill = Permill::from_percent(1);
pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry");
pub const TipCountdown: BlockNumber = 1 * DAYS; pub const TipCountdown: BlockNumber = 1 * DAYS;
pub const TipFindersFee: Percent = Percent::from_percent(20); pub const TipFindersFee: Percent = Percent::from_percent(20);
...@@ -461,6 +464,7 @@ impl treasury::Trait for Runtime { ...@@ -461,6 +464,7 @@ impl treasury::Trait for Runtime {
type ProposalBondMinimum = ProposalBondMinimum; type ProposalBondMinimum = ProposalBondMinimum;
type SpendPeriod = SpendPeriod; type SpendPeriod = SpendPeriod;
type Burn = Burn; type Burn = Burn;
type ModuleId = TreasuryModuleId;
} }
impl offences::Trait for Runtime { impl offences::Trait for Runtime {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment