Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

NoPermission #6602

Closed
octavei opened this issue Jan 21, 2023 · 8 comments · Fixed by #6606
Closed

NoPermission #6602

octavei opened this issue Jan 21, 2023 · 8 comments · Fixed by #6606

Comments

@octavei
Copy link

octavei commented Jan 21, 2023

Happy New Year! This error occurred when I was sending Transact to rococo via xcmpallet to enable two test chains to open hrmp channels to each other, then I looked at the code

Transact { origin_kind, require_weight_at_most, mut call } => {
				// We assume that the Relay-chain is allowed to use transact on this parachain.
				let origin = *self.origin_ref().ok_or(XcmError::BadOrigin)?;

				// TODO: #2841 #TRANSACTFILTER allow the trait to issue filters for the relay-chain
				let message_call = call.take_decoded().map_err(|_| XcmError::FailedToDecode)?;
				ensure!(Config::SafeCallFilter::contains(&message_call), XcmError::NoPermission);
				let dispatch_origin = Config::OriginConverter::convert_origin(origin, origin_kind)
					.map_err(|_| XcmError::BadOrigin)?;
				let weight = message_call.get_dispatch_info().weight;
				ensure!(weight.all_lte(require_weight_at_most), XcmError::MaxWeightInvalid);
				let maybe_actual_weight =
					match Config::CallDispatcher::dispatch(message_call, dispatch_origin) {
						Ok(post_info) => {
							self.transact_status = MaybeErrorCode::Success;
							post_info.actual_weight
						},
						Err(error_and_info) => {
							self.transact_status = error_and_info.error.encode().into();
							error_and_info.post_info.actual_weight
						},
					};
				let actual_weight = maybe_actual_weight.unwrap_or(weight);
				let surplus = weight.saturating_sub(actual_weight);
				// We assume that the `Config::Weigher` will counts the `require_weight_at_most`
				// for the estimate of how much weight this instruction will take. Now that we know
				// that it's less, we credit it.
				//
				// We make the adjustment for the total surplus, which is used eventually
				// reported back to the caller and this ensures that they account for the total
				// weight consumed correctly (potentially allowing them to do more operations in a
				// block than they otherwise would).
				self.total_surplus.saturating_accrue(surplus);
				Ok(())
			},

Obviously you added ensure! (Config::SafeCallFilter::contains(&message_call), XcmError::NoPermission); ,
This prevented me from opening the hrmp channel in the original way.
So, How can I open the hrmp channel now?

@octavei
Copy link
Author

octavei commented Jan 21, 2023

Original way

polkadotXcm.send
dest: XcmVersionedMultiLocation
{
  V1: {
    parents: 1
    interior: Here
  }
}
message: XcmVersionedXcm
{
  V2: [
    {
      WithdrawAsset: [
        {
          id: {
            Concrete: {
              parents: 0
              interior: Here
            }
          }
          fun: {
            Fungible: 10,000,000,000,000
          }
        }
      ]
    }
    {
      BuyExecution: {
        fees: {
          id: {
            Concrete: {
              parents: 0
              interior: Here
            }
          }
          fun: {
            Fungible: 10,000,000,000,000
          }
        }
        weightLimit: Unlimited
      }
    }
    {
      Transact: {
        originType: Native
        requireWeightAtMost: 1,000,000,000
        call: {
          encoded: 0x3c0046080000e803000000900100
        }
      }
    }
    RefundSurplus
    {
      DepositAsset: {
        assets: {
          Wild: All
        }
        maxAssets: 1
        beneficiary: {
          parents: 0
          interior: {
            X1: {
              AccountId32: {
                network: Any
                id: 0x706172613b080000000000000000000000000000000000000000000000000000
              }
            }
          }
        }
      }
    }
  ]
}

@KiChjang
Copy link
Contributor

What is the encoded call that you're using?

@octavei
Copy link
Author

octavei commented Jan 22, 2023

What is the encoded call that you're using?

hrmp.hrmpInitOpenChannel(recipient: 2118, proposedMaxCapacity: 1000, proposedMaxMessageSize: 102400)`

@octavei
Copy link
Author

octavei commented Jan 22, 2023

What is the encoded call that you're using?

My question is whether there is any other way to open the parallel chain hrmp channel. In other words, how do I submit the transaction that need let origin = ensure_parachain(<T as Config>::RuntimeOrigin::from(origin))? ; signed .
for example:

#[pallet::call_index(0)]
		#[pallet::weight(<T as Config>::WeightInfo::hrmp_init_open_channel())]
		pub fn hrmp_init_open_channel(
			origin: OriginFor<T>,
			recipient: ParaId,
			proposed_max_capacity: u32,
			proposed_max_message_size: u32,
		) -> DispatchResult {
			let origin = ensure_parachain(<T as Config>::RuntimeOrigin::from(origin))?;
			Self::init_open_channel(
				origin,
				recipient,
				proposed_max_capacity,
				proposed_max_message_size,
			)?;
			Self::deposit_event(Event::OpenChannelRequested(
				origin,
				recipient,
				proposed_max_capacity,
				proposed_max_message_size,
			));
			Ok(())
		}

I think such a transaction should be handed directly to the parallel chain, with their autonomy to execute it. It shouldn't be in the SafeCallFilter, don't you think?

@octavei
Copy link
Author

octavei commented Jan 22, 2023

Now our parallel chain slot 2107 is ready to expire, we want to swap it with our new id. But I couldn't submit an xcm Transactpub fn swap(origin: OriginFor<T>, id: ParaId, other: ParaId)(paras-resgister module) in the kico chain to kusama(relay-chain) to execute it successful. That means we're going to have a serious problem in two days with no block

@octavei
Copy link
Author

octavei commented Jan 22, 2023

polkadotXcm.send
dest: XcmVersionedMultiLocation
{
  V1: {
    parents: 1
    interior: Here
  }
}
message: XcmVersionedXcm
{
  V2: [
    {
      WithdrawAsset: [
        {
          id: {
            Concrete: {
              parents: 0
              interior: Here
            }
          }
          fun: {
            Fungible: 10,000,000,000,000
          }
        }
      ]
    }
    {
      BuyExecution: {
        fees: {
          id: {
            Concrete: {
              parents: 0
              interior: Here
            }
          }
          fun: {
            Fungible: 10,000,000,000,000
          }
        }
        weightLimit: Unlimited
      }
    }
    {
      Transact: {
        originType: Native
        requireWeightAtMost: 1,000,000,000
        call: {
          encoded:0x46033b08000046080000
        }
      }
    }
    RefundSurplus
    {
      DepositAsset: {
        assets: {
          Wild: All
        }
        maxAssets: 1
        beneficiary: {
          parents: 0
          interior: {
            X1: {
              AccountId32: {
                network: Any
                id: 0x706172613b080000000000000000000000000000000000000000000000000000
              }
            }
          }
        }
      }
    }
  ]
}

encode call 0x46033b08000046080000:

register.swap(id: 2107,  other: 2118)`

@KiChjang
Copy link
Contributor

Kusama has still not upgraded to XCM v3 yet, so there isn't any problem there. All we need to do is to simply whitelist the pallet. Will still have to check if it is safe to do so.

@Polkadot-Forum
Copy link

This issue has been mentioned on Polkadot Forum. There might be relevant details there:

https://forum.polkadot.network/t/polkadot-release-analysis-v0-9-38/2122/1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants