mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 22:51:03 +00:00
Put HRMP Channel Management on General Admin Track (#7477)
* create ManagerOrigin for HRMP * missed one * fix mock * update GeneralAdmin docs
This commit is contained in:
@@ -38,7 +38,7 @@ pub mod pallet_custom_origins {
|
|||||||
Treasurer,
|
Treasurer,
|
||||||
/// Origin for managing the composition of the fellowship.
|
/// Origin for managing the composition of the fellowship.
|
||||||
FellowshipAdmin,
|
FellowshipAdmin,
|
||||||
/// Origin for managing the registrar.
|
/// Origin for managing the registrar and permissioned HRMP channel operations.
|
||||||
GeneralAdmin,
|
GeneralAdmin,
|
||||||
/// Origin for starting auctions.
|
/// Origin for starting auctions.
|
||||||
AuctionAdmin,
|
AuctionAdmin,
|
||||||
|
|||||||
@@ -1155,6 +1155,7 @@ impl parachains_dmp::Config for Runtime {}
|
|||||||
impl parachains_hrmp::Config for Runtime {
|
impl parachains_hrmp::Config for Runtime {
|
||||||
type RuntimeOrigin = RuntimeOrigin;
|
type RuntimeOrigin = RuntimeOrigin;
|
||||||
type RuntimeEvent = RuntimeEvent;
|
type RuntimeEvent = RuntimeEvent;
|
||||||
|
type ChannelManager = EitherOf<EnsureRoot<Self::AccountId>, GeneralAdmin>;
|
||||||
type Currency = Balances;
|
type Currency = Balances;
|
||||||
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Runtime>;
|
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Runtime>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -249,6 +249,9 @@ pub mod pallet {
|
|||||||
+ From<<Self as frame_system::Config>::RuntimeOrigin>
|
+ From<<Self as frame_system::Config>::RuntimeOrigin>
|
||||||
+ Into<Result<crate::Origin, <Self as Config>::RuntimeOrigin>>;
|
+ Into<Result<crate::Origin, <Self as Config>::RuntimeOrigin>>;
|
||||||
|
|
||||||
|
/// The origin that can perform "force" actions on channels.
|
||||||
|
type ChannelManager: EnsureOrigin<<Self as frame_system::Config>::RuntimeOrigin>;
|
||||||
|
|
||||||
/// An interface for reserving deposits for opening channels.
|
/// An interface for reserving deposits for opening channels.
|
||||||
///
|
///
|
||||||
/// NOTE that this Currency instance will be charged with the amounts defined in the
|
/// NOTE that this Currency instance will be charged with the amounts defined in the
|
||||||
@@ -513,13 +516,13 @@ pub mod pallet {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This extrinsic triggers the cleanup of all the HRMP storage items that
|
/// This extrinsic triggers the cleanup of all the HRMP storage items that a para may have.
|
||||||
/// a para may have. Normally this happens once per session, but this allows
|
/// Normally this happens once per session, but this allows you to trigger the cleanup
|
||||||
/// you to trigger the cleanup immediately for a specific parachain.
|
/// immediately for a specific parachain.
|
||||||
///
|
///
|
||||||
/// Origin must be Root.
|
/// Number of inbound and outbound channels for `para` must be provided as witness data.
|
||||||
///
|
///
|
||||||
/// Number of inbound and outbound channels for `para` must be provided as witness data of weighing.
|
/// Origin must be the `ChannelManager`.
|
||||||
#[pallet::call_index(3)]
|
#[pallet::call_index(3)]
|
||||||
#[pallet::weight(<T as Config>::WeightInfo::force_clean_hrmp(*_inbound, *_outbound))]
|
#[pallet::weight(<T as Config>::WeightInfo::force_clean_hrmp(*_inbound, *_outbound))]
|
||||||
pub fn force_clean_hrmp(
|
pub fn force_clean_hrmp(
|
||||||
@@ -528,21 +531,23 @@ pub mod pallet {
|
|||||||
_inbound: u32,
|
_inbound: u32,
|
||||||
_outbound: u32,
|
_outbound: u32,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
ensure_root(origin)?;
|
T::ChannelManager::ensure_origin(origin)?;
|
||||||
Self::clean_hrmp_after_outgoing(¶);
|
Self::clean_hrmp_after_outgoing(¶);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Force process HRMP open channel requests.
|
/// Force process HRMP open channel requests.
|
||||||
///
|
///
|
||||||
/// If there are pending HRMP open channel requests, you can use this
|
/// If there are pending HRMP open channel requests, you can use this function to process
|
||||||
/// function process all of those requests immediately.
|
/// all of those requests immediately.
|
||||||
///
|
///
|
||||||
/// Total number of opening channels must be provided as witness data of weighing.
|
/// Total number of opening channels must be provided as witness data.
|
||||||
|
///
|
||||||
|
/// Origin must be the `ChannelManager`.
|
||||||
#[pallet::call_index(4)]
|
#[pallet::call_index(4)]
|
||||||
#[pallet::weight(<T as Config>::WeightInfo::force_process_hrmp_open(*_channels))]
|
#[pallet::weight(<T as Config>::WeightInfo::force_process_hrmp_open(*_channels))]
|
||||||
pub fn force_process_hrmp_open(origin: OriginFor<T>, _channels: u32) -> DispatchResult {
|
pub fn force_process_hrmp_open(origin: OriginFor<T>, _channels: u32) -> DispatchResult {
|
||||||
ensure_root(origin)?;
|
T::ChannelManager::ensure_origin(origin)?;
|
||||||
let host_config = configuration::Pallet::<T>::config();
|
let host_config = configuration::Pallet::<T>::config();
|
||||||
Self::process_hrmp_open_channel_requests(&host_config);
|
Self::process_hrmp_open_channel_requests(&host_config);
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -550,14 +555,16 @@ pub mod pallet {
|
|||||||
|
|
||||||
/// Force process HRMP close channel requests.
|
/// Force process HRMP close channel requests.
|
||||||
///
|
///
|
||||||
/// If there are pending HRMP close channel requests, you can use this
|
/// If there are pending HRMP close channel requests, you can use this function to process
|
||||||
/// function process all of those requests immediately.
|
/// all of those requests immediately.
|
||||||
///
|
///
|
||||||
/// Total number of closing channels must be provided as witness data of weighing.
|
/// Total number of closing channels must be provided as witness data.
|
||||||
|
///
|
||||||
|
/// Origin must be the `ChannelManager`.
|
||||||
#[pallet::call_index(5)]
|
#[pallet::call_index(5)]
|
||||||
#[pallet::weight(<T as Config>::WeightInfo::force_process_hrmp_close(*_channels))]
|
#[pallet::weight(<T as Config>::WeightInfo::force_process_hrmp_close(*_channels))]
|
||||||
pub fn force_process_hrmp_close(origin: OriginFor<T>, _channels: u32) -> DispatchResult {
|
pub fn force_process_hrmp_close(origin: OriginFor<T>, _channels: u32) -> DispatchResult {
|
||||||
ensure_root(origin)?;
|
T::ChannelManager::ensure_origin(origin)?;
|
||||||
Self::process_hrmp_close_channel_requests();
|
Self::process_hrmp_close_channel_requests();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -588,12 +595,14 @@ pub mod pallet {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Open a channel from a `sender` to a `recipient` `ParaId` using the Root origin. Although
|
/// Open a channel from a `sender` to a `recipient` `ParaId`. Although opened by governance,
|
||||||
/// opened by Root, the `max_capacity` and `max_message_size` are still subject to the Relay
|
/// the `max_capacity` and `max_message_size` are still subject to the Relay Chain's
|
||||||
/// Chain's configured limits.
|
/// configured limits.
|
||||||
///
|
///
|
||||||
/// Expected use is when one of the `ParaId`s involved in the channel is governed by the
|
/// Expected use is when one of the `ParaId`s involved in the channel is governed by the
|
||||||
/// Relay Chain, e.g. a system parachain.
|
/// Relay Chain, e.g. a system parachain.
|
||||||
|
///
|
||||||
|
/// Origin must be the `ChannelManager`.
|
||||||
#[pallet::call_index(7)]
|
#[pallet::call_index(7)]
|
||||||
#[pallet::weight(<T as Config>::WeightInfo::force_open_hrmp_channel(1))]
|
#[pallet::weight(<T as Config>::WeightInfo::force_open_hrmp_channel(1))]
|
||||||
pub fn force_open_hrmp_channel(
|
pub fn force_open_hrmp_channel(
|
||||||
@@ -603,7 +612,7 @@ pub mod pallet {
|
|||||||
max_capacity: u32,
|
max_capacity: u32,
|
||||||
max_message_size: u32,
|
max_message_size: u32,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResultWithPostInfo {
|
||||||
ensure_root(origin)?;
|
T::ChannelManager::ensure_origin(origin)?;
|
||||||
|
|
||||||
// Guard against a common footgun where someone makes a channel request to a system
|
// Guard against a common footgun where someone makes a channel request to a system
|
||||||
// parachain and then makes a proposal to open the channel via governance, which fails
|
// parachain and then makes a proposal to open the channel via governance, which fails
|
||||||
|
|||||||
@@ -219,6 +219,7 @@ parameter_types! {
|
|||||||
impl crate::hrmp::Config for Test {
|
impl crate::hrmp::Config for Test {
|
||||||
type RuntimeOrigin = RuntimeOrigin;
|
type RuntimeOrigin = RuntimeOrigin;
|
||||||
type RuntimeEvent = RuntimeEvent;
|
type RuntimeEvent = RuntimeEvent;
|
||||||
|
type ChannelManager = frame_system::EnsureRoot<u64>;
|
||||||
type Currency = pallet_balances::Pallet<Test>;
|
type Currency = pallet_balances::Pallet<Test>;
|
||||||
type WeightInfo = crate::hrmp::TestWeightInfo;
|
type WeightInfo = crate::hrmp::TestWeightInfo;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ pub mod pallet_custom_origins {
|
|||||||
Treasurer,
|
Treasurer,
|
||||||
/// Origin for managing the composition of the fellowship.
|
/// Origin for managing the composition of the fellowship.
|
||||||
FellowshipAdmin,
|
FellowshipAdmin,
|
||||||
/// Origin for managing the registrar.
|
/// Origin for managing the registrar and permissioned HRMP channel operations.
|
||||||
GeneralAdmin,
|
GeneralAdmin,
|
||||||
/// Origin for starting auctions.
|
/// Origin for starting auctions.
|
||||||
AuctionAdmin,
|
AuctionAdmin,
|
||||||
|
|||||||
@@ -1171,6 +1171,7 @@ impl parachains_dmp::Config for Runtime {}
|
|||||||
impl parachains_hrmp::Config for Runtime {
|
impl parachains_hrmp::Config for Runtime {
|
||||||
type RuntimeOrigin = RuntimeOrigin;
|
type RuntimeOrigin = RuntimeOrigin;
|
||||||
type RuntimeEvent = RuntimeEvent;
|
type RuntimeEvent = RuntimeEvent;
|
||||||
|
type ChannelManager = EitherOf<EnsureRoot<Self::AccountId>, GeneralAdmin>;
|
||||||
type Currency = Balances;
|
type Currency = Balances;
|
||||||
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Self>;
|
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Self>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1084,6 +1084,7 @@ impl parachains_dmp::Config for Runtime {}
|
|||||||
impl parachains_hrmp::Config for Runtime {
|
impl parachains_hrmp::Config for Runtime {
|
||||||
type RuntimeOrigin = RuntimeOrigin;
|
type RuntimeOrigin = RuntimeOrigin;
|
||||||
type RuntimeEvent = RuntimeEvent;
|
type RuntimeEvent = RuntimeEvent;
|
||||||
|
type ChannelManager = EnsureRoot<AccountId>;
|
||||||
type Currency = Balances;
|
type Currency = Balances;
|
||||||
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Runtime>;
|
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Runtime>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -543,6 +543,7 @@ parameter_types! {
|
|||||||
impl parachains_hrmp::Config for Runtime {
|
impl parachains_hrmp::Config for Runtime {
|
||||||
type RuntimeOrigin = RuntimeOrigin;
|
type RuntimeOrigin = RuntimeOrigin;
|
||||||
type RuntimeEvent = RuntimeEvent;
|
type RuntimeEvent = RuntimeEvent;
|
||||||
|
type ChannelManager = frame_system::EnsureRoot<AccountId>;
|
||||||
type Currency = Balances;
|
type Currency = Balances;
|
||||||
type WeightInfo = parachains_hrmp::TestWeightInfo;
|
type WeightInfo = parachains_hrmp::TestWeightInfo;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -984,6 +984,7 @@ impl parachains_dmp::Config for Runtime {}
|
|||||||
impl parachains_hrmp::Config for Runtime {
|
impl parachains_hrmp::Config for Runtime {
|
||||||
type RuntimeOrigin = RuntimeOrigin;
|
type RuntimeOrigin = RuntimeOrigin;
|
||||||
type RuntimeEvent = RuntimeEvent;
|
type RuntimeEvent = RuntimeEvent;
|
||||||
|
type ChannelManager = EnsureRoot<AccountId>;
|
||||||
type Currency = Balances;
|
type Currency = Balances;
|
||||||
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Self>;
|
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Self>;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user