6

When swapping two parachain slots as described in the polkadot wiki, is it also possible to swap the ParaID, for example to keep the old ParaID and thus avoid issues in regards to XCM when extending the lease?

2 Answers 2

6

When swapping between two parachains you are transfering slot information of each one to the other, same thing happens with crowdloan info.

swap is part of registrar pallet, and defines that for this case, both paras are parachains at the same time, the logic handling the swap will be defined at runtime level.

// --snip
// If both chains are currently parachains, there is nothing funny we
// need to do for their lifecycle management, just swap the underlying
// data.
T::OnSwap::on_swap(id, other);
// --snip

If we check registrar pallet config on Kusama we can see the following:

impl paras_registrar::Config for Runtime {
    type Event = Event;
    type Origin = Origin;
    type Currency = Balances;
    type OnSwap = (Crowdloan, Slots); // implementations of OnSwap on these pallets
    type ParaDeposit = ParaDeposit;
    type DataDepositPerByte = DataDepositPerByte;
    type WeightInfo = weights::runtime_common_paras_registrar::WeightInfo<Runtime>;
}

So, when swapping, the logic handling the information movement is located in the following pallets, per runtime definition:

  • crowdloan: swapping Funds information between paras.
impl<T: Config> crate::traits::OnSwap for Pallet<T> {
    fn on_swap(one: ParaId, other: ParaId) {
        Funds::<T>::mutate(one, |x| Funds::<T>::mutate(other, |y| sp_std::mem::swap(x, y)))
    }
}
  • slots: swapping Leases information between paras.
impl<T: Config> crate::traits::OnSwap for Pallet<T> {
    fn on_swap(one: ParaId, other: ParaId) {
        Leases::<T>::mutate(one, |x| Leases::<T>::mutate(other, |y| sp_std::mem::swap(x, y)))
    }

Meaning that if there was a parachain, with ParaId=2222 which is at its last LP, close to the end of its parachain lifecycle, and it swaps with another parachain with ParaId=3333 that has more LPs, meaning it will be parachain for longer. 2222 will receive the LPs of 3333, then we achieve to keep 2222 for longer as a parachain. 3333 in the other hand will end its parachain lifecycle when 2222 was going to, as it holds the Leases information that was 2222's before the swap. Similar story with Funds info.

So answering your question, ParaIds don't swap, but you can make one of them stick for longer, and thus keep on using it, and this doesn't present any kind of problems.

2

Yes it is possible to keep the paraId with overlapping slots by calling the registrar > swap extrinsic.

I agree that non-overlapping slots takes a bit of logistics and planning e.g. making sure you have time allocated for all aspects of securing a new slot (governance, auction, etc) and it is not guaranteed - you could lose the bid.

Always make sure to test this process locally on a test network.

More Info:

3
  • Thanks for pointing this out, but the question was about swapping paraID when swapping slots. Option 2 is risky, because it is not guaranteed that the slot is attained.
    – sea212
    Sep 2, 2022 at 12:18
  • Updated my answer to better reflect your question.
    – Bruno
    Sep 2, 2022 at 19:35
  • 2
    Here is an example of a parachain that called swap 7 days ago on Polkadot. You can see that their lease is now 664 days (as of time of writing this).
    – Bruno
    Sep 5, 2022 at 20:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.