Skip to content

Consolidate pallet-assets metadata benchmarks into single get_metadata benchmark#11037

Merged
0xRVE merged 6 commits intomasterfrom
rve/ierc20metadata
Feb 13, 2026
Merged

Consolidate pallet-assets metadata benchmarks into single get_metadata benchmark#11037
0xRVE merged 6 commits intomasterfrom
rve/ierc20metadata

Conversation

@0xRVE
Copy link
Copy Markdown
Contributor

@0xRVE 0xRVE commented Feb 10, 2026

Summary

Consolidates the three identical get_name, get_symbol, and get_decimals benchmarks into a single get_metadata benchmark. This addresses the follow-up from #10971 where it was noted that these benchmarks perform the same operation (Pallet::get_metadata()).

Changes

Benchmarks

  • substrate/frame/assets/src/benchmarking.rs
    • Replaced get_name, get_symbol, get_decimals with single get_metadata benchmark
    • Updated verification to check all three metadata fields (name, symbol, decimals)

Weight Functions

  • substrate/frame/assets/src/weights.rs
    • Replaced get_name(), get_symbol(), get_decimals() with single get_metadata() in WeightInfo trait
    • Updated implementations for SubstrateWeight<T> and ()

Precompile

  • substrate/frame/assets/precompiles/src/lib.rs
    • Updated name(), symbol(), and decimals() methods to all charge get_metadata() weight

Cumulus Runtimes

Updated weight implementations in:

  • asset-hub-rococo: pallet_assets_foreign.rs, pallet_assets_local.rs, pallet_assets_pool.rs
  • asset-hub-westend: pallet_assets_foreign.rs, pallet_assets_local.rs, pallet_assets_pool.rs

Rationale

All three original benchmarks were measuring the exact same operation - a single metadata storage read. Consolidating them:

  1. Reduces code duplication
  2. Simplifies the WeightInfo trait
  3. Accurately reflects that name(), symbol(), and decimals() have identical costs

Closes follow-up from #10971 (comment)

@0xRVE 0xRVE requested a review from a team as a code owner February 10, 2026 15:14
@0xRVE
Copy link
Copy Markdown
Contributor Author

0xRVE commented Feb 10, 2026

/cmd bench --runtime dev

@github-actions
Copy link
Copy Markdown
Contributor

Command "bench --runtime dev" has started 🚀 See logs here

@0xRVE
Copy link
Copy Markdown
Contributor Author

0xRVE commented Feb 10, 2026

/cmd bench --runtime dev --pallet pallet_assets pallet-assets-precompiles

@github-actions
Copy link
Copy Markdown
Contributor

Command "bench --runtime dev --pallet pallet_assets pallet-assets-precompiles" has started 🚀 See logs here

@github-actions
Copy link
Copy Markdown
Contributor

Command "bench --runtime dev --pallet pallet_assets pallet-assets-precompiles" has failed ❌! See logs here

@0xRVE
Copy link
Copy Markdown
Contributor Author

0xRVE commented Feb 10, 2026

/cmd bench --runtime dev --pallet pallet_assets pallet_assets_precompiles

@github-actions
Copy link
Copy Markdown
Contributor

Command "bench --runtime dev --pallet pallet_assets pallet_assets_precompiles" has started 🚀 See logs here

@github-actions
Copy link
Copy Markdown
Contributor

Command "bench --runtime dev --pallet pallet_assets pallet_assets_precompiles" has failed ❌! See logs here

@0xRVE
Copy link
Copy Markdown
Contributor Author

0xRVE commented Feb 10, 2026

/cmd bench --runtime dev --pallet pallet_assets

@github-actions
Copy link
Copy Markdown
Contributor

Command "bench --runtime dev --pallet pallet_assets" has started 🚀 See logs here

@github-actions
Copy link
Copy Markdown
Contributor

Command "bench --runtime dev --pallet pallet_assets" has finished ✅ See logs here

Details

Subweight results:
File Extrinsic Old New Change [%]
substrate/frame/assets/src/weights.rs destroy_accounts 16.10ms 266.81ms +1557.19
substrate/frame/assets/src/weights.rs migration_v2_foreign_asset_set_reserve_weight 10.03us 135.15us +1247.27
substrate/frame/assets/src/weights.rs finish_destroy 22.19us 269.19us +1112.98
substrate/frame/assets/src/weights.rs transfer_keep_alive 52.87us 552.28us +944.65
substrate/frame/assets/src/weights.rs force_create 16.19us 166.26us +926.91
substrate/frame/assets/src/weights.rs force_set_metadata 17.25us 167.20us +869.24
substrate/frame/assets/src/weights.rs force_transfer 57.68us 557.53us +866.56
substrate/frame/assets/src/weights.rs refund 43.47us 417.99us +861.46
substrate/frame/assets/src/weights.rs transfer 58.05us 557.63us +860.58
substrate/frame/assets/src/weights.rs touch 45.71us 419.95us +818.72
substrate/frame/assets/src/weights.rs transfer_approved 83.20us 707.91us +750.84
substrate/frame/assets/src/weights.rs mint 33.02us 280.24us +748.75
substrate/frame/assets/src/weights.rs transfer_all 69.82us 569.02us +714.95
substrate/frame/assets/src/weights.rs transfer_ownership 20.87us 168.20us +706.03
substrate/frame/assets/src/weights.rs create 39.02us 313.41us +703.17
substrate/frame/assets/src/weights.rs destroy_approvals 18.45ms 143.98ms +680.44
substrate/frame/assets/src/weights.rs force_asset_status 18.29us 140.85us +670.14
substrate/frame/assets/src/weights.rs freeze_asset 18.95us 144.72us +663.76
substrate/frame/assets/src/weights.rs thaw_asset 19.12us 143.78us +651.91
substrate/frame/assets/src/weights.rs set_team 18.79us 140.89us +649.89
substrate/frame/assets/src/weights.rs start_destroy 19.34us 144.25us +645.76
substrate/frame/assets/src/weights.rs set_min_balance 19.53us 141.75us +625.75
substrate/frame/assets/src/weights.rs thaw 24.39us 174.79us +616.61
substrate/frame/assets/src/weights.rs block 24.39us 174.75us +616.58
substrate/frame/assets/src/weights.rs freeze 24.60us 174.34us +608.73
substrate/frame/assets/src/weights.rs refund_other 41.21us 289.95us +603.58
substrate/frame/assets/src/weights.rs set_reserves 20.85us 145.97us +600.19
substrate/frame/assets/src/weights.rs burn 42.19us 292.98us +594.49
substrate/frame/assets/src/weights.rs touch_other 43.34us 292.45us +574.75
substrate/frame/assets/src/weights.rs approve_transfer 44.13us 293.86us +565.82
substrate/frame/assets/src/weights.rs force_cancel_approval 45.19us 294.77us +552.29
substrate/frame/assets/src/weights.rs cancel_approval 45.69us 294.99us +545.60
substrate/frame/assets/src/weights.rs force_clear_metadata 37.55us 187.25us +398.66
substrate/frame/assets/src/weights.rs clear_metadata 38.77us 188.18us +385.36
substrate/frame/assets/src/weights.rs set_metadata 39.95us 188.93us +372.90
substrate/frame/assets/src/weights.rs total_issuance 11.46us 36.21us +215.97
substrate/frame/assets/src/weights.rs balance 11.46us 33.33us +190.71
substrate/frame/assets/src/weights.rs allowance 14.86us 36.45us +145.31
substrate/frame/assets/src/weights.rs get_metadata 35.70us Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_assets_pool.rs get_metadata 11.12us Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_assets_local.rs get_metadata 11.12us Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_assets_foreign.rs get_metadata 11.12us Added
cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_assets_pool.rs get_metadata 11.12us Added
cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_assets_local.rs get_metadata 11.12us Added
cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_assets_foreign.rs get_metadata 11.12us Added
Command output:

✅ Successful benchmarks of runtimes/pallets:
-- dev: ['pallet_assets']

@0xRVE
Copy link
Copy Markdown
Contributor Author

0xRVE commented Feb 10, 2026

/cmd bench --runtime dev --pallet pallet_assets_precompiles

@github-actions
Copy link
Copy Markdown
Contributor

Command "bench --runtime dev --pallet pallet_assets_precompiles" has started 🚀 See logs here

@github-actions
Copy link
Copy Markdown
Contributor

Command "bench --runtime dev --pallet pallet_assets_precompiles" has failed ❌! See logs here

@0xRVE
Copy link
Copy Markdown
Contributor Author

0xRVE commented Feb 11, 2026

/cmd bench --runtime asset-hub-westend --pallet pallet_assets

@0xRVE
Copy link
Copy Markdown
Contributor Author

0xRVE commented Feb 11, 2026

/cmd bench --runtime asset-hub-rococo --pallet pallet_assets

@0xRVE 0xRVE added the T7-smart_contracts This PR/Issue is related to smart contracts. label Feb 11, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Command "bench --runtime asset-hub-westend --pallet pallet_assets" has started 🚀 See logs here

@0xRVE
Copy link
Copy Markdown
Contributor Author

0xRVE commented Feb 11, 2026

/cmd prdoc --audience runtime_dev --bump patch

@github-actions
Copy link
Copy Markdown
Contributor

Command "bench --runtime asset-hub-rococo --pallet pallet_assets" has started 🚀 See logs here

@github-actions
Copy link
Copy Markdown
Contributor

Command "bench --runtime asset-hub-rococo --pallet pallet_assets" has failed ❌! See logs here

@github-actions
Copy link
Copy Markdown
Contributor

Command "bench --runtime asset-hub-westend --pallet pallet_assets" has finished ✅ See logs here

Details

Subweight results:
File Extrinsic Old New Change [%]
substrate/frame/assets/src/weights.rs destroy_accounts 16.10ms 266.81ms +1557.19
substrate/frame/assets/src/weights.rs migration_v2_foreign_asset_set_reserve_weight 10.03us 135.15us +1247.27
substrate/frame/assets/src/weights.rs finish_destroy 22.19us 269.19us +1112.98
substrate/frame/assets/src/weights.rs transfer_keep_alive 52.87us 552.28us +944.65
substrate/frame/assets/src/weights.rs force_create 16.19us 166.26us +926.91
substrate/frame/assets/src/weights.rs force_set_metadata 17.25us 167.20us +869.24
substrate/frame/assets/src/weights.rs force_transfer 57.68us 557.53us +866.56
substrate/frame/assets/src/weights.rs refund 43.47us 417.99us +861.46
substrate/frame/assets/src/weights.rs transfer 58.05us 557.63us +860.58
substrate/frame/assets/src/weights.rs touch 45.71us 419.95us +818.72
substrate/frame/assets/src/weights.rs transfer_approved 83.20us 707.91us +750.84
substrate/frame/assets/src/weights.rs mint 33.02us 280.24us +748.75
substrate/frame/assets/src/weights.rs transfer_all 69.82us 569.02us +714.95
substrate/frame/assets/src/weights.rs transfer_ownership 20.87us 168.20us +706.03
substrate/frame/assets/src/weights.rs create 39.02us 313.41us +703.17
substrate/frame/assets/src/weights.rs destroy_approvals 18.45ms 143.98ms +680.44
substrate/frame/assets/src/weights.rs force_asset_status 18.29us 140.85us +670.14
substrate/frame/assets/src/weights.rs freeze_asset 18.95us 144.72us +663.76
substrate/frame/assets/src/weights.rs thaw_asset 19.12us 143.78us +651.91
substrate/frame/assets/src/weights.rs set_team 18.79us 140.89us +649.89
substrate/frame/assets/src/weights.rs start_destroy 19.34us 144.25us +645.76
substrate/frame/assets/src/weights.rs set_min_balance 19.53us 141.75us +625.75
substrate/frame/assets/src/weights.rs thaw 24.39us 174.79us +616.61
substrate/frame/assets/src/weights.rs block 24.39us 174.75us +616.58
substrate/frame/assets/src/weights.rs freeze 24.60us 174.34us +608.73
substrate/frame/assets/src/weights.rs refund_other 41.21us 289.95us +603.58
substrate/frame/assets/src/weights.rs set_reserves 20.85us 145.97us +600.19
substrate/frame/assets/src/weights.rs burn 42.19us 292.98us +594.49
substrate/frame/assets/src/weights.rs touch_other 43.34us 292.45us +574.75
substrate/frame/assets/src/weights.rs approve_transfer 44.13us 293.86us +565.82
substrate/frame/assets/src/weights.rs force_cancel_approval 45.19us 294.77us +552.29
substrate/frame/assets/src/weights.rs cancel_approval 45.69us 294.99us +545.60
substrate/frame/assets/src/weights.rs force_clear_metadata 37.55us 187.25us +398.66
substrate/frame/assets/src/weights.rs clear_metadata 38.77us 188.18us +385.36
substrate/frame/assets/src/weights.rs set_metadata 39.95us 188.93us +372.90
substrate/frame/assets/src/weights.rs total_issuance 11.46us 36.21us +215.97
substrate/frame/assets/src/weights.rs balance 11.46us 33.33us +190.71
substrate/frame/assets/src/weights.rs allowance 14.86us 36.45us +145.31
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_assets_pool.rs total_issuance 37.41us 33.69us -9.95
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_assets_local.rs total_issuance 38.10us 33.81us -11.25
substrate/frame/assets/src/weights.rs get_metadata 35.70us Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_assets_pool.rs get_metadata 34.17us Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_assets_local.rs get_metadata 34.42us Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_assets_foreign.rs get_metadata 33.41us Added
cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_assets_pool.rs get_metadata 11.12us Added
cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_assets_local.rs get_metadata 11.12us Added
cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_assets_foreign.rs get_metadata 11.12us Added
Command output:

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

@0xRVE 0xRVE requested a review from acatangiu February 13, 2026 08:21
@0xRVE 0xRVE requested a review from pgherveou February 13, 2026 08:22
@0xRVE 0xRVE added this pull request to the merge queue Feb 13, 2026
Merged via the queue into master with commit bab8ed7 Feb 13, 2026
247 of 248 checks passed
@0xRVE 0xRVE deleted the rve/ierc20metadata branch February 13, 2026 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T7-smart_contracts This PR/Issue is related to smart contracts.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants