Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Cargo.lock

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

6 changes: 5 additions & 1 deletion polkadot-parachains/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "integritee-collator"
description = "The Integritee parachain collator binary"
# align major.minor revision with the runtimes. bump patch revision ad lib. make this the github release tag
version = "1.5.22"
version = "1.5.23"
authors = ["Integritee AG <[email protected]>"]
homepage = "https://integritee.network/"
repository = "https://github.com/integritee-network/parachain"
Expand Down Expand Up @@ -112,3 +112,7 @@ runtime-benchmarks = [
'polkadot-service/runtime-benchmarks',
'parachain-runtime/runtime-benchmarks'
]
fast-runtime = [
"polkadot-service/fast-runtime",
"parachain-runtime/fast-runtime",
]
10 changes: 9 additions & 1 deletion polkadot-parachains/integritee-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = 'integritee-runtime'
description = "The Integritee parachain runtime"
# patch revision must match runtime spec_version
version = '1.5.18'
version = '1.5.19'
authors = ["Integritee AG <[email protected]>"]
homepage = "https://integritee.network/"
repository = "https://github.com/integritee-network/parachain"
Expand Down Expand Up @@ -39,6 +39,8 @@ frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate"
# pallets
pallet-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.19" }
pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.19" }
pallet-collective = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.19" }
pallet-democracy = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.19" }
pallet-randomness-collective-flip = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.19" }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.19" }
pallet-treasury = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.19" }
Expand Down Expand Up @@ -115,6 +117,8 @@ std = [
"frame-system-rpc-runtime-api/std",
"pallet-aura/std",
"pallet-balances/std",
"pallet-collective/std",
"pallet-democracy/std",
"pallet-randomness-collective-flip/std",
"pallet-timestamp/std",
"pallet-treasury/std",
Expand Down Expand Up @@ -163,6 +167,8 @@ runtime-benchmarks = [
"frame-system/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-claims/runtime-benchmarks",
"pallet-collective/runtime-benchmarks",
"pallet-democracy/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
Expand All @@ -174,3 +180,5 @@ runtime-benchmarks = [
"pallet-utility/runtime-benchmarks",
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
]
# Set timing constants (e.g. session period) to faster versions to speed up testing.
fast-runtime = []
40 changes: 40 additions & 0 deletions polkadot-parachains/integritee-runtime/src/helpers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2021 Integritee AG and Supercomputing Systems AG
// This file is part of the "Integritee parachain" and is
// based on Cumulus from Parity Technologies (UK) Ltd.

// Integritee parachain 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.

// Cumulus 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 Integritee parachain. If not, see <http://www.gnu.org/licenses/>.

//! XCM configuration for Integritee Runtime.
//!

/// Copied from polkadot/runtime/common/src/lib.rs
/// Macro to set a value (e.g. when using the `parameter_types` macro) to either a production value
/// or to an environment variable or testing value (in case the `fast-runtime` feature is selected).
/// Note that the environment variable is evaluated _at compile time_.
///
/// Usage:
/// ```Rust
/// parameter_types! {
/// pub const VotingPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1 * MINUTES);
/// }
#[macro_export]
macro_rules! prod_or_fast {
($prod:expr, $test:expr) => {
if cfg!(feature = "fast-runtime") {
$test
} else {
$prod
}
};
}
163 changes: 155 additions & 8 deletions polkadot-parachains/integritee-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
use crate::opaque::SessionKeys;
use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::traits::{EqualPrivilegeOnly, Imbalance, InstanceFilter, OnUnbalanced};
use pallet_collective;
use sp_api::impl_runtime_apis;
use sp_core::OpaqueMetadata;
use sp_runtime::{
Expand Down Expand Up @@ -70,6 +71,7 @@ pub use pallet_teerex::Call as TeerexCall;

pub type SessionHandlers = ();

mod helpers;
mod weights;

pub mod xcm_config;
Expand Down Expand Up @@ -103,7 +105,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("integritee-parachain"),
impl_name: create_runtime_str!("integritee-full"),
authoring_version: 2,
spec_version: 18,
spec_version: 19,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 3,
Expand Down Expand Up @@ -506,7 +508,7 @@ impl pallet_claims::Config for Runtime {
type Event = Event;
type VestingSchedule = Vesting;
type Prefix = Prefix;
type MoveClaimOrigin = frame_system::EnsureRoot<AccountId>;
type MoveClaimOrigin = EnsureRoot<AccountId>;
type WeightInfo = weights::pallet_claims::WeightInfo<Runtime>;
}
parameter_types! {
Expand Down Expand Up @@ -535,12 +537,12 @@ type RootOrigin = EnsureRoot<AccountId>;
impl pallet_treasury::Config for Runtime {
type PalletId = TreasuryPalletId;
type Currency = pallet_balances::Pallet<Runtime>;
type ApproveOrigin = RootOrigin;
type RejectOrigin = RootOrigin;
type ApproveOrigin = EnsureRootOrThreeFifthCouncil;
type RejectOrigin = EnsureRootOrHalfCouncil;
type Event = Event;
type OnSlash = (); //No proposal
type ProposalBond = ProposalBond; //No proposal
type ProposalBondMinimum = ProposalBondMinimum; //No proposal
type OnSlash = (); // No Proposal
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type ProposalBondMaximum = ProposalBondMaximum;
type SpendPeriod = SpendPeriod; //Cannot be 0: Error: Thread 'tokio-runtime-worker' panicked at 'attempt to calculate the remainder with a divisor of zero
type Burn = (); //No burn
Expand All @@ -550,6 +552,144 @@ impl pallet_treasury::Config for Runtime {
type WeightInfo = weights::pallet_treasury::WeightInfo<Runtime>;
}

/// Council collective instance declaration.
/// The council primarly serves to optimize and balance the inclusive referendum system,
/// by being allowed to porpose external democracy proposals and controls the treasury.
pub type CouncilInstance = pallet_collective::Instance1;

parameter_types! {
pub const CouncilMotionDuration: BlockNumber = prod_or_fast!(3 * DAYS, 2 * MINUTES);
pub const CouncilMaxProposals: u32 = 100;
pub const CouncilMaxMembers: u32 = 100;
}

impl pallet_collective::Config<CouncilInstance> for Runtime {
type Origin = Origin;
type Proposal = Call;
type Event = Event;
type MotionDuration = CouncilMotionDuration;
type MaxProposals = CouncilMaxProposals;
type MaxMembers = CouncilMaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type WeightInfo = weights::pallet_collective_council::WeightInfo<Runtime>;
}

pub type EnsureRootOrAllCouncil = EnsureOneOf<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilInstance, 1, 1>,
>;

pub type EnsureRootOrHalfCouncil = EnsureOneOf<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilInstance, 1, 2>,
>;

pub type EnsureRootOrTwoThirdsCouncil = EnsureOneOf<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilInstance, 2, 3>,
>;

pub type EnsureRootOrThreeFifthCouncil = EnsureOneOf<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilInstance, 3, 5>,
>;

pub type EnsureRootOrOneCouncil =
EnsureOneOf<EnsureRoot<AccountId>, pallet_collective::EnsureMember<AccountId, CouncilInstance>>;

/// Technical committee collective instance declaration.
/// The technical committee primarly serves to optimize and balance the inclusive referendum system,
/// by being allowed to porpose external democracy proposals and treasury control.
pub type TechnicalCommitteeInstance = pallet_collective::Instance2;

parameter_types! {
pub const TechnicalMotionDuration: BlockNumber = prod_or_fast!(3 * DAYS, 2 * MINUTES);
pub const TechnicalMaxProposals: u32 = 100;
pub const TechnicalMaxMembers: u32 = 100;
}

impl pallet_collective::Config<TechnicalCommitteeInstance> for Runtime {
type Origin = Origin;
type Event = Event;
type Proposal = Call;
/// The maximum amount of time (in blocks) for technical committee members to vote on motions.
/// Motions may end in fewer blocks if enough votes are cast to determine the result.
type MotionDuration = TechnicalMotionDuration;
/// The maximum number of Proposlas that can be open in the technical committee at once.
type MaxProposals = TechnicalMaxProposals;
/// The maximum number of technical committee members.
type MaxMembers = TechnicalMaxMembers;
type DefaultVote = pallet_collective::MoreThanMajorityThenPrimeDefaultVote;
type WeightInfo = weights::pallet_collective_technical_committee::WeightInfo<Runtime>;
}

pub type EnsureRootOrTwoThirdsTechnicalCommittee = EnsureOneOf<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCommitteeInstance, 2, 3>,
>;

pub type EnsureRootOrAllTechnicalCommittee = EnsureOneOf<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCommitteeInstance, 1, 1>,
>;

parameter_types! {
pub const LaunchPeriod: BlockNumber = prod_or_fast!(5 * DAYS, 1 * MINUTES);
pub const VotingPeriod: BlockNumber = prod_or_fast!(5 * DAYS, 1 * MINUTES);
pub FastTrackVotingPeriod: BlockNumber = prod_or_fast!(3 * HOURS, 1 * MINUTES);
pub const MinimumDeposit: Balance = 100 * TEER;
pub EnactmentPeriod: BlockNumber = prod_or_fast!(2 * DAYS, 1 * MINUTES);
pub const CooloffPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1 * MINUTES);
pub const InstantAllowed: bool = true;
pub const MaxVotes: u32 = 100;
pub const MaxProposals: u32 = 100;
pub const PreimageByteDeposit: Balance = 10 * MICROTEER; // 10 times a tx fee
}

impl pallet_democracy::Config for Runtime {
type Proposal = Call;
type Event = Event;
type Currency = Balances;
type EnactmentPeriod = EnactmentPeriod;
type LaunchPeriod = LaunchPeriod;
type VotingPeriod = VotingPeriod;
type VoteLockingPeriod = EnactmentPeriod;
type MinimumDeposit = MinimumDeposit;
//// Origin allowed to schedule a SuperMajorityApprove (default decline)
/// referendum once it is is legal for an externally proposed referendum
type ExternalOrigin = EnsureRootOrHalfCouncil;
/// Origin allowed to schedule a majority-carries (Simple Majority)
/// referendum once it is legal for an externally proposed referendum
type ExternalMajorityOrigin = EnsureRootOrHalfCouncil;
/// Origin allowed to schedule a SuperMajorityAgainst (default accept)
/// referendum once it is legal for an externally proposed referendum
type ExternalDefaultOrigin = EnsureRootOrAllCouncil;
/// 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 = InstantAllowed;
type FastTrackVotingPeriod = FastTrackVotingPeriod;
// To cancel a proposal which has been passed.
type CancellationOrigin = EnsureRootOrTwoThirdsCouncil;
type BlacklistOrigin = EnsureRootOrAllCouncil;
// 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 PreimageByteDeposit = PreimageByteDeposit;
type OperationalPreimageOrigin = pallet_collective::EnsureMember<AccountId, CouncilInstance>;
type Slash = Treasury;
type Scheduler = Scheduler;
type PalletsOrigin = OriginCaller;
type MaxVotes = MaxVotes;
type WeightInfo = weights::pallet_democracy::WeightInfo<Runtime>;
type MaxProposals = MaxProposals;
}

impl orml_xcm::Config for Runtime {
type Event = Event;
type SovereignOrigin = RootOrigin;
Expand Down Expand Up @@ -578,8 +718,12 @@ construct_runtime! {
TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 11,
Vesting: pallet_vesting::{Pallet, Call, Storage, Event<T>, Config<T>} = 12,

// Governance
// Governance.
Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 13,
Democracy: pallet_democracy::{Pallet, Storage, Config<T>, Event<T>, Call} = 14,
Council: pallet_collective::<Instance1>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>} = 15,
TechnicalCommittee:
pallet_collective::<Instance2>::{Pallet, Call, Storage, Event<T>, Origin<T>, Config<T>} = 16,

// Consensus.
Aura: pallet_aura::{Pallet, Storage, Config<T>} = 23,
Expand Down Expand Up @@ -657,6 +801,9 @@ mod benches {
[frame_system, SystemBench::<Runtime>]
[pallet_balances, Balances]
[pallet_claims, Claims]
[pallet_collective, Council]
[pallet_collective, TechnicalCommittee]
[pallet_democracy, Democracy]
[pallet_multisig, Multisig]
[pallet_proxy, Proxy]
[pallet_scheduler, Scheduler]
Expand Down
3 changes: 3 additions & 0 deletions polkadot-parachains/integritee-runtime/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
pub mod frame_system;
pub mod pallet_balances;
pub mod pallet_claims;
pub mod pallet_collective_council;
pub mod pallet_collective_technical_committee;
pub mod pallet_democracy;
pub mod pallet_multisig;
pub mod pallet_proxy;
pub mod pallet_scheduler;
Expand Down
Loading