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

[Enhancement] Use XCM V3 for initiate_teleport weight calc #2102

Merged
merged 9 commits into from
Feb 9, 2023

Conversation

ruseinov
Copy link
Contributor

@ruseinov ruseinov commented Jan 17, 2023

Fixes #1669

@ruseinov ruseinov self-assigned this Jan 17, 2023
@ruseinov ruseinov added A0-please_review Pull request needs code review. D9-needsaudit 👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited B1-note_worthy Changes should be noted in the release notes T6-XCM This PR/Issue is related to XCM. C1-low PR touches the given topic and has a low impact on builders. labels Jan 17, 2023
@ruseinov ruseinov requested a review from KiChjang January 31, 2023 13:09
@ruseinov ruseinov added D5-nicetohaveaudit ⚠️ PR contains trivial changes to logic that should be properly reviewed. T1-runtime This PR/Issue is related to the topic “runtime”. and removed D9-needsaudit 👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited labels Jan 31, 2023
Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64),
Self::Wild(asset) => match asset {
All => weight.saturating_mul(MAX_ASSETS as u64),
AllOf { .. } => weight,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually still uncertain about this -- comments on AllOfCounted says that each individual instance of an NFT is considered a different class of asset, and so wouldn't it make more sense to use the number of NFT instances as an upper bound here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, good question. Let me check it out and come back to you.

Copy link
Contributor Author

@ruseinov ruseinov Feb 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think this makes sense. I'm not sure though where the NFT instance count should be coming from in this case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this requires you to actually look inside the holding register and determine just how many AssetInstances there are... We could match against fun in AllOf and see if it's a NonFungible, and if so, it would basically be weight * MaxAssetsIntoHolding::get(), otherwise it's just weight.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KiChjang One thing that disturbs me a bit is the comment below, should we then do something like weight * MaxAssetsIntoHolding::get() * 2 to be safe?

	/// The maximum number of assets we target to have in the Holding Register at any one time.
	///
	/// NOTE: In the worse case, the Holding Register may contain up to twice as many assets as this
	/// and any benchmarks should take that into account.
	type MaxAssetsIntoHolding: Get<u32>;

@ruseinov
Copy link
Contributor Author

ruseinov commented Feb 9, 2023

bot rebase

@paritytech-processbot
Copy link

Rebased

@ruseinov
Copy link
Contributor Author

ruseinov commented Feb 9, 2023

bot merge

@paritytech-processbot
Copy link

Waiting for commit status.

@paritytech-processbot paritytech-processbot bot merged commit 8230ec4 into master Feb 9, 2023
@paritytech-processbot paritytech-processbot bot deleted the ru/enhancement/iinitinit-teleport branch February 9, 2023 15:01
bkontur pushed a commit that referenced this pull request Feb 25, 2023
* [Enhancement] Use XCM V3 for initiate_teleport weight calc

* deref

* replicate in all the runtimes

* fmt

* better handling for AllOf

* fmt

* small type fix

* replicate the fix for all runtimes

---------

Co-authored-by: parity-processbot <>
paritytech-processbot bot pushed a commit that referenced this pull request Feb 27, 2023
)

* Wwstmint test for ReceiveTeleportedAsset

* Missing fix for `weigh_multi_assets`

* Added tests for statemine/statemint

* [Enhancement] Use XCM V3 for initiate_teleport weight calc (#2102)

* [Enhancement] Use XCM V3 for initiate_teleport weight calc

* deref

* replicate in all the runtimes

* fmt

* better handling for AllOf

* fmt

* small type fix

* replicate the fix for all runtimes

---------

Co-authored-by: parity-processbot <>

* removed `frame_support::sp_tracing::try_init_simple();`

* Review fixes

* Removed `as u64`

---------

Co-authored-by: Roman Useinov <roman.useinov@gmail.com>
EgorPopelyaev pushed a commit that referenced this pull request Feb 27, 2023
)

* Wwstmint test for ReceiveTeleportedAsset

* Missing fix for `weigh_multi_assets`

* Added tests for statemine/statemint

* [Enhancement] Use XCM V3 for initiate_teleport weight calc (#2102)

* [Enhancement] Use XCM V3 for initiate_teleport weight calc

* deref

* replicate in all the runtimes

* fmt

* better handling for AllOf

* fmt

* small type fix

* replicate the fix for all runtimes

---------

Co-authored-by: parity-processbot <>

* removed `frame_support::sp_tracing::try_init_simple();`

* Review fixes

* Removed `as u64`

---------

Co-authored-by: Roman Useinov <roman.useinov@gmail.com>
EgorPopelyaev pushed a commit that referenced this pull request Feb 27, 2023
)

* Wwstmint test for ReceiveTeleportedAsset

* Missing fix for `weigh_multi_assets`

* Added tests for statemine/statemint

* [Enhancement] Use XCM V3 for initiate_teleport weight calc (#2102)

* [Enhancement] Use XCM V3 for initiate_teleport weight calc

* deref

* replicate in all the runtimes

* fmt

* better handling for AllOf

* fmt

* small type fix

* replicate the fix for all runtimes

---------

Co-authored-by: parity-processbot <>

* removed `frame_support::sp_tracing::try_init_simple();`

* Review fixes

* Removed `as u64`

---------

Co-authored-by: Roman Useinov <roman.useinov@gmail.com>
EgorPopelyaev pushed a commit that referenced this pull request Feb 27, 2023
)

* Wwstmint test for ReceiveTeleportedAsset

* Missing fix for `weigh_multi_assets`

* Added tests for statemine/statemint

* [Enhancement] Use XCM V3 for initiate_teleport weight calc (#2102)

* [Enhancement] Use XCM V3 for initiate_teleport weight calc

* deref

* replicate in all the runtimes

* fmt

* better handling for AllOf

* fmt

* small type fix

* replicate the fix for all runtimes

---------

Co-authored-by: parity-processbot <>

* removed `frame_support::sp_tracing::try_init_simple();`

* Review fixes

* Removed `as u64`

---------

Co-authored-by: Roman Useinov <roman.useinov@gmail.com>
EgorPopelyaev added a commit that referenced this pull request Feb 27, 2023
) (#2239)

* Wwstmint test for ReceiveTeleportedAsset

* Missing fix for `weigh_multi_assets`

* Added tests for statemine/statemint

* [Enhancement] Use XCM V3 for initiate_teleport weight calc (#2102)

* [Enhancement] Use XCM V3 for initiate_teleport weight calc

* deref

* replicate in all the runtimes

* fmt

* better handling for AllOf

* fmt

* small type fix

* replicate the fix for all runtimes

---------

Co-authored-by: parity-processbot <>

* removed `frame_support::sp_tracing::try_init_simple();`

* Review fixes

* Removed `as u64`

---------

Co-authored-by: Branislav Kontur <bkontur@gmail.com>
Co-authored-by: Roman Useinov <roman.useinov@gmail.com>
EgorPopelyaev added a commit that referenced this pull request Feb 27, 2023
) (#2240)

* Wwstmint test for ReceiveTeleportedAsset

* Missing fix for `weigh_multi_assets`

* Added tests for statemine/statemint

* [Enhancement] Use XCM V3 for initiate_teleport weight calc (#2102)

* [Enhancement] Use XCM V3 for initiate_teleport weight calc

* deref

* replicate in all the runtimes

* fmt

* better handling for AllOf

* fmt

* small type fix

* replicate the fix for all runtimes

---------

Co-authored-by: parity-processbot <>

* removed `frame_support::sp_tracing::try_init_simple();`

* Review fixes

* Removed `as u64`

---------

Co-authored-by: Branislav Kontur <bkontur@gmail.com>
Co-authored-by: Roman Useinov <roman.useinov@gmail.com>
paritytech-processbot bot pushed a commit that referenced this pull request Feb 27, 2023
) (#2238)

* Wwstmint test for ReceiveTeleportedAsset

* Missing fix for `weigh_multi_assets`

* Added tests for statemine/statemint

* [Enhancement] Use XCM V3 for initiate_teleport weight calc (#2102)

* [Enhancement] Use XCM V3 for initiate_teleport weight calc

* deref

* replicate in all the runtimes

* fmt

* better handling for AllOf

* fmt

* small type fix

* replicate the fix for all runtimes

---------

Co-authored-by: parity-processbot <>

* removed `frame_support::sp_tracing::try_init_simple();`

* Review fixes

* Removed `as u64`

---------

Co-authored-by: Branislav Kontur <bkontur@gmail.com>
Co-authored-by: Roman Useinov <roman.useinov@gmail.com>
@gilescope gilescope mentioned this pull request Mar 28, 2023
gilescope added a commit that referenced this pull request Mar 29, 2023
* Revert "[Enhancement] Use XCM V3 for initiate_teleport weight calc (#2102)"

This reverts commit 8230ec4.

* updating weight format

* We expect to pay 1bn+ for a teleport at the current weights.

* The test isn't needed and hardcoded scale is hand to maintain.

* remove unused imports

---------

Co-authored-by: Giles Cope <gilescope@gmail.com>
EgorPopelyaev added a commit that referenced this pull request Mar 29, 2023
* Revert "[Enhancement] Use XCM V3 for initiate_teleport weight calc (#2102)"

This reverts commit 8230ec4.

* updating weight format

* We expect to pay 1bn+ for a teleport at the current weights.

* The test isn't needed and hardcoded scale is hand to maintain.

* remove unused imports

---------

Co-authored-by: Giles Cope <gilescope@gmail.com>
EgorPopelyaev added a commit that referenced this pull request Mar 29, 2023
* Revert "[Enhancement] Use XCM V3 for initiate_teleport weight calc (#2102)"

This reverts commit 8230ec4.

* updating weight format

* We expect to pay 1bn+ for a teleport at the current weights.

* The test isn't needed and hardcoded scale is hand to maintain.

* remove unused imports

---------

Co-authored-by: Giles Cope <gilescope@gmail.com>
EgorPopelyaev added a commit that referenced this pull request Mar 30, 2023
…2402)

* Revert "[Enhancement] Use XCM V3 for initiate_teleport weight calc (#2102)"

This reverts commit 8230ec4.

* updating weight format

* We expect to pay 1bn+ for a teleport at the current weights.

* The test isn't needed and hardcoded scale is hand to maintain.

* remove unused imports

---------

Co-authored-by: Giles Cope <gilescope@gmail.com>
EgorPopelyaev added a commit that referenced this pull request Mar 30, 2023
…2403)

* Revert "[Enhancement] Use XCM V3 for initiate_teleport weight calc (#2102)"

This reverts commit 8230ec4.

* updating weight format

* We expect to pay 1bn+ for a teleport at the current weights.

* The test isn't needed and hardcoded scale is hand to maintain.

* remove unused imports

---------

Co-authored-by: Giles Cope <gilescope@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B1-note_worthy Changes should be noted in the release notes C1-low PR touches the given topic and has a low impact on builders. D5-nicetohaveaudit ⚠️ PR contains trivial changes to logic that should be properly reviewed. T1-runtime This PR/Issue is related to the topic “runtime”. T6-XCM This PR/Issue is related to XCM.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Fix] Hardcoded weight for initiate_teleport
4 participants