Skip to content

Commit

Permalink
Westend: Fellowship Treasury (#2532)
Browse files Browse the repository at this point in the history
Treasury Pallet Instance for the Fellowship in Westend Collectives.

In this update, we present a Treasury Pallet Instance that is under the
control of the Fellowship body, with oversight from the Root and
Treasurer origins. Here's how it is governed:
- the Root origin have the authority to reject or approve spend
proposals, with no amount limit for approvals.
- the Treasurer origin have the authority to reject or approve spend
proposals, with approval limits of up to 10,000,000 DOT.
- Voice of all Fellows ranked at 3 or above can reject or approve spend
proposals, with a maximum approval limit of 10,000 DOT.
- Voice of Fellows ranked at 4 or above can also reject or approve spend
proposals, with a maximum approval limit of 10,000,000 DOT.

Additionally, we introduce the Asset Rate Pallet Instance to establish
conversion rates from asset A to B. This is used to determine if a
proposed spend amount involving a non-native asset is permissible by the
commanding origin. The rates can be set up by the Root, Treasurer
origins, or Voice of all Fellows.

---------

Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
Co-authored-by: joepetrowski <joe@parity.io>
  • Loading branch information
3 people authored Dec 8, 2023
1 parent 1bdfb29 commit da40d97
Show file tree
Hide file tree
Showing 26 changed files with 827 additions and 27 deletions.
19 changes: 19 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 @@ -66,6 +66,7 @@ members = [
"cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-westend",
"cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-rococo",
"cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend",
"cumulus/parachains/integration-tests/emulated/chains/parachains/collectives/collectives-westend",
"cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal",
"cumulus/parachains/integration-tests/emulated/chains/relays/rococo",
"cumulus/parachains/integration-tests/emulated/chains/relays/westend",
Expand Down
2 changes: 2 additions & 0 deletions cumulus/parachains/common/src/polkadot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ pub mod account {
/// It is used as a temporarily place to deposit a slashed imbalance
/// before the teleport to the Treasury.
pub const AMBASSADOR_REFERENDA_PALLET_ID: PalletId = PalletId(*b"py/amref");
/// Fellowship treasury pallet ID
pub const FELLOWSHIP_TREASURY_PALLET_ID: PalletId = PalletId(*b"py/feltr");
}

/// Consensus-related.
Expand Down
2 changes: 2 additions & 0 deletions cumulus/parachains/common/src/westend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ pub mod account {
/// Ambassador Referenda pallet ID - used as a temporary place to deposit a slashed imbalance
/// before the teleport to the Treasury.
pub const AMBASSADOR_REFERENDA_PALLET_ID: PalletId = PalletId(*b"py/amref");
/// Fellowship treasury pallet ID.
pub const FELLOWSHIP_TREASURY_PALLET_ID: PalletId = PalletId(*b"py/feltr");
}

pub mod currency {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "collectives-westend-emulated-chain"
version = "0.0.0"
authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
description = "Collectives Westend emulated chain"
publish = false

[dependencies]
serde_json = "1.0.104"

# Substrate
sp-core = { path = "../../../../../../../../substrate/primitives/core", default-features = false }
sp-runtime = { path = "../../../../../../../../substrate/primitives/runtime", default-features = false }
frame-support = { path = "../../../../../../../../substrate/frame/support", default-features = false }

# Polakadot
parachains-common = { path = "../../../../../../../parachains/common" }

# Cumulus
cumulus-primitives-core = { path = "../../../../../../../primitives/core", default-features = false }
emulated-integration-tests-common = { path = "../../../../common", default-features = false }
collectives-westend-runtime = { path = "../../../../../../runtimes/collectives/collectives-westend" }
westend-emulated-chain = { path = "../../../relays/westend" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Substrate
use sp_core::storage::Storage;

// Cumulus
use emulated_integration_tests_common::{
accounts, build_genesis_storage, collators, SAFE_XCM_VERSION,
};
use parachains_common::Balance;

pub const PARA_ID: u32 = 1001;
pub const ED: Balance = parachains_common::westend::currency::EXISTENTIAL_DEPOSIT;

pub fn genesis() -> Storage {
let genesis_config = collectives_westend_runtime::RuntimeGenesisConfig {
system: collectives_westend_runtime::SystemConfig::default(),
balances: collectives_westend_runtime::BalancesConfig {
balances: accounts::init_balances().iter().cloned().map(|k| (k, ED * 4096)).collect(),
},
parachain_info: collectives_westend_runtime::ParachainInfoConfig {
parachain_id: PARA_ID.into(),
..Default::default()
},
collator_selection: collectives_westend_runtime::CollatorSelectionConfig {
invulnerables: collators::invulnerables().iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: ED * 16,
..Default::default()
},
session: collectives_westend_runtime::SessionConfig {
keys: collators::invulnerables()
.into_iter()
.map(|(acc, aura)| {
(
acc.clone(), // account id
acc, // validator id
collectives_westend_runtime::SessionKeys { aura }, // session keys
)
})
.collect(),
},
polkadot_xcm: collectives_westend_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
},
..Default::default()
};

build_genesis_storage(
&genesis_config,
collectives_westend_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

pub mod genesis;

// Substrate
use frame_support::traits::OnInitialize;

// Cumulus
use emulated_integration_tests_common::{
impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain,
impls::Parachain, xcm_emulator::decl_test_parachains,
};

// CollectivesWestend Parachain declaration
decl_test_parachains! {
pub struct CollectivesWestend {
genesis = genesis::genesis(),
on_init = {
collectives_westend_runtime::AuraExt::on_initialize(1);
},
runtime = collectives_westend_runtime,
core = {
XcmpMessageHandler: collectives_westend_runtime::XcmpQueue,
LocationToAccountId: collectives_westend_runtime::xcm_config::LocationToAccountId,
ParachainInfo: collectives_westend_runtime::ParachainInfo,
},
pallets = {
PolkadotXcm: collectives_westend_runtime::PolkadotXcm,
Balances: collectives_westend_runtime::Balances,
FellowshipTreasury: collectives_westend_runtime::FellowshipTreasury,
AssetRate: collectives_westend_runtime::AssetRate,
}
},
}

// AssetHubWestend implementation
impl_accounts_helpers_for_parachain!(CollectivesWestend);
impl_assert_events_helpers_for_parachain!(CollectivesWestend);
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ emulated-integration-tests-common = { path = "../../common", default-features =
westend-emulated-chain = { path = "../../chains/relays/westend", default-features = false }
asset-hub-westend-emulated-chain = { path = "../../chains/parachains/assets/asset-hub-westend" }
bridge-hub-westend-emulated-chain = { path = "../../chains/parachains/bridges/bridge-hub-westend" }
collectives-westend-emulated-chain = { path = "../../chains/parachains/collectives/collectives-westend" }
penpal-emulated-chain = { path = "../../chains/parachains/testing/penpal" }
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@

pub use asset_hub_westend_emulated_chain;
pub use bridge_hub_westend_emulated_chain;
pub use collectives_westend_emulated_chain;
pub use penpal_emulated_chain;
pub use westend_emulated_chain;

use asset_hub_westend_emulated_chain::AssetHubWestend;
use bridge_hub_westend_emulated_chain::BridgeHubWestend;
use collectives_westend_emulated_chain::CollectivesWestend;
use penpal_emulated_chain::{PenpalA, PenpalB};
use westend_emulated_chain::Westend;

Expand All @@ -35,6 +37,7 @@ decl_test_networks! {
parachains = vec![
AssetHubWestend,
BridgeHubWestend,
CollectivesWestend,
PenpalA,
PenpalB,
],
Expand All @@ -46,6 +49,7 @@ decl_test_sender_receiver_accounts_parameter_types! {
WestendRelay { sender: ALICE, receiver: BOB },
AssetHubWestendPara { sender: ALICE, receiver: BOB },
BridgeHubWestendPara { sender: ALICE, receiver: BOB },
CollectivesWestendPara { sender: ALICE, receiver: BOB },
PenpalAPara { sender: ALICE, receiver: BOB },
PenpalBPara { sender: ALICE, receiver: BOB }
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ parachains-common = { path = "../../../../../../parachains/common" }
asset-hub-westend-runtime = { path = "../../../../../runtimes/assets/asset-hub-westend" }
asset-test-utils = { path = "../../../../../runtimes/assets/test-utils" }
cumulus-pallet-dmp-queue = { default-features = false, path = "../../../../../../pallets/dmp-queue" }
cumulus-pallet-xcmp-queue = { default-features = false, path = "../../../../../../pallets/xcmp-queue" }
cumulus-pallet-parachain-system = { default-features = false, path = "../../../../../../pallets/parachain-system" }
emulated-integration-tests-common = { path = "../../../common", default-features = false }
westend-system-emulated-network = { path = "../../../networks/westend-system" }
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,16 @@ pub use westend_system_emulated_network::{
asset_hub_westend_emulated_chain::{
genesis::ED as ASSET_HUB_WESTEND_ED, AssetHubWestendParaPallet as AssetHubWestendPallet,
},
collectives_westend_emulated_chain::{
genesis::ED as COLLECTIVES_WESTEND_ED,
CollectivesWestendParaPallet as CollectivesWestendPallet,
},
penpal_emulated_chain::PenpalBParaPallet as PenpalBPallet,
westend_emulated_chain::{genesis::ED as WESTEND_ED, WestendRelayPallet as WestendPallet},
AssetHubWestendPara as AssetHubWestend, AssetHubWestendParaReceiver as AssetHubWestendReceiver,
AssetHubWestendParaSender as AssetHubWestendSender, BridgeHubWestendPara as BridgeHubWestend,
BridgeHubWestendParaReceiver as BridgeHubWestendReceiver, PenpalBPara as PenpalB,
BridgeHubWestendParaReceiver as BridgeHubWestendReceiver,
CollectivesWestendPara as CollectivesWestend, PenpalBPara as PenpalB,
PenpalBParaReceiver as PenpalBReceiver, PenpalBParaSender as PenpalBSender,
WestendRelay as Westend, WestendRelayReceiver as WestendReceiver,
WestendRelaySender as WestendSender,
Expand Down
Loading

0 comments on commit da40d97

Please sign in to comment.