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

Secretary Program #4764

Closed
Closed
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ members = [
"cumulus/parachains/runtimes/bridge-hubs/common",
"cumulus/parachains/runtimes/bridge-hubs/test-utils",
"cumulus/parachains/runtimes/collectives/collectives-westend",
"cumulus/parachains/runtimes/collectives/collectives-westend/constants",
"cumulus/parachains/runtimes/constants",
"cumulus/parachains/runtimes/contracts/contracts-rococo",
"cumulus/parachains/runtimes/coretime/coretime-rococo",
Expand Down Expand Up @@ -661,6 +662,7 @@ coarsetime = { version = "0.1.22" }
codec = { version = "3.6.12", default-features = false, package = "parity-scale-codec" }
collectives-westend-emulated-chain = { path = "cumulus/parachains/integration-tests/emulated/chains/parachains/collectives/collectives-westend" }
collectives-westend-runtime = { path = "cumulus/parachains/runtimes/collectives/collectives-westend" }
collectives-westend-runtime-constants = { path = "cumulus/parachains/runtimes/collectives/collectives-westend/constants" }
color-eyre = { version = "0.6.1", default-features = false }
color-print = { version = "0.3.4" }
colored = { version = "2.0.4" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ parachains-common = { workspace = true, default-features = true }
cumulus-primitives-core = { workspace = true }
emulated-integration-tests-common = { workspace = true }
collectives-westend-runtime = { workspace = true }
collectives-westend-runtime-constants = { workspace = true }
testnet-parachains-constants = { features = ["westend"], workspace = true, default-features = true }
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ parachain-info = { workspace = true }
parachains-common = { workspace = true }
testnet-parachains-constants = { features = ["westend"], workspace = true }
assets-common = { workspace = true }
collectives-westend-runtime-constants = { workspace = true }

# Bridges
pallet-xcm-bridge-hub-router = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ use xcm_builder::{
};
use xcm_executor::XcmExecutor;

use westend_runtime_constants::system_parachain;
use collectives_westend_runtime_constants;

parameter_types! {
pub const WestendLocation: Location = Location::parent();
pub const WestendLocationV3: xcm::v3::Location = xcm::v3::Location::parent();
Expand Down Expand Up @@ -256,22 +259,35 @@ impl Contains<Location> for ParentOrParentsPlurality {
}
}

/// Location type to determine the Technical Fellowship related
/// pallets for use in XCM
pub struct FellowshipEntities;
impl Contains<Location> for FellowshipEntities {
fn contains(location: &Location) -> bool {
matches!(
location.unpack(),
(1, [Parachain(1001), Plurality { id: BodyId::Technical, .. }]) |
(1, [Parachain(1001), PalletInstance(64)]) |
(1, [Parachain(1001), PalletInstance(65)])
(1, [Parachain(COLLECTIVES_ID), Plurality { id: BodyId::Technical, .. }]) |
(1, [Parachain(COLLECTIVES_ID), PalletInstance(FELLOWSHIP_SALARY_PALLET_INDEX)]) |
(1, [Parachain(COLLECTIVES_ID), PalletInstance(FELLOWSHIP_TREASURY_PALLET_INDEX)])
)
}
}

/// Location type to determine the Ambassador Collective
/// pallets for use in XCM
pub struct AmbassadorEntities;
impl Contains<Location> for AmbassadorEntities {
fn contains(location: &Location) -> bool {
matches!(location.unpack(), (1, [Parachain(1001), PalletInstance(74)]))
matches!(location.unpack(), (1, [Parachain(COLLECTIVES_ID), PalletInstance(AMBASSADOR_SALARY_PALLET_INDEX)]))
}
}

/// Location type to determine the Secretary Collective related
/// pallets for use in XCM
pub struct SecretaryEntities;
Doordashcon marked this conversation as resolved.
Show resolved Hide resolved
impl Contains<Location> for SecretaryEntities {
fn contains(location: &Location) -> bool {
matches!(location.unpack(), (1, [Parachain(COLLECTIVES_ID), PalletInstance(SECRETARY_SALARY_PALLET_INDEX)]))
}
}

Expand All @@ -296,6 +312,7 @@ pub type Barrier = TrailingSetTopicAsId<
Equals<bridging::SiblingBridgeHub>,
FellowshipEntities,
AmbassadorEntities,
SecretaryEntities,
)>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
Expand Down Expand Up @@ -338,6 +355,7 @@ pub type WaivedLocations = (
Equals<RelayTreasuryLocation>,
FellowshipEntities,
AmbassadorEntities,
SecretaryEntities,
);

/// Cases where a remote origin is accepted as trusted Teleporter for a given asset:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ substrate-wasm-builder = { optional = true, workspace = true, default-features =

[dev-dependencies]
sp-io = { features = ["std"], workspace = true, default-features = true }
collectives-westend-runtime-constants = { workspace = true }

[features]
default = ["std"]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "collectives-westend-runtime-constants"
version = "1.0.0"
authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
description = "Westend Collectives Parachain Runtime Constants"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description = "Westend Collectives Parachain Runtime Constants"
description = "Westend Collectives Parachain Runtime Constants"

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 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.

#![no_std]

/// Fellowship Salary pallet instance.
pub const FELLOWSHIP_SALARY_PALLET_INDEX: u8 = 64;

/// Fellowship Treasury pallet instance.
pub const FELLOWSHIP_TREASURY_PALLET_INDEX: u8 = 65;

/// Ambassador Salary pallet instance.
pub const AMBASSADOR_SALARY_PALLET_INDEX: u8 = 74;

/// Secretary Salary pallet instance.
pub const SECRETARY_SALARY_PALLET_INDEX: u8 = 93;
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ use westend_runtime_constants::time::HOURS;
use xcm::prelude::*;
use xcm_builder::{AliasesIntoAccountId32, PayOverXcm};

use crate::secretary::{ranks::SECRETARY, SecretaryCollectiveInstance};

#[cfg(feature = "runtime-benchmarks")]
use crate::impls::benchmarks::{OpenHrmpChannel, PayWithEnsure};

Expand Down Expand Up @@ -81,19 +83,22 @@ impl pallet_referenda::Config<FellowshipReferendaInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type Scheduler = Scheduler;
type Currency = Balances;
// Fellows can submit proposals.
// Fellows & Secretary can submit proposals.
type SubmitOrigin = EitherOf<
pallet_ranked_collective::EnsureMember<Runtime, FellowshipCollectiveInstance, 3>,
MapSuccess<
TryWithMorphedArg<
RuntimeOrigin,
<RuntimeOrigin as OriginTrait>::PalletsOrigin,
ToVoice,
EnsureOfRank<Runtime, FellowshipCollectiveInstance>,
(AccountId, u16),
EitherOf<
pallet_ranked_collective::EnsureMember<Runtime, FellowshipCollectiveInstance, 3>,
MapSuccess<
TryWithMorphedArg<
RuntimeOrigin,
<RuntimeOrigin as OriginTrait>::PalletsOrigin,
ToVoice,
EnsureOfRank<Runtime, FellowshipCollectiveInstance>,
(AccountId, u16),
>,
TakeFirst,
>,
TakeFirst,
>,
pallet_ranked_collective::EnsureMember<Runtime, SecretaryCollectiveInstance, { SECRETARY }>,
>;
type CancelOrigin = Architects;
type KillOrigin = Masters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));

pub mod secretary;
pub use secretary::pallet_secretary_origins;

pub mod ambassador;
pub mod impls;
mod weights;
Expand Down Expand Up @@ -299,6 +302,8 @@ pub enum ProxyType {
Fellowship,
/// Ambassador proxy. Allows calls related to the Ambassador Program.
Ambassador,
/// Secretary proxy. Allows calls related to the Secretary Program.
Secretary,
}
impl Default for ProxyType {
fn default() -> Self {
Expand Down Expand Up @@ -349,6 +354,14 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
),
ProxyType::Secretary => matches!(
c,
RuntimeCall::SecretaryCollective { .. } |
RuntimeCall::SecretaryReferenda { .. } |
RuntimeCall::SecretarySalary { .. } |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
),
}
}
fn is_superset(&self, o: &Self) -> bool {
Expand Down Expand Up @@ -710,6 +723,12 @@ construct_runtime!(
AmbassadorContent: pallet_collective_content::<Instance1> = 75,

StateTrieMigration: pallet_state_trie_migration = 80,

// Secretary Program
SecretaryCollective: pallet_ranked_collective::<Instance3> = 90,
SecretaryReferenda: pallet_referenda::<Instance3> = 91,
SecretaryOrigins: pallet_secretary_origins = 92,
SecretarySalary: pallet_salary::<Instance3> = 93,
}
);

Expand Down Expand Up @@ -784,12 +803,15 @@ mod benches {
[pallet_ranked_collective, FellowshipCollective]
[pallet_core_fellowship, FellowshipCore]
[pallet_salary, FellowshipSalary]
[pallet_treasury, FellowshipTreasury]
[pallet_referenda, AmbassadorReferenda]
[pallet_ranked_collective, AmbassadorCollective]
[pallet_collective_content, AmbassadorContent]
[pallet_core_fellowship, AmbassadorCore]
[pallet_salary, AmbassadorSalary]
[pallet_treasury, FellowshipTreasury]
[pallet_referenda, SecretaryReferenda]
[pallet_ranked_collective, SecretaryCollective]
[pallet_salary, SecretarySalary]
[pallet_asset_rate, AssetRate]
);
}
Expand Down
Loading