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

Runtime: Polkadot Fellowship promotion/demotion periods, members activity and salaries #2607

Merged
merged 32 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
13bb75e
core fellowship
muharem May 19, 2023
de643ea
core fellowship weights
muharem May 19, 2023
16b0815
salary
muharem May 20, 2023
102fdcf
Merge remote-tracking branch 'origin/master' into muharem-core-fellow…
muharem May 20, 2023
c4a7425
weights
muharem May 20, 2023
ffbb342
fellowship pot
muharem May 20, 2023
ad45934
registration period 15 days
muharem May 22, 2023
bc05ae6
use treasury account for salary pay, promotion origin
muharem May 25, 2023
e3d744a
decision period for tracks 30 days
muharem May 25, 2023
2c556af
docs
muharem May 25, 2023
fa1d47f
comment
muharem May 25, 2023
9787bc1
Merge remote-tracking branch 'origin/master' into muharem-core-fellow…
gavofyork May 29, 2023
5092d3c
Couple of fixes and some refactoring
gavofyork Jun 1, 2023
c7f3292
Alter curves to be a bit more conservative
gavofyork Jun 1, 2023
7c245b3
Use `PayOverXcm` for fellowship salary payments
gavofyork Jun 1, 2023
320b12c
Merge remote-tracking branch 'origin/master' into muharem-core-fellow…
gavofyork Jun 1, 2023
842bc9d
Docs and remove unneeded code
gavofyork Jun 1, 2023
f3ede4c
Fixes
gavofyork Jun 1, 2023
be0a235
Move Fellowship stuff in line with whitepaper
gavofyork Jun 2, 2023
3b58f19
fix: induction by a single Fellow (not proficient)
muharem Jun 2, 2023
2a882f9
doc fix
muharem Jun 2, 2023
9cc708b
renames, pallet index, allow unpaid for salary pallet
muharem Jun 4, 2023
b37bbe4
Merge remote-tracking branch 'origin/master' into muharem-core-fellow…
gavofyork Jun 5, 2023
44ffd21
Fix budget units
gavofyork Jun 5, 2023
f53b4a4
Fixes
gavofyork Jun 5, 2023
d83fd85
Merge remote-tracking branch 'origin/master' into muharem-core-fellow…
gavofyork Jun 5, 2023
459977b
Test sovereign account for Fellowship salaries
gavofyork Jun 5, 2023
1c9b566
Nice address test
gavofyork Jun 5, 2023
7b9cf0f
Fixes
gavofyork Jun 5, 2023
caaa989
test for PayOverXcm setup
muharem Jun 5, 2023
af2d1f2
Merge remote-tracking branch 'origin/master' into muharem-core-fellow…
muharem Jun 5, 2023
cf929c3
Update parachains/runtimes/collectives/collectives-polkadot/src/fello…
gavofyork Jun 6, 2023
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
31 changes: 31 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ members = [
"parachains/integration-tests/emulated/assets/asset-hub-kusama",
"parachains/integration-tests/emulated/assets/asset-hub-polkadot",
"parachains/integration-tests/emulated/assets/asset-hub-westend",
"parachains/integration-tests/emulated/collectives/collectives-polkadot",
"test/client",
"test/relay-sproof-builder",
"test/relay-validation-worker-provider",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[package]
name = "collectives-polkadot-it"
version = "0.1.0"
authors = ["Parity Technologies <[email protected]>"]
edition = "2021"
description = "Polkadot Collectives parachain runtime integration tests based on xcm-emulator"

[dev-dependencies]
codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false }

# Substrate
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
sp-weights = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-assets = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-core-fellowship = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-salary = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }

# Polkadot
polkadot-core-primitives = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-parachain = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "master" }
xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" }
xcm-executor = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" }
pallet-xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" }

# Cumulus
parachains-common = { path = "../../../../common" }
cumulus-pallet-xcmp-queue = { default-features = false, path = "../../../../../pallets/xcmp-queue" }
collectives-polkadot-runtime = { path = "../../../../runtimes/collectives/collectives-polkadot" }
asset-hub-polkadot-runtime = { path = "../../../../runtimes/assets/asset-hub-polkadot" }

# Local
xcm-emulator = { default-features = false, path = "../../../../../xcm/xcm-emulator" }
integration-tests-common = { default-features = false, path = "../../common" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright Parity Technologies (UK) Ltd.
// This file is part of Cumulus.

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

//! Collectives Parachain integration tests based on xcm-emulator.
#![cfg(test)]

pub use frame_support::assert_ok;
pub use integration_tests_common::{
constants::accounts::ALICE, AccountId, AssetHubPolkadot as AssetHub,
AssetHubPolkadotPallet as AssetHubPallet, Collectives, CollectivesPallet, Polkadot,
PolkadotMockNet,
};
pub use xcm::prelude::*;
pub use xcm_emulator::{assert_expected_events, Parachain};

mod tests;
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Copyright Parity Technologies (UK) Ltd.
// This file is part of Cumulus.

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

//! Integration tests concerning the Fellowship.
use crate::*;
use collectives_polkadot_runtime::fellowship::FellowshipSalaryPaymaster;
use frame_support::traits::{
fungibles::{Create, Mutate},
tokens::Pay,
};
use sp_core::crypto::Ss58Codec;
use xcm_emulator::{Network, TestExt};

#[test]
fn pay_salary() {
let asset_id: u32 = 1984;
let pay_from: AccountId =
<AccountId as Ss58Codec>::from_string("13w7NdvSR1Af8xsQTArDtZmVvjE8XhWNdL4yed3iFHrUNCnS")
.unwrap();
let pay_to = Polkadot::account_id_of(ALICE);
let pay_amount = 9000;

PolkadotMockNet::_init();
PolkadotMockNet::reset();

AssetHub::execute_with(|| {
type AssetHubAssets = <AssetHub as AssetHubPallet>::Assets;

assert_ok!(<AssetHubAssets as Create<_>>::create(
asset_id,
pay_to.clone(),
true,
pay_amount / 2
));
assert_ok!(<AssetHubAssets as Mutate<_>>::mint_into(asset_id, &pay_from, pay_amount * 2));
});

Collectives::execute_with(|| {
type RuntimeEvent = <Collectives as Parachain>::RuntimeEvent;

assert_ok!(FellowshipSalaryPaymaster::pay(&pay_to, (), pay_amount));
assert_expected_events!(
Collectives,
vec![
RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {},
]
);
});

AssetHub::execute_with(|| {
type RuntimeEvent = <AssetHub as Parachain>::RuntimeEvent;

assert_expected_events!(
AssetHub,
vec![
RuntimeEvent::Assets(pallet_assets::Event::Transferred { asset_id: id, from, to, amount }) => {
asset_id: id == &asset_id,
from: from == &pay_from,
to: to == &pay_to,
amount: amount == &pay_amount,
},
RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success { .. }) => {},
]
);
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright Parity Technologies (UK) Ltd.
// This file is part of Cumulus.

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

mod fellowship;
13 changes: 8 additions & 5 deletions parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter,
DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FungiblesAdapter, IsConcrete,
LocalMint, NativeAsset, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, DescribeFamily,
EnsureXcmOrigin, FungiblesAdapter, HashedDescription, IsConcrete, LocalMint, NativeAsset,
NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
};
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};

Expand Down Expand Up @@ -66,6 +67,8 @@ pub type LocationToAccountId = (
SiblingParachainConvertsVia<Sibling, AccountId>,
// Straight up local `AccountId32` origins just alias directly to `AccountId`.
AccountId32Aliases<RelayNetwork, AccountId>,
// Foreign locations alias into accounts according to a hash of their standard description.
HashedDescription<AccountId, DescribeFamily<DescribeAllTerminal>>,
);

/// Means for transacting the native currency on this chain.
Expand Down
38 changes: 32 additions & 6 deletions parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter,
DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FungiblesAdapter, IsConcrete,
LocalMint, NativeAsset, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
WeightInfoBounds, WithComputedOrigin,
DenyReserveTransferToRelayChain, DenyThenTry, DescribeFamily, DescribePalletTerminal,
EnsureXcmOrigin, FungiblesAdapter, HashedDescription, IsConcrete, LocalMint, NativeAsset,
NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds,
WithComputedOrigin,
};
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};

Expand Down Expand Up @@ -66,6 +67,9 @@ pub type LocationToAccountId = (
SiblingParachainConvertsVia<Sibling, AccountId>,
// Straight up local `AccountId32` origins just alias directly to `AccountId`.
AccountId32Aliases<RelayNetwork, AccountId>,
// Foreign chain account alias into local accounts according to a hash of their standard
// description.
HashedDescription<AccountId, DescribeFamily<DescribePalletTerminal>>,
);

/// Means for transacting the native currency on this chain.
Expand Down Expand Up @@ -177,6 +181,9 @@ match_types! {
pub type FellowsPlurality: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: X2(Parachain(1001), Plurality { id: BodyId::Technical, ..}) }
};
pub type FellowshipSalaryPallet: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: X2(Parachain(1001), PalletInstance(64)) }
};
}

/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
Expand Down Expand Up @@ -355,7 +362,11 @@ pub type Barrier = DenyThenTry<
// If the message is one that immediately attemps to pay for execution, then allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Parent, its pluralities (i.e. governance bodies), and the Fellows plurality get free execution.
AllowExplicitUnpaidExecutionFrom<(ParentOrParentsPlurality, FellowsPlurality)>,
AllowExplicitUnpaidExecutionFrom<(
ParentOrParentsPlurality,
FellowsPlurality,
FellowshipSalaryPallet,
)>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<ParentOrSiblings>,
),
Expand Down Expand Up @@ -497,3 +508,18 @@ impl pallet_assets::BenchmarkHelper<MultiLocation> for XcmBenchmarkHelper {
MultiLocation { parents: 1, interior: X1(Parachain(id)) }
}
}

#[test]
fn foreign_pallet_has_correct_local_account() {
use sp_core::crypto::{Ss58AddressFormat, Ss58Codec};
use xcm_executor::traits::ConvertLocation;

const COLLECTIVES_PARAID: u32 = 1001;
const FELLOWSHIP_SALARY_PALLET_ID: u8 = 64;
let fellowship_salary =
(Parent, Parachain(COLLECTIVES_PARAID), PalletInstance(FELLOWSHIP_SALARY_PALLET_ID));
let account = LocationToAccountId::convert_location(&fellowship_salary.into()).unwrap();
let polkadot = Ss58AddressFormat::try_from("polkadot").unwrap();
let address = Ss58Codec::to_ss58check_with_version(&account, polkadot);
assert_eq!(address, "13w7NdvSR1Af8xsQTArDtZmVvjE8XhWNdL4yed3iFHrUNCnS");
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/parityt
pallet-utility = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-referenda = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-ranked-collective = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-core-fellowship = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-salary = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-arithmetic = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" }
sp-block-builder = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
Expand Down Expand Up @@ -103,6 +105,8 @@ runtime-benchmarks = [
"pallet-preimage/runtime-benchmarks",
"pallet-referenda/runtime-benchmarks",
"pallet-ranked-collective/runtime-benchmarks",
"pallet-core-fellowship/runtime-benchmarks",
"pallet-salary/runtime-benchmarks",
]
try-runtime = [
"cumulus-pallet-aura-ext/try-runtime",
Expand Down Expand Up @@ -131,6 +135,8 @@ try-runtime = [
"pallet-preimage/try-runtime",
"pallet-referenda/try-runtime",
"pallet-ranked-collective/try-runtime",
"pallet-core-fellowship/try-runtime",
"pallet-salary/try-runtime",
]
std = [
"codec/std",
Expand Down Expand Up @@ -187,4 +193,6 @@ std = [
"pallet-referenda/std",
"pallet-ranked-collective/std",
"substrate-wasm-builder",
"pallet-core-fellowship/std",
"pallet-salary/std",
]
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
pub mod account {
use frame_support::PalletId;

/// Relay Chain treasury pallet id, used to convert into AccountId
pub const RELAY_TREASURY_PALLET_ID: PalletId = PalletId(*b"py/trsry");
/// Polkadot treasury pallet id, used to convert into AccountId
pub const POLKADOT_TREASURY_PALLET_ID: PalletId = PalletId(*b"py/trsry");
/// Alliance pallet ID.
/// It is used as a temporarily place to deposit a slashed imbalance
/// before the teleport to the Treasury.
Expand Down
Loading