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

establish_channel_with_system #3721

Merged
merged 29 commits into from
Apr 12, 2024
Merged
Changes from 3 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
28 changes: 28 additions & 0 deletions polkadot/runtime/parachains/src/hrmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,34 @@ pub mod pallet {

Ok(())
}

/// TODO write docs
xlc marked this conversation as resolved.
Show resolved Hide resolved
#[pallet::call_index(10)]
#[pallet::weight(<T as Config>::WeightInfo::establish_system_channel())] // TODO benchmarks
pub fn establish_channel_with_system(
origin: OriginFor<T>,
recipient: ParaId,
) -> DispatchResultWithPostInfo {
xlc marked this conversation as resolved.
Show resolved Hide resolved
let sender = ensure_parachain(<T as Config>::RuntimeOrigin::from(origin))?;

ensure!(recipient.is_system(), Error::<T>::ChannelCreationNotAuthorized);

let config = <configuration::Pallet<T>>::config();
let max_message_size = config.hrmp_channel_max_message_size;
let max_capacity = config.hrmp_channel_max_capacity;
xlc marked this conversation as resolved.
Show resolved Hide resolved

Self::init_open_channel(sender, recipient, max_capacity, max_message_size)?;
Self::accept_open_channel(recipient, sender)?;
xlc marked this conversation as resolved.
Show resolved Hide resolved

Self::deposit_event(Event::HrmpSystemChannelOpened {
xlc marked this conversation as resolved.
Show resolved Hide resolved
sender,
recipient,
proposed_max_capacity: max_capacity,
proposed_max_message_size: max_message_size,
});

Ok(Pays::No.into())
}
}
}

Expand Down
Loading