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

Benchmarking xcm instructions Weight #1012

Closed
wants to merge 22 commits into from

Conversation

gitofdeepanshu
Copy link
Contributor

@gitofdeepanshu gitofdeepanshu commented Aug 28, 2023

Pull Request Summary

Currently all xcm instructions occupy same weight, this PR changes that by changing FixedWeightbounds to WeightInfoBounds which benchmarks all xcm instructions for accurate weight.

Benchmarking pallets are inspired from pallet_xcm_benchmark and adjustments related to Shibuya has been made to benchmarks.

Architecture

Just like the original pallet, instructions are divided between generic and fungible instructions, and each pallet's config is configurable to define how the benchmarks will be run.

Furthermore, for fungible instrctions, separate pallets for assets of type balances and assets were added to keep the naming of benchmarks and config consistent and straightforward.

Weight Calculations

For generic instructions we have taken the worst case scenarios that could occur.

For fungible instructions
We benchmark every instruction for 1 asset of pallet_assets and 1 asset of pallet_balances and take the maximum weight consumed between them. For multiple assets, we multiply that weight with the number of assets.

Weight = max_weight_consumption( one pallet_balances token , one pallet_assets token) for that instruction * number of assets

@gitofdeepanshu gitofdeepanshu added runtime This PR/Issue is related to the topic “runtime”. shiden related to shiden runtime labels Aug 28, 2023
@gitofdeepanshu gitofdeepanshu added shibuya related to shibuya and removed shiden related to shiden runtime labels Oct 16, 2023
@AstarNetwork AstarNetwork deleted a comment from github-actions bot Oct 16, 2023
@AstarNetwork AstarNetwork deleted a comment from github-actions bot Oct 16, 2023
@gitofdeepanshu
Copy link
Contributor Author

/bench shibuya-dev astar_xcm_benchmarks::generic

@github-actions
Copy link

Benchmarks job is scheduled at https://github.com/AstarNetwork/Astar/actions/runs/6536053493.
Please wait for a while.
Branch: feat/weightinfobounds-xcm
SHA: ea71a94

@github-actions
Copy link

Benchmark job failed.
Please check https://github.com/AstarNetwork/Astar/actions/runs/6536053493.

@gitofdeepanshu
Copy link
Contributor Author

/bench shibuya-dev astar_xcm_benchmarks

@github-actions
Copy link

Benchmarks job is scheduled at https://github.com/AstarNetwork/Astar/actions/runs/6542412489.
Please wait for a while.
Branch: feat/weightinfobounds-xcm
SHA: 5039bf7

@github-actions
Copy link

Benchmarks have been finished.
You can download artifacts if exists https://github.com/AstarNetwork/Astar/actions/runs/6542412489.

@gitofdeepanshu gitofdeepanshu changed the title Part 1/2 : benchmarking generic xcm instructions weight Benchmarking xcm instructions Weight Oct 19, 2023
@AstarNetwork AstarNetwork deleted a comment from github-actions bot Oct 19, 2023
@gitofdeepanshu
Copy link
Contributor Author

/bench shibuya-dev astar_xcm_benchmarks::generic,astar_xcm_benchmarks::fungible::assets,astar_xcm_benchmarks::fungible::balances

@github-actions
Copy link

Benchmarks have been finished.
You can download artifacts if exists https://github.com/AstarNetwork/Astar/actions/runs/6573291507.

@gitofdeepanshu
Copy link
Contributor Author

/bench shibuya-dev astar_xcm_benchmarks::generic

@github-actions
Copy link

Benchmarks job is scheduled at https://github.com/AstarNetwork/Astar/actions/runs/6574576146.
Please wait for a while.
Branch: feat/weightinfobounds-xcm
SHA: 7f929d1

@github-actions
Copy link

Benchmarks have been finished.
You can download artifacts if exists https://github.com/AstarNetwork/Astar/actions/runs/6574576146.

@gitofdeepanshu gitofdeepanshu marked this pull request as ready for review October 20, 2023 08:54
@gitofdeepanshu
Copy link
Contributor Author

/bench shibuya-dev astar_xcm_benchmarks::generic,astar_xcm_benchmarks::fungible::assets,astar_xcm_benchmarks::fungible::balances

@github-actions
Copy link

Benchmarks job is scheduled at https://github.com/AstarNetwork/Astar/actions/runs/6585607290.
Please wait for a while.
Branch: feat/weightinfobounds-xcm
SHA: bbcff0b

@github-actions
Copy link

Benchmarks have been finished.
You can download artifacts if exists https://github.com/AstarNetwork/Astar/actions/runs/6585607290.

@gitofdeepanshu
Copy link
Contributor Author

/bench shibuya-dev astar_xcm_benchmarks::generic,astar_xcm_benchmarks::fungible::assets,astar_xcm_benchmarks::fungible::balances

@github-actions
Copy link

Benchmarks job is scheduled at https://github.com/AstarNetwork/Astar/actions/runs/6589059865.
Please wait for a while.
Branch: feat/weightinfobounds-xcm
SHA: a4e2bd9

@github-actions
Copy link

Benchmarks have been finished.
You can download artifacts if exists https://github.com/AstarNetwork/Astar/actions/runs/6589059865.

@github-actions
Copy link

Code Coverage

Package Line Rate Branch Rate Health
precompiles/xcm/src 75% 0%
precompiles/sr25519/src 79% 0%
precompiles/dapps-staking/src 93% 0%
pallets/xvm/src 40% 0%
pallets/ethereum-checked/src 48% 0%
pallets/dapps-staking/src 81% 0%
pallets/xc-asset-config/src 53% 0%
precompiles/xvm/src 75% 0%
pallets/astar-xcm-benchmarks/src/fungible/balances 0% 0%
chain-extensions/xvm/src 0% 0%
chain-extensions/pallet-assets/src 0% 0%
pallets/contracts-migration/src 0% 0%
pallets/dynamic-evm-base-fee/src 81% 0%
chain-extensions/dapps-staking/src 0% 0%
pallets/astar-xcm-benchmarks/src 0% 0%
pallets/collator-selection/src 69% 0%
pallets/astar-xcm-benchmarks/src/fungible/assets 0% 0%
precompiles/utils/macro/src 0% 0%
precompiles/assets-erc20/src 76% 0%
pallets/dapps-staking/src/pallet 85% 0%
chain-extensions/types/xvm/src 0% 0%
pallets/astar-xcm-benchmarks/src/fungible 0% 0%
pallets/block-reward/src 85% 0%
chain-extensions/types/dapps-staking/src 0% 0%
pallets/astar-xcm-benchmarks/src/generic 0% 0%
precompiles/utils/src/testing 38% 0%
pallets/unified-accounts/src 80% 0%
chain-extensions/types/assets/src 0% 0%
primitives/src/xcm 66% 0%
precompiles/substrate-ecdsa/src 78% 0%
precompiles/utils/src 55% 0%
primitives/src 62% 0%
Summary 56% (2192 / 3926) 0% (0 / 0)

Minimum allowed line rate is 50%

Comment on lines 29 to 46
benchmarks_instance_pallet! {
where_clause { where
<
<
T::TransactAsset
as
Inspect<T::AccountId>
>::Balance
as
TryInto<u128>
>::Error: sp_std::fmt::Debug,

< T::TransactAsset
as
Inspect<T::AccountId>
>::Balance : Into<u128>

}
Copy link
Member

Choose a reason for hiding this comment

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

Why use old v1 benchmarks if new v2 has been available for many months?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to v2.

Comment on lines +21 to +22
pub mod assets;
pub mod balances;
Copy link
Member

Choose a reason for hiding this comment

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

Are two completely separate modules really needed?

Seems like lots of copy/paste, for mock.rs and mod.rs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted our pallet to have consistent style with the original pallet so I used the same format. We can also merge them into one but that would mean changing the variable names and name of benchmarks and some logic which will be different from the original pallet.
Let me know what you think.

@gitofdeepanshu
Copy link
Contributor Author

/bench shibuya-dev astar_xcm_benchmarks::generic,astar_xcm_benchmarks::fungible::assets,astar_xcm_benchmarks::fungible::balances

Copy link

github-actions bot commented Nov 2, 2023

Benchmarks job is scheduled at https://github.com/AstarNetwork/Astar/actions/runs/6728742049.
Please wait for a while.
Branch: feat/weightinfobounds-xcm
SHA: 2908a26

Copy link

github-actions bot commented Nov 2, 2023

Benchmarks have been finished.
You can download artifacts if exists https://github.com/AstarNetwork/Astar/actions/runs/6728742049.

@andabak andabak assigned andabak and ashutoshvarma and unassigned andabak Nov 21, 2023
@ashutoshvarma ashutoshvarma mentioned this pull request Jan 11, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
runtime This PR/Issue is related to the topic “runtime”. shibuya related to shibuya
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants