Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
companion for #13607
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyalaribe committed Apr 20, 2023
1 parent fd00d14 commit f4c5bd7
Show file tree
Hide file tree
Showing 7 changed files with 207 additions and 14 deletions.
33 changes: 30 additions & 3 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ use frame_election_provider_support::{
generate_solution_type, onchain, NposSolution, SequentialPhragmen,
};
use frame_support::{
construct_runtime, parameter_types,
construct_runtime, ord_parameter_types, parameter_types,
traits::{
ConstU32, Contains, EitherOf, EitherOfDiverse, InstanceFilter, KeyOwnerProofSystem,
PrivilegeCmp, StorageMapShim, WithdrawReasons,
Expand All @@ -71,8 +71,8 @@ use sp_mmr_primitives as mmr;
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{
AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, Extrinsic as ExtrinsicT,
OpaqueKeys, SaturatedConversion, Verify,
AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto,
Extrinsic as ExtrinsicT, OpaqueKeys, SaturatedConversion, Verify,
},
transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
ApplyExtrinsicResult, FixedU128, KeyTypeId, Perbill, Percent, Permill,
Expand Down Expand Up @@ -110,6 +110,13 @@ use governance::{
pallet_custom_origins, AuctionAdmin, Fellows, GeneralAdmin, LeaseAdmin, StakingAdmin,
Treasurer, TreasurySpender,
};
use xcm::{
latest::{InteriorMultiLocation, MultiLocation},
v3::Junction,
};

use crate::xcm_config::Statemine;
use xcm_builder::PayOverXcm;

#[cfg(test)]
mod tests;
Expand Down Expand Up @@ -599,6 +606,8 @@ impl pallet_fast_unstake::Config for Runtime {
type WeightInfo = weights::pallet_fast_unstake::WeightInfo<Runtime>;
}

use xcm::opaque::lts::Junctions;

parameter_types! {
pub const ProposalBond: Permill = Permill::from_percent(5);
pub const ProposalBondMinimum: Balance = 2000 * CENTS;
Expand All @@ -616,10 +625,28 @@ parameter_types! {
pub const MaxKeys: u32 = 10_000;
pub const MaxPeerInHeartbeats: u32 = 10_000;
pub const MaxPeerDataEncodingSize: u32 = 1_000;
// PayOverXcmTimeout is set to 3 x the spend period to provide buffer before status messages
// are deleted from storage
pub const PayOverXcmTimeout: BlockNumber = 6 * 3 * DAYS;
}

ord_parameter_types! {
pub const TreasuryAccountId: AccountId = AccountIdConversion::<AccountId>::into_account_truncating(&TreasuryPalletId::get());
}

impl pallet_treasury::Config for Runtime {
type PalletId = TreasuryPalletId;
type AssetKind = xcm::latest::AssetId;
type Paymaster = PayOverXcm<
Statemine,
TreasuryAccountId,
xcm_config::XcmRouter,
XcmPallet,
PayOverXcmTimeout,
Self::AccountId,
Self::AssetKind,
>;
type BalanceConverter = ();
type Currency = Balances;
type ApproveOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
type RejectOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
Expand Down
44 changes: 44 additions & 0 deletions runtime/kusama/src/weights/pallet_treasury.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,22 @@ impl<T: frame_system::Config> pallet_treasury::WeightInfo for WeightInfo<T> {
}
/// Storage: Treasury ProposalCount (r:1 w:1)
/// Proof: Treasury ProposalCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
/// Storage: Treasury Approvals (r:1 w:1)
/// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen)
/// Storage: Treasury Proposals (r:0 w:1)
/// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen)
fn spend_local() -> Weight {
// Proof Size summary in bytes:
// Measured: `6`
// Estimated: `3376`
// Minimum execution time: 14_516_000 picoseconds.
Weight::from_parts(14_898_000, 0)
.saturating_add(Weight::from_parts(0, 3376))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: Treasury ProposalCount (r:1 w:1)
/// Proof: Treasury ProposalCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
/// Storage: Treasury Proposals (r:0 w:1)
/// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen)
fn propose_spend() -> Weight {
Expand Down Expand Up @@ -146,4 +162,32 @@ impl<T: frame_system::Config> pallet_treasury::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(p.into())))
.saturating_add(Weight::from_parts(0, 7789).saturating_mul(p.into()))
}
/// Storage: Treasury Deactivated (r:1 w:1)
/// Proof: Treasury Deactivated (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)
/// Storage: Balances InactiveIssuance (r:1 w:1)
/// Proof: Balances InactiveIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)
/// Storage: Treasury Approvals (r:1 w:1)
/// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen)
/// Storage: Treasury Proposals (r:100 w:100)
/// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen)
/// Storage: System Account (r:201 w:201)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
/// Storage: Bounties BountyApprovals (r:1 w:1)
/// Proof: Bounties BountyApprovals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen)
/// The range of component `p` is `[0, 100]`.
fn on_initialize_pending_payments(p: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `297 + p * (251 ±0)`
// Estimated: `11359 + p * (7789 ±0)`
// Minimum execution time: 57_179_000 picoseconds.
Weight::from_parts(61_547_634, 0)
.saturating_add(Weight::from_parts(0, 11359))
// Standard Error: 30_382
.saturating_add(Weight::from_parts(32_012_031, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(p.into())))
.saturating_add(T::DbWeight::get().writes(5))
.saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(p.into())))
.saturating_add(Weight::from_parts(0, 7789).saturating_mul(p.into()))
}
}
26 changes: 23 additions & 3 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ use runtime_parachains::{
session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump,
};

use crate::xcm_config::Statemint;
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use beefy_primitives::crypto::{AuthorityId as BeefyId, Signature as BeefySignature};
use frame_election_provider_support::{generate_solution_type, onchain, SequentialPhragmen};
use frame_support::{
construct_runtime, parameter_types,
construct_runtime, ord_parameter_types, parameter_types,
traits::{
ConstU32, EitherOf, EitherOfDiverse, InstanceFilter, KeyOwnerProofSystem, LockIdentifier,
PrivilegeCmp, WithdrawReasons,
Expand Down Expand Up @@ -67,8 +68,8 @@ use sp_runtime::{
curve::PiecewiseLinear,
generic, impl_opaque_keys,
traits::{
AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, Extrinsic as ExtrinsicT,
OpaqueKeys, SaturatedConversion, Verify,
AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto,
Extrinsic as ExtrinsicT, OpaqueKeys, SaturatedConversion, Verify,
},
transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
ApplyExtrinsicResult, FixedU128, KeyTypeId, Perbill, Percent, Permill,
Expand Down Expand Up @@ -105,6 +106,7 @@ use governance::{
old::CouncilCollective, pallet_custom_origins, AuctionAdmin, FellowshipAdmin, GeneralAdmin,
LeaseAdmin, StakingAdmin, Treasurer, TreasurySpender,
};
use xcm_builder::PayOverXcm;

pub mod xcm_config;

Expand Down Expand Up @@ -653,10 +655,28 @@ parameter_types! {
pub const MaxPeerDataEncodingSize: u32 = 1_000;
pub const RootSpendOriginMaxAmount: Balance = Balance::MAX;
pub const CouncilSpendOriginMaxAmount: Balance = Balance::MAX;
// PayOverXcmTimeout is set to 3 x the spend period to provide buffer before status messages
// are deleted from storage
pub const PayOverXcmTimeout: BlockNumber = 6 * 3 * DAYS;
}

ord_parameter_types! {
pub const TreasuryAccountId: AccountId = AccountIdConversion::<AccountId>::into_account_truncating(&TreasuryPalletId::get());
}

impl pallet_treasury::Config for Runtime {
type PalletId = TreasuryPalletId;
type AssetKind = xcm::latest::AssetId;
type Paymaster = PayOverXcm<
Statemint,
TreasuryAccountId,
xcm_config::XcmRouter,
XcmPallet,
PayOverXcmTimeout,
Self::AccountId,
Self::AssetKind,
>;
type BalanceConverter = ();
type Currency = Balances;
type ApproveOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
type RejectOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
Expand Down
44 changes: 44 additions & 0 deletions runtime/polkadot/src/weights/pallet_treasury.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,22 @@ impl<T: frame_system::Config> pallet_treasury::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: Treasury ProposalCount (r:1 w:1)
/// Proof: Treasury ProposalCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
/// Storage: Treasury Approvals (r:1 w:1)
/// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen)
/// Storage: Treasury Proposals (r:0 w:1)
/// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen)
fn spend_local() -> Weight {
// Proof Size summary in bytes:
// Measured: `6`
// Estimated: `3376`
// Minimum execution time: 14_516_000 picoseconds.
Weight::from_parts(14_898_000, 0)
.saturating_add(Weight::from_parts(0, 3376))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: Treasury ProposalCount (r:1 w:1)
/// Proof: Treasury ProposalCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
/// Storage: Treasury Proposals (r:0 w:1)
Expand Down Expand Up @@ -146,4 +162,32 @@ impl<T: frame_system::Config> pallet_treasury::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(p.into())))
.saturating_add(Weight::from_parts(0, 7789).saturating_mul(p.into()))
}
/// Storage: Treasury Deactivated (r:1 w:1)
/// Proof: Treasury Deactivated (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)
/// Storage: Balances InactiveIssuance (r:1 w:1)
/// Proof: Balances InactiveIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)
/// Storage: Treasury Approvals (r:1 w:1)
/// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen)
/// Storage: Treasury Proposals (r:100 w:100)
/// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen)
/// Storage: System Account (r:201 w:201)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
/// Storage: Bounties BountyApprovals (r:1 w:1)
/// Proof: Bounties BountyApprovals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen)
/// The range of component `p` is `[0, 100]`.
fn on_initialize_pending_payments(p: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `297 + p * (251 ±0)`
// Estimated: `11359 + p * (7789 ±0)`
// Minimum execution time: 57_179_000 picoseconds.
Weight::from_parts(61_547_634, 0)
.saturating_add(Weight::from_parts(0, 11359))
// Standard Error: 30_382
.saturating_add(Weight::from_parts(32_012_031, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(p.into())))
.saturating_add(T::DbWeight::get().writes(5))
.saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(p.into())))
.saturating_add(Weight::from_parts(0, 7789).saturating_mul(p.into()))
}
}
3 changes: 2 additions & 1 deletion runtime/polkadot/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ pub type XcmRouter = (

parameter_types! {
pub const Dot: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) });
pub const DotForStatemint: (MultiAssetFilter, MultiLocation) = (Dot::get(), Parachain(STATEMINT_ID).into_location());
pub const Statemint: MultiLocation = Parachain(STATEMINT_ID).into_location();
pub const DotForStatemint: (MultiAssetFilter, MultiLocation) = (Dot::get(), Statemint::get());
pub const CollectivesLocation: MultiLocation = Parachain(COLLECTIVES_ID).into_location();
pub const DotForCollectives: (MultiAssetFilter, MultiLocation) = (Dot::get(), CollectivesLocation::get());
pub const MaxAssetsIntoHolding: u32 = 64;
Expand Down
35 changes: 28 additions & 7 deletions runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ use runtime_common::{
use scale_info::TypeInfo;
use sp_std::{cmp::Ordering, collections::btree_map::BTreeMap, prelude::*};

use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use beefy_primitives::{
crypto::{AuthorityId as BeefyId, Signature as BeefySignature},
mmr::{BeefyDataProvider, MmrLeafVersion},
};
use runtime_parachains::{
configuration as parachains_configuration, disputes as parachains_disputes,
disputes::slashing as parachains_slashing, dmp as parachains_dmp, hrmp as parachains_hrmp,
Expand All @@ -46,15 +51,10 @@ use runtime_parachains::{
runtime_api_impl::v4 as parachains_runtime_api_impl, scheduler as parachains_scheduler,
session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump,
};

use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use beefy_primitives::{
crypto::{AuthorityId as BeefyId, Signature as BeefySignature},
mmr::{BeefyDataProvider, MmrLeafVersion},
};
use sp_runtime::traits::AccountIdConversion;

use frame_support::{
construct_runtime, parameter_types,
construct_runtime, ord_parameter_types, parameter_types,
traits::{
Contains, EitherOfDiverse, InstanceFilter, KeyOwnerProofSystem, LockIdentifier,
PrivilegeCmp, StorageMapShim, WithdrawReasons,
Expand Down Expand Up @@ -83,13 +83,16 @@ use sp_staking::SessionIndex;
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use static_assertions::const_assert;
use xcm_builder::PayOverXcm;

pub use frame_system::Call as SystemCall;
pub use pallet_balances::Call as BalancesCall;

/// Constant values used within the runtime.
use rococo_runtime_constants::{currency::*, fee::*, time::*};

use crate::xcm_config::Statemine;

// Weights used in the runtime.
mod weights;

Expand Down Expand Up @@ -547,15 +550,33 @@ parameter_types! {
pub const MaxKeys: u32 = 10_000;
pub const MaxPeerInHeartbeats: u32 = 10_000;
pub const MaxPeerDataEncodingSize: u32 = 1_000;
// PayOverXcmTimeout is set to 3 x the spend period to provide buffer before status messages
// are deleted from storage
pub const PayOverXcmTimeout: BlockNumber = 6 * 3 * DAYS;
}

type ApproveOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 3, 5>,
>;

ord_parameter_types! {
pub const TreasuryAccountId: AccountId = AccountIdConversion::<AccountId>::into_account_truncating(&TreasuryPalletId::get());
}

impl pallet_treasury::Config for Runtime {
type PalletId = TreasuryPalletId;
type AssetKind = xcm::latest::AssetId;
type Paymaster = PayOverXcm<
Statemine,
TreasuryAccountId,
xcm_config::XcmRouter,
XcmPallet,
PayOverXcmTimeout,
Self::AccountId,
Self::AssetKind,
>;
type BalanceConverter = ();
type Currency = Balances;
type ApproveOrigin = ApproveOrigin;
type RejectOrigin = MoreThanHalfCouncil;
Expand Down
36 changes: 36 additions & 0 deletions runtime/rococo/src/weights/pallet_treasury.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ impl<T: frame_system::Config> pallet_treasury::WeightInfo for WeightInfo<T> {
Weight::from_parts(273_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn spend_local() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 253_000 picoseconds.
Weight::from_parts(273_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// Storage: Treasury ProposalCount (r:1 w:1)
/// Proof: Treasury ProposalCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
/// Storage: Treasury Proposals (r:0 w:1)
Expand Down Expand Up @@ -138,4 +146,32 @@ impl<T: frame_system::Config> pallet_treasury::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(p.into())))
.saturating_add(Weight::from_parts(0, 7789).saturating_mul(p.into()))
}
/// Storage: Treasury Deactivated (r:1 w:1)
/// Proof: Treasury Deactivated (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)
/// Storage: Balances InactiveIssuance (r:1 w:1)
/// Proof: Balances InactiveIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)
/// Storage: Treasury Approvals (r:1 w:1)
/// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen)
/// Storage: Treasury Proposals (r:100 w:100)
/// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen)
/// Storage: System Account (r:201 w:201)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
/// Storage: Bounties BountyApprovals (r:1 w:1)
/// Proof: Bounties BountyApprovals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen)
/// The range of component `p` is `[0, 100]`.
fn on_initialize_pending_payments(p: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `296 + p * (251 ±0)`
// Estimated: `11359 + p * (7789 ±0)`
// Minimum execution time: 60_192_000 picoseconds.
Weight::from_parts(59_512_799, 0)
.saturating_add(Weight::from_parts(0, 11359))
// Standard Error: 25_794
.saturating_add(Weight::from_parts(32_571_537, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(p.into())))
.saturating_add(T::DbWeight::get().writes(5))
.saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(p.into())))
.saturating_add(Weight::from_parts(0, 7789).saturating_mul(p.into()))
}
}

0 comments on commit f4c5bd7

Please sign in to comment.