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

AllowTopLevelPaidExecutionFrom incorrectly checks Limited weight in BuyExecution #6067

Closed
Dinonard opened this issue Sep 28, 2022 · 2 comments

Comments

@Dinonard
Copy link

Hi,

In AllowTopLevelPaidExecutionFrom (here), when processing BuyExecution we do it like this:

BuyExecution { weight_limit: Limited(ref mut weight), .. } if *weight >= max_weight => {   <==== THIS CHECK
		*weight = max_weight;
		Ok(())
	},
	BuyExecution { ref mut weight_limit, .. } if weight_limit == &Unlimited => {
		*weight_limit = Limited(max_weight);
		Ok(())
	},
	_ => Err(()),
}

Regarding the first arm, should we also be Ok(()) in case weight is below max_weight?

It seems like an error to me but I'm skeptical of my own understanding since it hasn't been noticed by now 😅

@KiChjang
Copy link
Contributor

KiChjang commented Sep 28, 2022

No, because recall that whatever you specify as weight in BuyExecution is the total amount of weight that your XCM is willing to pay for. If it's any less than max_weight (which I know is a misnomer, but it means what the executing chain thinks is fair price for the message), then we should definitely throw an error and refuse to execute said XCM, as it did not pay enough weight.

@Dinonard
Copy link
Author

You are right, my mistake! This makes total sense, I switched the order in which Transact and BuyExecution are evaluated when thinking about it.

Following everything that happens can get confusing 😅

Closing the issue.

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

No branches or pull requests

2 participants