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

Add expensive scenario for asset exchange #7952

Open
wants to merge 38 commits into
base: master
Choose a base branch
from

Conversation

raymondkfcheung
Copy link
Contributor

@raymondkfcheung raymondkfcheung commented Mar 18, 2025

This PR introduces an implementation for worst_case_asset_exchange() in the AssetHubWestend benchmarking setup, partially addressing #7943.

Key Changes

  • Implemented worst_case_asset_exchange() to model a maximum workload scenario.
  • This lays the groundwork for generating accurate weight benchmarks in subsequent steps.

Integration Notes

  • This change should have minimal impact on existing functionality since worst_case_asset_exchange() was previously unimplemented.
  • Future integration steps include generating weights, backporting changes to stable2503, and deploying on AssetHubWestend.

Review Notes

  • Reviewers should focus on the logic for constructing the "worst case" asset exchange scenario.
  • Suggestions for improving complexity modelling or ensuring edge case coverage are welcome.

@raymondkfcheung raymondkfcheung marked this pull request as draft March 18, 2025 10:17
@raymondkfcheung raymondkfcheung self-assigned this Mar 18, 2025
@raymondkfcheung raymondkfcheung added T6-XCM This PR/Issue is related to XCM. T12-benchmarks This PR/Issue is related to benchmarking and weights. labels Mar 18, 2025
@raymondkfcheung
Copy link
Contributor Author

/cmd prdoc --audience runtime_dev --bump patch

@raymondkfcheung raymondkfcheung marked this pull request as ready for review March 18, 2025 11:55
@raymondkfcheung raymondkfcheung added the A4-needs-backport Pull request must be backported to all maintained releases. label Mar 18, 2025
let mut receive_assets = XcmAssets::new();

// Setup assets and pools
for i in 0..MAX_ITEMS_IN_ASSETS {
Copy link
Contributor

Choose a reason for hiding this comment

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

This would be a good worst case if asset hub supported a lot of assets in both give and want but the only asset exchanger only accepts 1 for 1.
We should do one foreign asset exchanging for another.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated to 1 for 1

@raymondkfcheung
Copy link
Contributor Author

/cmd bench --pallet pallet_xcm_benchmarks::fungible --runtime asset-hub-westend

Copy link
Contributor

Command "bench --pallet pallet_xcm_benchmarks::fungible --runtime asset-hub-westend" has started 🚀 See logs here

raymondkfcheung and others added 2 commits March 20, 2025 15:06
Copy link
Contributor

Command "bench --pallet pallet_xcm_benchmarks::fungible --runtime asset-hub-westend" has finished ✅ See logs here

Subweight results:
File Extrinsic Old New Change [%]
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs execute_with_origin 783.00ns 18446744.07s +2355906011967914.00
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs set_appendix 693.00ns 854.00ns +23.23
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs alias_origin 690.00ns 848.00ns +22.90
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs set_topic 681.00ns 833.00ns +22.32
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs clear_topic 655.00ns 801.00ns +22.29
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs clear_transact_status 735.00ns 895.00ns +21.77
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs clear_error 664.00ns 799.00ns +20.33
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs set_fees_mode 663.00ns 790.00ns +19.16
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs set_error_handler 713.00ns 849.00ns +19.07
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs unpaid_execution 695.00ns 827.00ns +18.99
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs clear_origin 674.00ns 800.00ns +18.69
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs asset_claimer 749.00ns 888.00ns +18.56
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs expect_transact_status 838.00ns 979.00ns +16.83
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs buy_execution 699.00ns 813.00ns +16.31
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs refund_surplus 2.78us 3.19us +14.73
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs reserve_asset_deposited 1.37us 1.54us +12.40
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs descend_origin 727.00ns 815.00ns +12.10
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs expect_pallet 5.32us 5.65us +6.09
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs expect_error 3.46us 3.67us +6.01
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs trap 3.45us 3.63us +5.31
Command output:

✅ Successful benchmarks of runtimes/pallets:
-- asset-hub-westend: ['pallet_xcm_benchmarks::fungible']

@raymondkfcheung
Copy link
Contributor Author

/cmd bench --pallet pallet_xcm_benchmarks::generic --runtime asset-hub-westend

Copy link
Contributor

Command "bench --pallet pallet_xcm_benchmarks::generic --runtime asset-hub-westend" has started 🚀 See logs here

…t_xcm_benchmarks::generic --runtime asset-hub-westend'
Copy link
Contributor

Command "bench --pallet pallet_xcm_benchmarks::generic --runtime asset-hub-westend" has finished ✅ See logs here

Subweight results:
File Extrinsic Old New Change [%]
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs execute_with_origin 783.00ns 18446744.07s +2355906011967914.00
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs clear_topic 655.00ns 843.00ns +28.70
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs alias_origin 690.00ns 870.00ns +26.09
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs set_fees_mode 663.00ns 824.00ns +24.28
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs clear_transact_status 735.00ns 893.00ns +21.50
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs clear_error 664.00ns 806.00ns +21.39
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs clear_origin 674.00ns 812.00ns +20.47
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs set_topic 681.00ns 818.00ns +20.12
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs expect_transact_status 838.00ns 1.01us +20.05
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs buy_execution 699.00ns 832.00ns +19.03
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs descend_origin 727.00ns 854.00ns +17.47
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs set_error_handler 713.00ns 832.00ns +16.69
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs unpaid_execution 695.00ns 810.00ns +16.55
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs set_appendix 693.00ns 799.00ns +15.30
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs refund_surplus 2.78us 3.17us +13.83
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs trap 3.45us 3.92us +13.78
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs asset_claimer 749.00ns 840.00ns +12.15
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs expect_error 3.46us 3.73us +7.72
Command output:

✅ Successful benchmarks of runtimes/pallets:
-- asset-hub-westend: ['pallet_xcm_benchmarks::generic']

@bkontur bkontur requested a review from a team as a code owner March 20, 2025 21:06
@paritytech-workflow-stopper
Copy link

All GitHub workflows were cancelled due to failure one of the required jobs.
Failed workflow url: https://github.com/paritytech/polkadot-sdk/actions/runs/13979363063
Failed job name: run-frame-omni-bencher

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A4-needs-backport Pull request must be backported to all maintained releases. T6-XCM This PR/Issue is related to XCM. T12-benchmarks This PR/Issue is related to benchmarking and weights.
Projects
Status: In-Review
Development

Successfully merging this pull request may close these issues.

4 participants