Skip to content

benchmarking: Support child trie key whitelisting#10992

Open
pgherveou wants to merge 7 commits intomasterfrom
pg/child-trie-whitelist-benchmarking
Open

benchmarking: Support child trie key whitelisting#10992
pgherveou wants to merge 7 commits intomasterfrom
pg/child-trie-whitelist-benchmarking

Conversation

@pgherveou
Copy link
Contributor

@pgherveou pgherveou commented Feb 4, 2026

Summary

Extends the benchmarking framework to support whitelisting child trie storage keys, enabling accurate PoV measurement for pallets that use child tries (e.g. pallet-revive for contract storage).

  • Add child_trie_key: Option<Vec<u8>> field to TrackedStorageKey with new_child() constructor
  • Add add_to_whitelist_child() helper function for benchmarks
  • Update whitelist pre-read in both v1 and v2 benchmark macros to handle child trie keys via child::get_raw()
  • Fix stale whitelist bug: on_before_start now reads from the global whitelist (get_whitelist()) instead of a captured local copy, so keys added during benchmark setup are properly pre-loaded
  • Export ChildInfo from frame_support::storage

Problem

Calling add_to_whitelist() or add_to_whitelist_child() during benchmark setup had no effect on PoV measurement because:

  1. The pre-read only used unhashed::get_raw() which doesn't work for child tries
  2. The pre-read closure captured a local whitelist copy that missed keys added during benchmark setup

Extends the benchmarking framework to support whitelisting child trie
storage keys, which enables accurate PoV (Proof of Validity) measurement
for pallets that use child tries (e.g. pallet-revive for contract storage).

Changes:
- Add `child_trie_key` field to `TrackedStorageKey` with `new_child()`
  constructor
- Add `add_to_whitelist_child()` helper function
- Update whitelist pre-read in both v1 and v2 benchmark macros to handle
  child trie keys via `child::get_raw()`
- Fix stale whitelist bug: `on_before_start` now reads from the global
  whitelist (`get_whitelist()`) instead of a captured local copy, so keys
  added during benchmark setup are properly pre-loaded
- Export `ChildInfo` from `frame_support::storage`

Without this fix, whitelisting child trie keys had no effect on PoV
measurement because:
1. The pre-read only used `unhashed::get_raw()` (main storage only)
2. The pre-read iterated a local whitelist copy that missed keys added
   during benchmark setup via `add_to_whitelist()`
@pgherveou pgherveou marked this pull request as ready for review February 5, 2026 12:34
@pgherveou pgherveou requested a review from a team as a code owner February 5, 2026 12:34
@pgherveou
Copy link
Contributor Author

/cmd prdoc --audience runtime_dev --bump patch

@pgherveou pgherveou added T7-smart_contracts This PR/Issue is related to smart contracts. T12-benchmarks This PR/Issue is related to benchmarking and weights. and removed T7-smart_contracts This PR/Issue is related to smart contracts. labels Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T12-benchmarks This PR/Issue is related to benchmarking and weights.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant