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

XCM Deposit is not Unreserved after Closing XCM Channel #6101

Closed
albertov19 opened this issue Oct 17, 2024 · 4 comments
Closed

XCM Deposit is not Unreserved after Closing XCM Channel #6101

albertov19 opened this issue Oct 17, 2024 · 4 comments
Labels
I10-unconfirmed Issue might be valid, but it's not yet known.

Comments

@albertov19
Copy link

It is clear that when a team inits open or accepts an XCM channel, there is a deposit (currently 10 DOT) for each action:

  • Init Open:
    // Do not require deposits for channels with or amongst the system.
    let is_system = origin.is_system() || recipient.is_system();
    let deposit = if is_system { 0 } else { config.hrmp_sender_deposit };
    if !deposit.is_zero() {
    T::Currency::reserve(
    &origin.into_account_truncating(),
    deposit.unique_saturated_into(),
    )?;
    }
  • Accept:
    // Do not require deposits for channels with or amongst the system.
    let is_system = origin.is_system() || sender.is_system();
    let deposit = if is_system { 0 } else { config.hrmp_recipient_deposit };
    if !deposit.is_zero() {
    T::Currency::reserve(
    &origin.into_account_truncating(),
    deposit.unique_saturated_into(),
    )?;
    }

Nevertheless, I don't see this balance being unreserved when the XCM channel is closed ->

fn close_channel(origin: ParaId, channel_id: HrmpChannelId) -> Result<(), Error<T>> {

Any reasons?

@github-actions github-actions bot added the I10-unconfirmed Issue might be valid, but it's not yet known. label Oct 17, 2024
@bkontur
Copy link
Contributor

bkontur commented Oct 17, 2024

close_channel does not close channel :), it just creates a request for closing HrmpCloseChannelRequests,
and the real closing is done on new session or something like that here:

fn process_hrmp_close_channel_requests() {
let close_reqs = HrmpCloseChannelRequestsList::<T>::take();
for condemned_ch_id in close_reqs {
HrmpCloseChannelRequests::<T>::remove(&condemned_ch_id);
Self::close_hrmp_channel(&condemned_ch_id);
}
}
/// Close and remove the designated HRMP channel.
///
/// This includes returning the deposits.
///
/// This function is idempotent, meaning that after the first application it should have no
/// effect (i.e. it won't return the deposits twice).
fn close_hrmp_channel(channel_id: &HrmpChannelId) {

and there in the close_hrmp_channel is also unreserve calls.

So the real closing is done here: https://github.com/paritytech/polkadot-sdk/blob/d5b96e9e7f24adc1799f8e426c5cb69b4f2dbf8a/polkadot/runtime/parachains/src/hrmp.rs#L1137C5-L1137C23

@bkontur
Copy link
Contributor

bkontur commented Oct 17, 2024

so, iiuc, when a team closes an HRMP channel, they receive their funds back in the new session

@albertov19
Copy link
Author

Thanks for clarifying! That makes sense, maybe it would also make sense to reserve the balance when the actual channel is established then.

But it is clear! Thanks!

@bkontur
Copy link
Contributor

bkontur commented Oct 17, 2024

maybe it would also make sense to reserve the balance when the actual channel is established then.

I don't think so. The establishment is done asynchronously in the new session in process_hrmp_open_channel_requests. What if the relevant parachains don't have enough balance at that time? Potentially, those requests could hang indefinitely, and we need to handle that case (maybe with a timeout). I guess, it would complicate things, and perhaps there are other reasons why it isn't done this way.
Additionally, I think it's also a form of spam protection that para teams must pay a deposit on the hrmp_init_open_channel / hrmp_accept_open_channel extrinsics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I10-unconfirmed Issue might be valid, but it's not yet known.
Projects
None yet
Development

No branches or pull requests

2 participants