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

origin_kind: OriginKind::X, results into BadOrigin in XCM #6079

Closed
dudo50 opened this issue Oct 15, 2024 · 18 comments
Closed

origin_kind: OriginKind::X, results into BadOrigin in XCM #6079

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

Comments

@dudo50
Copy link
Contributor

dudo50 commented Oct 15, 2024

I want to execute the cross-chain call from nfts pallet, but whenever I try it with OriginKind::Native, which should represent OriginFor<T> aka signed user, I receive a Bad Origin error on the destination chain. Could this be XCM Config related? If so, what needs to be changed?

Here is my instruction:

	match send_xcm::<T::XcmSender>(
		(Parent, Junction::Parachain(destination_para.into())).into(),
		Xcm(vec![
			UnpaidExecution { weight_limit: Unlimited, check_origin: None },
			Transact {
				origin_kind: OriginKind::Native,
				require_weight_at_most: Weight::from_parts(1_000_000_000, 64 * 1024),
				call: <T as Config<I>>::RuntimeCall::from(pallet_nfts::Call::<
					T,
					I,
				>::set_collection_metadata {
					collection: destination_collection_id.clone(),
					data: data.clone(),
				})
				.encode()
				.into(),
			},
		]),
	)

Previously, I had OriginKind set to SovereignAccount, but this would only work for collections or nfts owned by sibling accounts.
Any idea as to what might be incorrect and why it is resulting into BadOrigin error?

EDIT: Also tried with OriginKind::Xcm, that resulted into nftModule.NoPermission meaning signed account was different than the user that sent the XCM.

Many thanks!

@github-actions github-actions bot added the I10-unconfirmed Issue might be valid, but it's not yet known. label Oct 15, 2024
@dudo50 dudo50 changed the title origin_kind: OriginKind::Native, results into BadOrigin in XCM origin_kind: OriginKind::X, results into BadOrigin in XCM Oct 15, 2024
@bkontur
Copy link
Contributor

bkontur commented Oct 16, 2024

@dudo50 can you please share your configuration for OriginConverter?

impl xcm_executor::Config for XcmConfig {
	type OriginConverter = ???

@dudo50
Copy link
Contributor Author

dudo50 commented Oct 16, 2024

@bkontur ,

Standard config, that was defined in the template parachain xcm config:

type OriginConverter = XcmOriginToTransactDispatchOrigin;

It's of the following type:

pub type XcmOriginToTransactDispatchOrigin = (
	// Sovereign account converter; this attempts to derive an `AccountId` from the origin location
	// using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for
	// foreign chains who want to have a local sovereign account on this chain which they control.
	SovereignSignedViaLocation<LocationToAccountId, RuntimeOrigin>,
	// Native converter for Relay-chain (Parent) location; will convert to a `Relay` origin when
	// recognized.
	RelayChainAsNative<RelayChainOrigin, RuntimeOrigin>,
	// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when
	// recognized.
	SiblingParachainAsNative<cumulus_pallet_xcm::Origin, RuntimeOrigin>,
	// Native signed account converter; this just converts an `AccountId32` origin into a normal
	// `RuntimeOrigin::Signed` origin of the same 32-byte value.
	SignedAccountId32AsNative<RelayNetwork, RuntimeOrigin>,
	// Xcm origins can be represented natively under the Xcm pallet's Xcm origin.
	XcmPassthrough<RuntimeOrigin>,
);

@bkontur
Copy link
Contributor

bkontur commented Oct 16, 2024

I don't quite understand this:

whenever I try it with OriginKind::Native, which should represent OriginFor aka signed user

where/how do you specify signed user for your call?
Other words, what resolved origin do you expect here?

pub fn set_collection_metadata(
			origin: OriginFor<T>,
			collection: T::CollectionId,
			data: BoundedVec<u8, T::StringLimit>,
		) -> DispatchResult {
			let maybe_check_origin = T::ForceOrigin::try_origin(origin)
				.map(|_| None)
				.or_else(|origin| ensure_signed(origin).map(Some).map_err(DispatchError::from))?;

What is your T::XcmSender? Can you share the code base?

@dudo50
Copy link
Contributor Author

dudo50 commented Oct 16, 2024

@bkontur ,

where/how do you specify signed user for your call?
Other words, what resolved origin do you expect here?

I want it to be origin of the call aka OriginFor<T> provided in the call. The first parameter in snippet you provided:

pub fn set_collection_metadata(
			origin: OriginFor<T>,  //I want this account to be the origin of the 
                                     XCM call, so that if they own the collection on the destination chain, 
                                      they will be able to set metadata of it from other chain.

What is your T::XcmSender? Can you share the code base?

Sure, here is the codebase

I am now having to convert AccountIdLookupOf to OriginFor<T> in order to be able to test the functions, so don't mind that, that should be fixed by having correct OriginFor<T> from the start - provided in the XCM Message.

If you navigate into

pallets/xcnft/lib.rs

You will be able to see transfer functions and parse functions. Parse functions would fail with either BadOrigin or No Permission based on what I choose as OriginKind of the XCM (Native, SovereignAccount, Superuser or Xcm). That is why in Parse functions, I have to convert "owner," which is type AccountIndexOf into OriginFor<T>. But this isn't solution, because everyone will be able to do anything on behalf of someone else. That is the reason I need XCM Message to set origin as the original caller of the transfer function on origin chain.

Eg:

1.Bob calls function nft_x_transfer on chain A
2.Chain A transfers XCM with Bob's account as OriginKind
3.Chain B receives XCM message to parse nft_x_transfer call
4.Chain B sets Bob as origin in the parse call, thus calls won't fail

Also, please don't mind the mess in the pallet code; after it's finished, it will all undergo a deep refactoring.

@bkontur
Copy link
Contributor

bkontur commented Oct 16, 2024

I think your are missing this piece:

Chain A transfers XCM with Bob's account as OriginKind

I don't see anywhere in your code propagating/adding actual origin (Bob's account on the chainA) to the XCM message. You are using XcmpQueue so the resolved origin on the chainB is always sibling parachain chainA.

The XCM that comes to the chainB has the the origin as sibling parachain from which the XCM was sent,
So, if you need different origin there, you need to change your XCM with ClearOrigin and/or DescendOrigin(BobAccountId32OnChainB) before Transact or something like that e.g. AliasOrigin.

        /// Mutate the origin to some interior location.
	///
	/// Kind: *Command*
	///
	/// Errors:
	DescendOrigin(InteriorLocation),

I would suggest to add unit-test simulating the received XCM that your runtime is expected to pass for set_collection_metadata.

@dudo50
Copy link
Contributor Author

dudo50 commented Oct 17, 2024

@bkontur ,

Thanks for the ideas and your patience.

Using ClearOrigin results into unsupported:
screen

//This was the snippet I used

	match send_xcm::<T::XcmSender>(
		(Parent, Junction::Parachain(destination_para.into())).into(),
		Xcm(vec![
			ClearOrigin,
			UnpaidExecution { weight_limit: Unlimited, check_origin: None },		
			Transact {
				origin_kind: OriginKind::SovereignAccount,
				require_weight_at_most: Weight::from_parts(1_000_000_000, 64 * 1024),
				call: <T as Config<I>>::XcNftCall::from(Call::<
					T,
					I,
				>::parse_collection_metadata {
					owner: w.clone(),
					collection: destination_collection_id.clone(),
					data: data.clone(),
				})
				.encode()
				.into(),
			},
		]),
			

Using AliasOrigin results into unsupported also:
screenshot

//This was the snippet I used

	match send_xcm::<T::XcmSender>(
		(Parent, Junction::Parachain(destination_para.into())).into(),
		Xcm(vec![
			AliasOrigin(AccountId32::new([0; 32]).into()),
			UnpaidExecution { weight_limit: Unlimited, check_origin: None },		
			Transact {
				origin_kind: OriginKind::SovereignAccount,
				require_weight_at_most: Weight::from_parts(1_000_000_000, 64 * 1024),
				call: <T as Config<I>>::XcNftCall::from(Call::<
					T,
					I,
				>::parse_collection_metadata {
					owner: w.clone(),
					collection: destination_collection_id.clone(),
					data: data.clone(),
				})
				.encode()
				.into(),
			},
		]),
	)

As for DescendOrigin I have found some example in XCM unit tests, but I am unable to convert T::AccountId type to AccountId32 and I am not sure, that even if I am successful at converting, that if it will allow me to then use that account on destination chain as OriginFor<T> type, that will have permissions to execute tasks on behalf that user. eg. update collection :

//Snippet I use

	let acc = AccountId32::from(who.clone());

	let sender: Location = AccountId32::new(acc.into()).into();

	//Send the prompt to update 
	match send_xcm::<T::XcmSender>(
		(Parent, Junction::Parachain(destination_para.into())).into(),
		Xcm(vec![
			DescendOrigin(sender.clone().try_into().unwrap()),
			UnpaidExecution { weight_limit: Unlimited, check_origin: None },		
			Transact {
				origin_kind: OriginKind::SovereignAccount,
				require_weight_at_most: Weight::from_parts(1_000_000_000, 64 * 1024),
				call: <T as Config<I>>::XcNftCall::from(Call::<
					T,
					I,
				>::parse_collection_metadata {
					owner: w.clone(),
					collection: destination_collection_id.clone(),
					data: data.clone(),
				})
				.encode()
				.into(),
			},
		]),
	)

Any idea as to what I may have missed or on how to convert AccId to AccId32 types? Will DescendOrigin allow me to then act as Bob on Chain B if Bob originated the call on Chain A?

Much appreciated!

Thanks!

Dudo

@bkontur
Copy link
Contributor

bkontur commented Oct 17, 2024

Using ClearOrigin results into unsupported:

Using AliasOrigin results into unsupported also

yes, because you are using AllowExplicitUnpaidExecutionFrom, so the ClearOrigin / AliasOrigin / DescendOrigin needs to go after UnpaidExecution instruction. UnpaidExecution needs to be first instruction.

@dudo50
Copy link
Contributor Author

dudo50 commented Oct 17, 2024

@bkontur ,

Moving them under UnpaidExecution results into same error for ClearOrigin:
snimka

The AliasOrigin instruction results into different error:
snimka
When debugging:

2024-10-17 12:58:18.039 TRACE tokio-runtime-worker xcm::execute: [Parachain] Executing message origin=Location { parents: 1, interior: X1([Parachain(1001)]) } message=Xcm([UnpaidExecution { weight_limit: Unlimited, check_origin: None }, AliasOrigin(Location { parents: 0, interior: X1([AccountId32 { network: None, id: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }]) }), Transact { origin_kind: SovereignAccount, require_weight_at_most: Weight { ref_time: 1000000000, proof_size: 65536 }, call: "0x320d00d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d00000000146471717764" }, SetTopic([91, 98, 172, 29, 235, 146, 154, 170, 194, 218, 198, 56, 189, 19, 202, 138, 186, 92, 110, 200, 214, 195, 201, 217, 46, 64, 203, 52, 184, 140, 56, 67])]) weight_credit=Weight { ref_time: 0, proof_size: 0 }    
2024-10-17 12:58:18.039 TRACE tokio-runtime-worker xcm::process: [Parachain] origin=Some(Location { parents: 1, interior: X1([Parachain(1001)]) }) total_surplus=Weight { ref_time: 0, proof_size: 0 } total_refunded=Weight { ref_time: 0, proof_size: 0 } error_handler_weight=Weight { ref_time: 0, proof_size: 0 }    
2024-10-17 12:58:18.039 TRACE tokio-runtime-worker xcm::process_instruction: [Parachain] Processing instruction instruction=UnpaidExecution { weight_limit: Unlimited, check_origin: None }    
2024-10-17 12:58:18.039 TRACE tokio-runtime-worker xcm::process_instruction: [Parachain] Processing instruction instruction=AliasOrigin(Location { parents: 0, interior: X1([AccountId32 { network: None, id: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }]) })    
2024-10-17 12:58:18.039 TRACE tokio-runtime-worker xcm::execute: [Parachain] !!! ERROR: NoPermission    
2024-10-17 12:58:18.039 TRACE tokio-runtime-worker xcm::execute: [Parachain] Message executed result=Err(ExecutorError { index: 1, xcm_error: NoPermission, weight: Weight { ref_time: 3000000000, proof_size: 196608 } }) 

@bkontur
Copy link
Contributor

bkontur commented Oct 17, 2024

Did you add DescendOrigin(Bob) after ClearOrigin?
For AliasOrigin you are missing this https://github.com/paraspell-research-foundation/polkadot-sdk/blob/master/templates/parachain/runtime/src/configs/xcm_config.rs#L139C7-L139C15, NoPermission is from here:

AliasOrigin(target) => {
				let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?;
				if Config::Aliasers::contains(origin, &target) {
					self.context.origin = Some(target);
					Ok(())
				} else {
					Err(XcmError::NoPermission)
				}
			},

@dudo50
Copy link
Contributor Author

dudo50 commented Oct 17, 2024

@bkontur ,

I see; I would like to focus on ClearOrigin, then.
The problem I am facing there, however, is how do I convert T::AccountId or OriginFor<T> into a location that can then be fed to DescendOrigin?

I tried following:

	let account32 = AccountId32::new(who.clone().into()); // I have problem converting T::AccountId to AccountId32 - the trait bound `[u8; 32]: From<<T as frame_system::Config>::AccountId>` is not satisfied


	//Send the prompt to update 
	match send_xcm::<T::XcmSender>(
		(Parent, Junction::Parachain(destination_para.into())).into(),
		Xcm(vec![
			UnpaidExecution { weight_limit: Unlimited, check_origin: None },
			ClearOrigin,
			DescendOrigin(Junctions::X1(Junction::AccountId32 { network: NetworkId::Any, id: account32.into() })), //DescendOrigin requires Location, but nothing I tried works.
			Transact {
				origin_kind: OriginKind::SovereignAccount,
				require_weight_at_most: Weight::from_parts(1_000_000_000, 64 * 1024),
				call: <T as Config<I>>::XcNftCall::from(Call::<
					T,
					I,
				>::parse_collection_metadata {
					owner: w.clone(),
					collection: destination_collection_id.clone(),
					data: data.clone(),
				})
				.encode()
				.into(),
			},
		]),
	)

But that only results into errors:

error[E0277]: the trait bound `[u8; 32]: From<<T as frame_system::Config>::AccountId>` is not satisfied
     |
1251 |             let account32 = AccountId32::new(who.clone().into());
     |                                                          ^^^^ the trait `From<<T as frame_system::Config>::AccountId>` is not implemented for `[u8; 32]`, which is required by `<T as frame_system::Config>::AccountId: Into<_>`

1260 |                     DescendOrigin(Junctions::X1(Junction::AccountId32 { network: NetworkId::Any, id: account32.into() })),
     |                                                                                             ^^^ variant or associated item not found in `NetworkId`

error[E0308]: mismatched types

1260 |                     DescendOrigin(Junctions::X1(Junction::AccountId32 { network: NetworkId::Any, id: account32.into() })),
     |                                   ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Arc<[Junction; 1]>`, found `Junction`
     |                                   |
     |                                   arguments to this enum variant are incorrect
     |
     = note: expected struct `Arc<[cumulus_primitives_core::Junction; 1]>`
                  found enum `cumulus_primitives_core::Junction`

Much appreciated!

@bkontur
Copy link
Contributor

bkontur commented Oct 17, 2024

maybe?

DescendOrigin(AccountId32 { id: account32.into(), network: None }.into()),

@dudo50
Copy link
Contributor Author

dudo50 commented Oct 17, 2024

@bkontur ,
That resulted into multiple errors:


error[E0560]: struct `sp_runtime::AccountId32` has no field named `id`
     |
1260 |                     DescendOrigin(AccountId32 { id: account32.into(), network: None }.into()),
     |                                                 ^^ field does not exist
     |    

error[E0560]: struct `sp_runtime::AccountId32` has no field named `network`
     |
1260 |                     DescendOrigin(AccountId32 { id: account32.into(), network: None }.into()),
     |                                                                       ^^^^^^^ field does not exist
     |

error[E0277]: the trait bound `cumulus_primitives_core::Junction: From<sp_runtime::AccountId32>` is not satisfied
     |
1260 |                     DescendOrigin(AccountId32 { id: account32.into(), network: None }.into()),
     |                                                                                       ^^^^ the trait `From<sp_runtime::AccountId32>` is not implemented for `cumulus_primitives_core::Junction`, which is required by `sp_runtime::AccountId32: Into<_>`
     |

I did try to modify it a little:

DescendOrigin(AccountId32::new(account32.into()).into()),

Which then resulted into another error:

error[E0277]: the trait bound `cumulus_primitives_core::Junction: From<sp_runtime::AccountId32>` is not satisfied
     |
1260 |                     DescendOrigin(AccountId32::new(account32.into()).into()),
     |                                                                      ^^^^ the trait `From<sp_runtime::AccountId32>` is not implemented for `cumulus_primitives_core::Junction`, which is required by `sp_runtime::AccountId32: Into<_>`

Which basically said, that I did not give any junction to DescendOrigin.

@bkontur
Copy link
Contributor

bkontur commented Oct 17, 2024

I did try to modify it a little:

DescendOrigin(AccountId32::new(account32.into()).into()),

No, you're mixing it up. You probably have use sp_runtime::AccountId32; imported, so it should be:

DescendOrigin(xcm::latest::prelude::AccountId32 { id: account32.into(), network: None }.into()),

@dudo50
Copy link
Contributor Author

dudo50 commented Oct 17, 2024

@bkontur ,

You were right. I was finally able to compile after converting T::AccountId into AccountId32.

However, I still get the same error - Bad Origin

screen

Here is the log:

2024-10-17 22:23:06.070 TRACE tokio-runtime-worker xcm::execute: [Parachain] Executing message origin=Location { parents: 1, interior: X1([Parachain(1000)]) } message=Xcm([UnpaidExecution { weight_limit: Unlimited, check_origin: None }, ClearOrigin, DescendOrigin(X1([AccountId32 { network: None, id: [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] }])), Transact { origin_kind: SovereignAccount, require_weight_at_most: Weight { ref_time: 1000000000, proof_size: 65536 }, call: "0x320d00d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d000000001066776665" }, SetTopic([245, 148, 8, 104, 166, 40, 198, 232, 55, 73, 68, 66, 223, 95, 16, 18, 6, 88, 41, 65, 11, 78, 27, 32, 81, 28, 233, 110, 104, 102, 174, 15])]) weight_credit=Weight { ref_time: 0, proof_size: 0 }    
2024-10-17 22:23:06.070 TRACE tokio-runtime-worker xcm::process: [Parachain] origin=Some(Location { parents: 1, interior: X1([Parachain(1000)]) }) total_surplus=Weight { ref_time: 0, proof_size: 0 } total_refunded=Weight { ref_time: 0, proof_size: 0 } error_handler_weight=Weight { ref_time: 0, proof_size: 0 }    
2024-10-17 22:23:06.070 TRACE tokio-runtime-worker xcm::process_instruction: [Parachain] Processing instruction instruction=UnpaidExecution { weight_limit: Unlimited, check_origin: None }    
2024-10-17 22:23:06.070 TRACE tokio-runtime-worker xcm::process_instruction: [Parachain] Processing instruction instruction=ClearOrigin    
2024-10-17 22:23:06.070 TRACE tokio-runtime-worker xcm::process_instruction: [Parachain] Processing instruction instruction=DescendOrigin(X1([AccountId32 { network: None, id: [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] }]))    
2024-10-17 22:23:06.070 TRACE tokio-runtime-worker xcm::execute: [Parachain] !!! ERROR: BadOrigin    
2024-10-17 22:23:06.070 TRACE tokio-runtime-worker xcm::execute: [Parachain] Message executed result=Err(ExecutorError { index: 2, xcm_error: BadOrigin, weight: Weight { ref_time: 3000000000, proof_size: 196608 } })    
2024-10-17 22:23:06.070 TRACE tokio-runtime-worker xcm::process-message: [Parachain] XCM message execution incomplete, used weight: Weight(ref_time: 3000000000, proof_size: 196608), error: BadOrigin    

Here is what the XCM snippet looks like now:

        //Convert accountId into accountid32
	let account_vec = who.encode();
	ensure!(account_vec.len() == 32, "AccountId must be 32 bytes.");
	let mut bytes = [0u8; 32];
	bytes.copy_from_slice(&account_vec);

	//Send the prompt to update 
	match send_xcm::<T::XcmSender>(
		(Parent, Junction::Parachain(destination_para.into())).into(),
		Xcm(vec![
			UnpaidExecution { weight_limit: Unlimited, check_origin: None },
			ClearOrigin,
			DescendOrigin(xcm::latest::prelude::AccountId32 { id: bytes.into(), network: None }.into()),					
			Transact {
				origin_kind: OriginKind::SovereignAccount,
				require_weight_at_most: Weight::from_parts(1_000_000_000, 64 * 1024),
				call: <T as Config<I>>::XcNftCall::from(Call::<
					T,
					I,
				>::parse_collection_metadata {
					owner: w.clone(),
					collection: destination_collection_id.clone(),
					data: data.clone(),
				})
				.encode()
				.into(),
			},
		]),
	)

Any idea as to what may still be wrong?

EDIT: I have also tried setting OriginKind to Native, but the error remained with the same outcome.

EDIT2: When I removed ClearOrigin I received different kind of error, that stated, that: Parachain failed to convert origin to local origin.

2024-10-17 23:00:24.032 TRACE tokio-runtime-worker xcm::execute: [Parachain] Executing message origin=Location { parents: 1, interior: X1([Parachain(1000)]) } message=Xcm([UnpaidExecution { weight_limit: Unlimited, check_origin: None }, DescendOrigin(X1([AccountId32 { network: None, id: [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] }])), Transact { origin_kind: Native, require_weight_at_most: Weight { ref_time: 1000000000, proof_size: 65536 }, call: "0x320d00d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d000000001066776566" }, SetTopic([248, 215, 203, 77, 47, 18, 148, 115, 127, 249, 77, 22, 204, 147, 174, 109, 157, 190, 194, 57, 22, 60, 70, 224, 11, 166, 168, 77, 42, 34, 139, 158])]) weight_credit=Weight { ref_time: 0, proof_size: 0 }    
2024-10-17 23:00:24.032 TRACE tokio-runtime-worker xcm::process: [Parachain] origin=Some(Location { parents: 1, interior: X1([Parachain(1000)]) }) total_surplus=Weight { ref_time: 0, proof_size: 0 } total_refunded=Weight { ref_time: 0, proof_size: 0 } error_handler_weight=Weight { ref_time: 0, proof_size: 0 }    
2024-10-17 23:00:24.032 TRACE tokio-runtime-worker xcm::process_instruction: [Parachain] Processing instruction instruction=UnpaidExecution { weight_limit: Unlimited, check_origin: None }    
2024-10-17 23:00:24.032 TRACE tokio-runtime-worker xcm::process_instruction: [Parachain] Processing instruction instruction=DescendOrigin(X1([AccountId32 { network: None, id: [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] }]))    
2024-10-17 23:00:24.032 TRACE tokio-runtime-worker xcm::process_instruction: [Parachain] Processing instruction instruction=Transact { origin_kind: Native, require_weight_at_most: Weight { ref_time: 1000000000, proof_size: 65536 }, call: "0x320d00d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d000000001066776566" }    
2024-10-17 23:00:24.032 TRACE tokio-runtime-worker xcm::process_instruction::transact: [Parachain] Processing call call="0x320d00d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d000000001066776566"    
2024-10-17 23:00:24.032 TRACE tokio-runtime-worker xcm::process_instruction::transact: [Parachain] Failed to convert origin to a local origin. origin=Location { parents: 1, interior: X2([Parachain(1000), AccountId32 { network: None, id: [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] }]) } origin_kind=Native    
2024-10-17 23:00:24.032 TRACE tokio-runtime-worker xcm::execute: [Parachain] !!! ERROR: BadOrigin    
2024-10-17 23:00:24.032 TRACE tokio-runtime-worker xcm::execute: [Parachain] Message executed result=Err(ExecutorError { index: 2, xcm_error: BadOrigin, weight: Weight { ref_time: 1000000000, proof_size: 65536 } })    
2024-10-17 23:00:24.032 TRACE tokio-runtime-worker xcm::process-message: [Parachain] XCM message execution incomplete, used weight: Weight(ref_time: 4000000000, proof_size: 262144), error: BadOrigin    

Many thanks!

@bkontur
Copy link
Contributor

bkontur commented Oct 17, 2024

ah, right, sorry, I see now that ClearOrigin with DescendOrigin won't work

			DescendOrigin(who) => self
				.context
				.origin
				.as_mut()
				.ok_or(XcmError::BadOrigin)?
				.append_with(who)
				.map_err(|_| XcmError::LocationFull),
			ClearOrigin => {
				self.context.origin = None;
				Ok(())
			},

so probably the AliasOrigin with implemeting Aliasers for pair (sibling_parachain_location, Location::new(0, AccountId32(...)))

@dudo50
Copy link
Contributor Author

dudo50 commented Oct 17, 2024

@bkontur ,

So I modified DescendOrigin to AliasOrigin in XCM message and Aliasers in XCM config to:

type Aliasers = AliasForeignAccountId32<OnlyParachains>;

Which may not be exactly what you wrote, but I am unable to find any other examples close to what you wrote in the Polkadot SDK. When I search for Aliasers, I get greeted with =Nothing in 99% of results. This one was the only one that contained foreign account id in it.

And received new kind of error:

2024-10-17 23:30:24.036 TRACE tokio-runtime-worker xcm::execute: [Parachain] Executing message origin=Location { parents: 1, interior: X1([Parachain(1000)]) } message=Xcm([UnpaidExecution { weight_limit: Unlimited, check_origin: None }, AliasOrigin(Location { parents: 0, interior: X1([AccountId32 { network: None, id: [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] }]) }), Transact { origin_kind: SovereignAccount, require_weight_at_most: Weight { ref_time: 1000000000, proof_size: 65536 }, call: "0x320d00d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d00000000086477" }, SetTopic([201, 141, 246, 2, 194, 106, 116, 41, 209, 7, 45, 157, 170, 200, 211, 244, 114, 230, 177, 202, 75, 74, 247, 163, 149, 185, 252, 177, 7, 127, 152, 27])]) weight_credit=Weight { ref_time: 0, proof_size: 0 }    
2024-10-17 23:30:24.036 TRACE tokio-runtime-worker xcm::process: [Parachain] origin=Some(Location { parents: 1, interior: X1([Parachain(1000)]) }) total_surplus=Weight { ref_time: 0, proof_size: 0 } total_refunded=Weight { ref_time: 0, proof_size: 0 } error_handler_weight=Weight { ref_time: 0, proof_size: 0 }    
2024-10-17 23:30:24.036 TRACE tokio-runtime-worker xcm::process_instruction: [Parachain] Processing instruction instruction=UnpaidExecution { weight_limit: Unlimited, check_origin: None }    
2024-10-17 23:30:24.036 TRACE tokio-runtime-worker xcm::process_instruction: [Parachain] Processing instruction instruction=AliasOrigin(Location { parents: 0, interior: X1([AccountId32 { network: None, id: [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] }]) })    
2024-10-17 23:30:24.036 TRACE tokio-runtime-worker xcm::execute: [Parachain] !!! ERROR: NoPermission    
2024-10-17 23:30:24.036 TRACE tokio-runtime-worker xcm::execute: [Parachain] Message executed result=Err(ExecutorError { index: 1, xcm_error: NoPermission, weight: Weight { ref_time: 3000000000, proof_size: 196608 } })    
2024-10-17 23:30:24.036 TRACE tokio-runtime-worker xcm::process-message: [Parachain] XCM message execution incomplete, used weight: Weight(ref_time: 2000000000, proof_size: 131072), error: NoPermission    

I feel like we are getting closer to the root of the problem here..

EDIT:
Switching OriginKind to Native results in same error:

2024-10-17 23:39:48.037 TRACE tokio-runtime-worker xcm::execute: [Parachain] Executing message origin=Location { parents: 1, interior: X1([Parachain(1000)]) } message=Xcm([UnpaidExecution { weight_limit: Unlimited, check_origin: None }, AliasOrigin(Location { parents: 0, interior: X1([AccountId32 { network: None, id: [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] }]) }), Transact { origin_kind: Native, require_weight_at_most: Weight { ref_time: 1000000000, proof_size: 65536 }, call: "0x320d00d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d000000000c647177" }, SetTopic([118, 8, 4, 181, 53, 48, 253, 166, 120, 52, 238, 229, 7, 183, 245, 32, 196, 152, 199, 203, 3, 25, 25, 7, 117, 179, 208, 52, 155, 168, 22, 48])]) weight_credit=Weight { ref_time: 0, proof_size: 0 }    
2024-10-17 23:39:48.037 TRACE tokio-runtime-worker xcm::process: [Parachain] origin=Some(Location { parents: 1, interior: X1([Parachain(1000)]) }) total_surplus=Weight { ref_time: 0, proof_size: 0 } total_refunded=Weight { ref_time: 0, proof_size: 0 } error_handler_weight=Weight { ref_time: 0, proof_size: 0 }    
2024-10-17 23:39:48.037 TRACE tokio-runtime-worker xcm::process_instruction: [Parachain] Processing instruction instruction=UnpaidExecution { weight_limit: Unlimited, check_origin: None }    
2024-10-17 23:39:48.037 TRACE tokio-runtime-worker xcm::process_instruction: [Parachain] Processing instruction instruction=AliasOrigin(Location { parents: 0, interior: X1([AccountId32 { network: None, id: [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] }]) })    
2024-10-17 23:39:48.037 TRACE tokio-runtime-worker xcm::execute: [Parachain] !!! ERROR: NoPermission    
2024-10-17 23:39:48.037 TRACE tokio-runtime-worker xcm::execute: [Parachain] Message executed result=Err(ExecutorError { index: 1, xcm_error: NoPermission, weight: Weight { ref_time: 3000000000, proof_size: 196608 } })    
2024-10-17 23:39:48.037 TRACE tokio-runtime-worker xcm::process-message: [Parachain] XCM message execution incomplete, used weight: Weight(ref_time: 2000000000, proof_size: 131072), error: NoPermission    

@dudo50
Copy link
Contributor Author

dudo50 commented Oct 18, 2024

@bkontur , setting Aliasers to Everything finally resolved issues with permissions :D. It isn't desired to setup Aliasers as Everything, but for testing it is good enough. Thanks for the help throughout! You were really helpful!

Much appreciated!

Dudo

@dudo50 dudo50 closed this as completed Oct 18, 2024
@bkontur
Copy link
Contributor

bkontur commented Oct 18, 2024

@dudo50 Welcome, good to hear! Also, there is more information coming regarding the AliasOrigin stuff here.

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