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

Limit the max number of assets weighable in XCM #2215

Merged
merged 4 commits into from Apr 12, 2023

Conversation

librelois
Copy link
Collaborator

@librelois librelois commented Apr 6, 2023

What does it do?

To prevent unreasonably high count values from overweighing related XCM instructions, we should have an upper limit on how many assets we would weight during the weight calculation of XCM and we should apply this limit to all *Counted variants.

This PR also apply the same limit for MAX_ASSETS and MaxAssetsIntoHolding.

⚠️ Breaking Changes ⚠️

The maximum number of "weighable" assets has been reduced from 100 to 64.
This means that if you try to send an XCM message that tries to handle more than 64 assets at the same time, it will still fail as before, but the weigher will charge less.

What important points reviewers should know?

Is there something left for follow-up PRs?

What alternative implementations were considered?

Are there relevant PRs or issues in other repositories (Substrate, Polkadot, Frontier, Cumulus)?

What value does it bring to the blockchain users?

@librelois librelois added B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes D5-nicetohaveaudit⚠️ PR contains trivial changes to logic that should be properly reviewed. labels Apr 6, 2023
@librelois librelois added the breaking Needs to be mentioned in breaking changes label Apr 6, 2023
@librelois librelois marked this pull request as ready for review April 6, 2023 14:28
@girazoki
Copy link
Collaborator

girazoki commented Apr 11, 2023

Just to be clear on what this PR does: if I withdraw 15 assets (nothing prevents me today from doing that) I will be charged as if I was withdrawing 10. Is this the behavior we want? I see statemint applies 100 so I just want to be sure we are doing what we want here:

https://github.com/paritytech/cumulus/blob/b0715f9bd9f24758c132fb7dc8adcd30551f7de4/parachains/runtimes/assets/statemine/src/weights/xcm/mod.rs#L31

@librelois
Copy link
Collaborator Author

Just to be clear on what this PR does: if I withdraw 15 assets (nothing prevents me today from doing that) I will be charged as if I was withdrawing 10. Is this the behavior we want?

Good point, the limit applied in the weigher should be equal the the limit applied by the executor, so MAX_ASSETS should be equal to MaxAssetsIntoHolding, I set it to 64 to minimize breaking change.

@librelois librelois mentioned this pull request Apr 11, 2023
20 tasks
@librelois librelois merged commit 0a03e9c into master Apr 12, 2023
20 checks passed
@librelois librelois deleted the elois-limit-xcm-weigher branch April 12, 2023 11:31
@crystalin crystalin changed the title XCM: Limit the max number of assets weighable Limit the max number of assets weighable in XCM Apr 13, 2023
imstar15 pushed a commit to OAK-Foundation/moonbeam that referenced this pull request May 16, 2023
* XCM: Limit the max number of assets weighable

* apply a more reasonable limit for max assets

* MAX_ASSETS should be equal to MaxAssetsIntoHolding
@notlesh notlesh added D1-audited👍 PR contains changes to fund-managing logic that has been properly reviewed and externally audited and removed D5-nicetohaveaudit⚠️ PR contains trivial changes to logic that should be properly reviewed. labels Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes breaking Needs to be mentioned in breaking changes D1-audited👍 PR contains changes to fund-managing logic that has been properly reviewed and externally audited
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants