mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-08 15:58:02 +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,
|
||||
/// Origin for managing the composition of the fellowship.
|
||||
FellowshipAdmin,
|
||||
/// Origin for managing the registrar.
|
||||
/// Origin for managing the registrar and permissioned HRMP channel operations.
|
||||
GeneralAdmin,
|
||||
/// Origin for starting auctions.
|
||||
AuctionAdmin,
|
||||
|
||||
@@ -1155,6 +1155,7 @@ impl parachains_dmp::Config for Runtime {}
|
||||
impl parachains_hrmp::Config for Runtime {
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type ChannelManager = EitherOf<EnsureRoot<Self::AccountId>, GeneralAdmin>;
|
||||
type Currency = Balances;
|
||||
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Runtime>;
|
||||
}
|
||||
|
||||
@@ -249,6 +249,9 @@ pub mod pallet {
|
||||
+ From<<Self as frame_system::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.
|
||||
///
|
||||
/// NOTE that this Currency instance will be charged with the amounts defined in the
|
||||
@@ -513,13 +516,13 @@ pub mod pallet {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// This extrinsic triggers the cleanup of all the HRMP storage items that
|
||||
/// a para may have. Normally this happens once per session, but this allows
|
||||
/// you to trigger the cleanup immediately for a specific parachain.
|
||||
/// This extrinsic triggers the cleanup of all the HRMP storage items that a para may have.
|
||||
/// Normally this happens once per session, but this allows you to trigger the cleanup
|
||||
/// 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::weight(<T as Config>::WeightInfo::force_clean_hrmp(*_inbound, *_outbound))]
|
||||
pub fn force_clean_hrmp(
|
||||
@@ -528,21 +531,23 @@ pub mod pallet {
|
||||
_inbound: u32,
|
||||
_outbound: u32,
|
||||
) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
T::ChannelManager::ensure_origin(origin)?;
|
||||
Self::clean_hrmp_after_outgoing(¶);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Force process HRMP open channel requests.
|
||||
///
|
||||
/// If there are pending HRMP open channel requests, you can use this
|
||||
/// function process all of those requests immediately.
|
||||
/// If there are pending HRMP open channel requests, you can use this function to process
|
||||
/// 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::weight(<T as Config>::WeightInfo::force_process_hrmp_open(*_channels))]
|
||||
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();
|
||||
Self::process_hrmp_open_channel_requests(&host_config);
|
||||
Ok(())
|
||||
@@ -550,14 +555,16 @@ pub mod pallet {
|
||||
|
||||
/// Force process HRMP close channel requests.
|
||||
///
|
||||
/// If there are pending HRMP close channel requests, you can use this
|
||||
/// function process all of those requests immediately.
|
||||
/// If there are pending HRMP close channel requests, you can use this function to process
|
||||
/// 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::weight(<T as Config>::WeightInfo::force_process_hrmp_close(*_channels))]
|
||||
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();
|
||||
Ok(())
|
||||
}
|
||||
@@ -588,12 +595,14 @@ pub mod pallet {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Open a channel from a `sender` to a `recipient` `ParaId` using the Root origin. Although
|
||||
/// opened by Root, the `max_capacity` and `max_message_size` are still subject to the Relay
|
||||
/// Chain's configured limits.
|
||||
/// Open a channel from a `sender` to a `recipient` `ParaId`. Although opened by governance,
|
||||
/// the `max_capacity` and `max_message_size` are still subject to the Relay Chain's
|
||||
/// configured limits.
|
||||
///
|
||||
/// Expected use is when one of the `ParaId`s involved in the channel is governed by the
|
||||
/// Relay Chain, e.g. a system parachain.
|
||||
///
|
||||
/// Origin must be the `ChannelManager`.
|
||||
#[pallet::call_index(7)]
|
||||
#[pallet::weight(<T as Config>::WeightInfo::force_open_hrmp_channel(1))]
|
||||
pub fn force_open_hrmp_channel(
|
||||
@@ -603,7 +612,7 @@ pub mod pallet {
|
||||
max_capacity: u32,
|
||||
max_message_size: u32,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
ensure_root(origin)?;
|
||||
T::ChannelManager::ensure_origin(origin)?;
|
||||
|
||||
// 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
|
||||
|
||||
@@ -219,6 +219,7 @@ parameter_types! {
|
||||
impl crate::hrmp::Config for Test {
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type ChannelManager = frame_system::EnsureRoot<u64>;
|
||||
type Currency = pallet_balances::Pallet<Test>;
|
||||
type WeightInfo = crate::hrmp::TestWeightInfo;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ pub mod pallet_custom_origins {
|
||||
Treasurer,
|
||||
/// Origin for managing the composition of the fellowship.
|
||||
FellowshipAdmin,
|
||||
/// Origin for managing the registrar.
|
||||
/// Origin for managing the registrar and permissioned HRMP channel operations.
|
||||
GeneralAdmin,
|
||||
/// Origin for starting auctions.
|
||||
AuctionAdmin,
|
||||
|
||||
@@ -1171,6 +1171,7 @@ impl parachains_dmp::Config for Runtime {}
|
||||
impl parachains_hrmp::Config for Runtime {
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type ChannelManager = EitherOf<EnsureRoot<Self::AccountId>, GeneralAdmin>;
|
||||
type Currency = Balances;
|
||||
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Self>;
|
||||
}
|
||||
|
||||
@@ -1084,6 +1084,7 @@ impl parachains_dmp::Config for Runtime {}
|
||||
impl parachains_hrmp::Config for Runtime {
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type ChannelManager = EnsureRoot<AccountId>;
|
||||
type Currency = Balances;
|
||||
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Runtime>;
|
||||
}
|
||||
|
||||
@@ -543,6 +543,7 @@ parameter_types! {
|
||||
impl parachains_hrmp::Config for Runtime {
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type ChannelManager = frame_system::EnsureRoot<AccountId>;
|
||||
type Currency = Balances;
|
||||
type WeightInfo = parachains_hrmp::TestWeightInfo;
|
||||
}
|
||||
|
||||
@@ -984,6 +984,7 @@ impl parachains_dmp::Config for Runtime {}
|
||||
impl parachains_hrmp::Config for Runtime {
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type ChannelManager = EnsureRoot<AccountId>;
|
||||
type Currency = Balances;
|
||||
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Self>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user