Repository navigation
nft-credits: Weigh build_credit_tree per award chunk and regenerate its weights - #155
Open
shawntabrizi wants to merge 11 commits into
Open
shawntabrizi wants to merge 11 commits into
shawntabrizi wants to merge 11 commits into
Conversation
The `build_credit_tree` weights were renamed by hand when awards were chunked (#50) but never regenerated. They still charge one `NftClaimCreditAwards` read of the old single-vector layout and a fixed proof size of 81_479 bytes over `[1, 1200]`, while a full tree of `AWARDS_PER_TREE = 2048` awards reads 64 chunks, 133_184 bytes. The `integrity_test` now asserts that the worst-case weight declares at least the proof of every chunk a tree reads, so stale weights fail the runtime tests rather than under-charge `on_initialize`. Fixes paritytech/srlabs_findings#743 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Member
Author
|
/cmd bench --pallet indiv_pallet_nft_credits |
Contributor
|
Command "bench --pallet indiv_pallet_nft_credits" has started 🚀 See logs here |
|
Command "bench --pallet indiv_pallet_nft_credits" has finished ✅ See logs here Runtime weight deviation: |
The generated weight declared a fixed `reads(69)`: a chunk read per 32 awards is a slope of 1/32 read per award, which rounds to zero. The benchmark now sweeps the number of full chunks, and `build_credit_tree` is charged for the chunks `block_awards` reads, so each chunk adds one read and its proof size. Also shortens the integrity check's comment and assert. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Member
Author
|
/cmd bench --pallet indiv_pallet_nft_credits |
Contributor
|
Command "bench --pallet indiv_pallet_nft_credits" has started 🚀 See logs here |
|
Command "bench --pallet indiv_pallet_nft_credits" has finished ✅ See logs here Runtime weight deviation: |
tindzk
reviewed
Oct 1, 2026
tindzk
approved these changes
Oct 1, 2026
agustinustheo
approved these changes
Nov 14, 2026
Co-authored-by: theo <37565691+agustinustheo@users.noreply.github.com> Signed-off-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Tim Nieradzik <tim.n@parity.io> Signed-off-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Takes main's regenerated nft-credits weights except build_credit_tree, which keeps the per-chunk weight until the bench bot reruns. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
/cmd bench --pallet indiv_pallet_nft_credits |
Contributor
|
Command "bench --pallet indiv_pallet_nft_credits" has started 🚀 See logs here |
|
Command "bench --pallet indiv_pallet_nft_credits" has finished ✅ See logs here Runtime weight deviation: |
…tree-proof-size # Conflicts: # pallets/nft-credits/src/weights.rs # runtimes/next-people-paseo/src/weights/indiv_pallet_nft_credits.rs
shawntabrizi
enabled auto-merge (squash)
November 25, 2026 17:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes https://github.com/paritytech/srlabs_findings/issues/743
When #50 chunked
NftClaimCreditAwardsinto 32-award chunks and raised a tree toAWARDS_PER_TREE = 2048, thebuild_credit_treeweights were renamed by hand but not regenerated. They still described oneNftClaimCreditAwardsread over[1, 1200], with a fixed proof size of 81_479 bytes. A full tree reads 64 chunks, which is 133_184 bytes of proof. Regenerating over awards alone is not enough: one chunk read per 32 awards is a slope of 1/32 read per award, which the generated weight rounds to zero, so the reads stay fixed.The benchmark now sweeps the number of full award chunks,
c: Linear<1, CHUNKS_PER_TREE>, andbuild_credit_treeis charged for the chunksblock_awardsreads. Each chunk then adds one read and its proof size. Theintegrity_testalso asserts that the worst-case weight covers the proof size of every chunk in a full tree, so stale weights fail the runtime tests.Changes
build_credit_treebenchmark: componentn: Linear<1, AWARDS_PER_TREE>→c: Linear<1, CHUNKS_PER_TREE>, withc * AWARDS_PER_CHUNKawards.Pallet::build_credit_tree: weighsbuffered.div_ceil(AWARDS_PER_CHUNK)chunks instead of the leaf count. A tree with a partly full last chunk pays for a full chunk.integrity_test_credits: calls the weight withCHUNKS_PER_TREEand assertsproof_size >= CHUNKS_PER_TREE * MaxEncodedLen(chunk). Zero weights (the mock) are skipped.indiv_pallet_nft_creditsweights (palletweights.rsandnext-people-paseoruntime), by the bench bot.