perf(metadata): paginate get_version_history to bound history reads - #1075
Open
Moonwalker-rgb wants to merge 1 commit into
Open
perf(metadata): paginate get_version_history to bound history reads#1075Moonwalker-rgb wants to merge 1 commit into
Moonwalker-rgb wants to merge 1 commit into
Conversation
get_version_history scanned every recorded version on each call, so reads grew linearly with metadata churn. Add from_version/limit pagination so callers fetch at most O(limit) entries per call, and assert paged reads reconstruct the full history in order. Fixes MettaChain#1028.
|
@Moonwalker-rgb Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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 #1028
Summary
get_version_historylooped over every version ever recorded for a property on each call, so reads grew linearly with metadata churn and could eventually exceed block weight limits for long-lived properties.Changes
contracts/metadata/src/lib.rs:get_version_history(property_id, from_version, limit)now returns at mostlimitentries in ascending version order, starting atfrom_version— O(limit) storage reads per call instead of O(total versions). Callers page forward by passing the last entry'sversion + 1; an empty page means the end of the history.Verification
cargo test -p propchain-metadatapasses (6 tests).