Skip to content
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

Westend: Fellowship Treasury #2532

Merged
merged 23 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions Cargo.lock

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

Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,17 @@ match_types! {
MultiLocation { parents: 1, interior: Here } |
MultiLocation { parents: 1, interior: X1(Plurality { .. }) }
};
pub type FellowshipEntities: impl Contains<MultiLocation> = {
// Fellowship Plurality
MultiLocation { parents: 1, interior: X2(Parachain(1001), Plurality { id: BodyId::Technical, ..}) } |
// Fellowship Salary Pallet
MultiLocation { parents: 1, interior: X2(Parachain(1001), PalletInstance(64)) } |
// Fellowship Treasury Pallet
MultiLocation { parents: 1, interior: X2(Parachain(1001), PalletInstance(65)) }
};
pub type AmbassadorSalaryPallet: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: X2(Parachain(1001), PalletInstance(74)) }
};
muharem marked this conversation as resolved.
Show resolved Hide resolved
}

/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
Expand Down Expand Up @@ -488,6 +499,8 @@ pub type Barrier = TrailingSetTopicAsId<
ParentOrParentsPlurality,
Equals<RelayTreasuryLocation>,
Equals<bridging::SiblingBridgeHub>,
FellowshipEntities,
AmbassadorSalaryPallet,
)>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ frame-system = { path = "../../../../../substrate/frame/system", default-feature
frame-system-benchmarking = { path = "../../../../../substrate/frame/system/benchmarking", default-features = false, optional = true }
frame-system-rpc-runtime-api = { path = "../../../../../substrate/frame/system/rpc/runtime-api", default-features = false }
frame-try-runtime = { path = "../../../../../substrate/frame/try-runtime", default-features = false, optional = true }
pallet-asset-rate = { path = "../../../../../substrate/frame/asset-rate", default-features = false }
pallet-alliance = { path = "../../../../../substrate/frame/alliance", default-features = false }
pallet-aura = { path = "../../../../../substrate/frame/aura", default-features = false }
pallet-authorship = { path = "../../../../../substrate/frame/authorship", default-features = false }
Expand All @@ -39,6 +40,7 @@ pallet-session = { path = "../../../../../substrate/frame/session", default-feat
pallet-timestamp = { path = "../../../../../substrate/frame/timestamp", default-features = false }
pallet-transaction-payment = { path = "../../../../../substrate/frame/transaction-payment", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { path = "../../../../../substrate/frame/transaction-payment/rpc/runtime-api", default-features = false }
pallet-treasury = { path = "../../../../../substrate/frame/treasury", default-features = false }
pallet-utility = { path = "../../../../../substrate/frame/utility", default-features = false }
pallet-referenda = { path = "../../../../../substrate/frame/referenda", default-features = false }
pallet-ranked-collective = { path = "../../../../../substrate/frame/ranked-collective", default-features = false }
Expand Down Expand Up @@ -107,6 +109,7 @@ runtime-benchmarks = [
"frame-system-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-alliance/runtime-benchmarks",
"pallet-asset-rate/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-collator-selection/runtime-benchmarks",
"pallet-collective-content/runtime-benchmarks",
Expand All @@ -121,6 +124,7 @@ runtime-benchmarks = [
"pallet-salary/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-treasury/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"parachains-common/runtime-benchmarks",
Expand All @@ -142,6 +146,7 @@ try-runtime = [
"frame-system/try-runtime",
"frame-try-runtime/try-runtime",
"pallet-alliance/try-runtime",
"pallet-asset-rate/try-runtime",
"pallet-aura/try-runtime",
"pallet-authorship/try-runtime",
"pallet-balances/try-runtime",
Expand All @@ -160,6 +165,7 @@ try-runtime = [
"pallet-session/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-transaction-payment/try-runtime",
"pallet-treasury/try-runtime",
"pallet-utility/try-runtime",
"pallet-xcm/try-runtime",
"parachain-info/try-runtime",
Expand All @@ -185,6 +191,7 @@ std = [
"frame-try-runtime?/std",
"log/std",
"pallet-alliance/std",
"pallet-asset-rate/std",
"pallet-aura/std",
"pallet-authorship/std",
"pallet-balances/std",
Expand All @@ -204,6 +211,7 @@ std = [
"pallet-timestamp/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
"pallet-treasury/std",
"pallet-utility/std",
"pallet-xcm/std",
"parachain-info/std",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,39 @@ mod tracks;
use crate::{
impls::ToParentTreasury,
weights,
xcm_config::{FellowshipAdminBodyId, UsdtAssetHub},
AccountId, Balance, Balances, FellowshipReferenda, GovernanceLocation, Preimage, Runtime,
RuntimeCall, RuntimeEvent, RuntimeOrigin, Scheduler, WestendTreasuryAccount, DAYS,
xcm_config::{FellowshipAdminBodyId, TreasurerBodyId, UsdtAssetHub},
AccountId, AssetRate, Balance, Balances, BlockNumber, FellowshipReferenda, GovernanceLocation,
Preimage, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, Scheduler, WestendTreasuryAccount,
DAYS,
};
use frame_support::{
parameter_types,
traits::{EitherOf, EitherOfDiverse, MapSuccess, OriginTrait, TryWithMorphedArg},
traits::{
EitherOf, EitherOfDiverse, MapSuccess, NeverEnsureOrigin, OriginTrait, TryWithMorphedArg,
},
PalletId,
};
use frame_system::EnsureRootWithSuccess;
use frame_system::{EnsureRoot, EnsureRootWithSuccess};
pub use origins::{
pallet_origins as pallet_fellowship_origins, Architects, EnsureCanPromoteTo, EnsureCanRetainAt,
EnsureFellowship, Fellows, Masters, Members, ToVoice,
EnsureFellowship, Fellows, Fellowship5Dan, Masters, Members, ToVoice,
};
use pallet_ranked_collective::EnsureOfRank;
use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
use parachains_common::{polkadot::account, HOURS};
use sp_core::{ConstU128, ConstU32};
use sp_runtime::traits::{AccountIdConversion, ConstU16, ConvertToValue, Replace, TakeFirst};
use polkadot_runtime_common::impls::{
LocatableAssetConverter, VersionedLocatableAsset, VersionedMultiLocationConverter,
};
use sp_arithmetic::Permill;
use sp_core::{ConstU128, ConstU32, ConstU8};
use sp_runtime::traits::{
AccountIdConversion, ConstU16, ConvertToValue, IdentityLookup, Replace, TakeFirst,
};
use testnets_common::westend::{
account,
currency::{DOLLARS, GRAND},
};
use westend_runtime_constants::time::HOURS;
use xcm::prelude::*;
use xcm_builder::{AliasesIntoAccountId32, PayOverXcm};

#[cfg(feature = "runtime-benchmarks")]
Expand Down Expand Up @@ -191,8 +206,6 @@ impl pallet_core_fellowship::Config<FellowshipCoreInstance> for Runtime {

pub type FellowshipSalaryInstance = pallet_salary::Instance1;

use xcm::prelude::*;

parameter_types! {
// The interior location on AssetHub for the paying account. This is the Fellowship Salary
// pallet instance (which sits at index 64). This sovereign account will need funding.
Expand Down Expand Up @@ -236,3 +249,72 @@ impl pallet_salary::Config<FellowshipSalaryInstance> for Runtime {
// Total monthly salary budget.
type Budget = ConstU128<{ 100_000 * USDT_UNITS }>;
}

parameter_types! {
pub const FellowshipTreasuryPalletId: PalletId = account::FELLOWSHIP_TREASURY_PALLET_ID;
pub const ProposalBond: Permill = Permill::from_percent(1);
pub const ProposalBondMinimum: Balance = 5 * DOLLARS;
pub const ProposalBondMaximum: Balance = 10 * DOLLARS;
pub const SpendPeriod: BlockNumber = 7 * DAYS;
pub const Burn: Permill = Permill::from_percent(0);
pub const PayoutSpendPeriod: BlockNumber = 30 * DAYS;
// The asset's interior location for the paying account. This is the Fellowship Treasury
// pallet instance (which sits at index 65).
pub FellowshipTreasuryInteriorLocation: InteriorMultiLocation = PalletInstance(65).into();
}

/// [`PayOverXcm`] setup to pay the Fellowship Treasury.
pub type FellowshipTreasuryPaymaster = PayOverXcm<
FellowshipTreasuryInteriorLocation,
crate::xcm_config::XcmRouter,
crate::PolkadotXcm,
ConstU32<{ 6 * HOURS }>,
VersionedMultiLocation,
VersionedLocatableAsset,
LocatableAssetConverter,
VersionedMultiLocationConverter,
>;

pub type FellowshipTreasuryInstance = pallet_treasury::Instance1;

impl pallet_treasury::Config<FellowshipTreasuryInstance> for Runtime {
type WeightInfo = weights::pallet_treasury::WeightInfo<Runtime>;
type PalletId = FellowshipTreasuryPalletId;
type Currency = Balances;
// This parameter guards a deprecated call and should not be used.
type ApproveOrigin = NeverEnsureOrigin<()>;
type RejectOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
EitherOfDiverse<EnsureXcm<IsVoiceOfBody<GovernanceLocation, TreasurerBodyId>>, Fellows>,
>;
type RuntimeEvent = RuntimeEvent;
// This type is never triggered until [`Self::ApproveOrigin``] is [`NeverEnsureOrigin`].
type OnSlash = ();
muharem marked this conversation as resolved.
Show resolved Hide resolved
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type ProposalBondMaximum = ProposalBondMaximum;
type SpendPeriod = SpendPeriod;
type Burn = Burn;
type BurnDestination = ();
type SpendFunds = ();
type MaxApprovals = ConstU32<100>;
type SpendOrigin = EitherOf<
EnsureRootWithSuccess<AccountId, ConstU128<{ 10_000 * GRAND }>>,
EitherOf<
MapSuccess<Fellowship5Dan, Replace<ConstU128<{ 10_000 * GRAND }>>>,
MapSuccess<Fellows, Replace<ConstU128<{ 10 * GRAND }>>>,
muharem marked this conversation as resolved.
Show resolved Hide resolved
>,
>;
type AssetKind = VersionedLocatableAsset;
type Beneficiary = VersionedMultiLocation;
type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;
#[cfg(not(feature = "runtime-benchmarks"))]
type Paymaster = FellowshipTreasuryPaymaster;
#[cfg(feature = "runtime-benchmarks")]
type Paymaster = PayWithEnsure<FellowshipTreasuryPaymaster, OpenHrmpChannel<ConstU32<1000>>>;
type BalanceConverter = AssetRate;
type PayoutPeriod = PayoutSpendPeriod;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper =
polkadot_runtime_common::impls::benchmarks::TreasuryArguments<ConstU8<1>, ConstU32<1000>>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ pub mod pallet_origins {
Members: Rank = ranks::DAN_1,
Fellows: Rank = ranks::DAN_3,
Architects: Rank = ranks::DAN_4,
Fellowship5Dan: Rank = ranks::DAN_5,
Masters: Rank = ranks::DAN_7,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,16 @@ use parachains_common::{
};
use sp_runtime::RuntimeDebug;
use testnets_common::westend::{account::*, consensus::*, currency::*, fee::WeightToFee};
use xcm_config::{GovernanceLocation, XcmOriginToTransactDispatchOrigin};
use xcm_config::{GovernanceLocation, TreasurerBodyId, XcmOriginToTransactDispatchOrigin};

#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;

// Polkadot imports
use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
use polkadot_runtime_common::{
impls::VersionedLocatableAsset, BlockHashCount, SlowAdjustingFeeUpdate,
};
use xcm::latest::{prelude::*, BodyId};

use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
Expand Down Expand Up @@ -330,6 +332,7 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
RuntimeCall::FellowshipReferenda { .. } |
RuntimeCall::FellowshipCore { .. } |
RuntimeCall::FellowshipSalary { .. } |
RuntimeCall::FellowshipTreasury { .. } |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
),
Expand Down Expand Up @@ -624,6 +627,21 @@ impl pallet_preimage::Config for Runtime {
>;
}

impl pallet_asset_rate::Config for Runtime {
type WeightInfo = weights::pallet_asset_rate::WeightInfo<Runtime>;
type RuntimeEvent = RuntimeEvent;
type CreateOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
EitherOfDiverse<EnsureXcm<IsVoiceOfBody<GovernanceLocation, TreasurerBodyId>>, Fellows>,
>;
type RemoveOrigin = Self::CreateOrigin;
type UpdateOrigin = Self::CreateOrigin;
type Currency = Balances;
type AssetKind = VersionedLocatableAsset;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = polkadot_runtime_common::impls::benchmarks::AssetRateArguments;
}

// Create the runtime by composing the FRAME pallets that were previously configured.
construct_runtime!(
pub enum Runtime
Expand Down Expand Up @@ -660,6 +678,7 @@ construct_runtime!(
Proxy: pallet_proxy::{Pallet, Call, Storage, Event<T>} = 42,
Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>, HoldReason} = 43,
Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 44,
AssetRate: pallet_asset_rate::{Pallet, Call, Storage, Event<T>} = 45,

// The main stage.

Expand All @@ -677,6 +696,8 @@ construct_runtime!(
FellowshipCore: pallet_core_fellowship::<Instance1>::{Pallet, Call, Storage, Event<T>} = 63,
// pub type FellowshipSalaryInstance = pallet_salary::Instance1;
FellowshipSalary: pallet_salary::<Instance1>::{Pallet, Call, Storage, Event<T>} = 64,
// pub type FellowshipTreasuryInstance = pallet_treasury::Instance1;
FellowshipTreasury: pallet_treasury::<Instance1>::{Pallet, Call, Storage, Event<T>} = 65,

// Ambassador Program.
AmbassadorCollective: pallet_ranked_collective::<Instance2>::{Pallet, Call, Storage, Event<T>} = 70,
Expand Down Expand Up @@ -755,6 +776,8 @@ mod benches {
[pallet_collective_content, AmbassadorContent]
[pallet_core_fellowship, AmbassadorCore]
[pallet_salary, AmbassadorSalary]
[pallet_treasury, FellowshipTreasury]
[pallet_asset_rate, AssetRate]
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub mod cumulus_pallet_xcmp_queue;
pub mod extrinsic_weights;
pub mod frame_system;
pub mod pallet_alliance;
pub mod pallet_asset_rate;
pub mod pallet_balances;
pub mod pallet_collator_selection;
pub mod pallet_collective;
Expand All @@ -39,6 +40,7 @@ pub mod pallet_salary_fellowship_salary;
pub mod pallet_scheduler;
pub mod pallet_session;
pub mod pallet_timestamp;
pub mod pallet_treasury;
pub mod pallet_utility;
pub mod pallet_xcm;
pub mod paritydb_weights;
Expand Down
Loading
Loading