-
Notifications
You must be signed in to change notification settings - Fork 84
Maintain incremental running totals for aggregates #226
Copy link
Copy link
Closed
Labels
GrantFox OSSIssue tracked in GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26Campaign: Official Campaign | FWC26area:onchainOn-chain (Soroban) areaOn-chain (Soroban) areakind:performancePerformance / scalabilityPerformance / scalability
Description
Activity
Metadata
Metadata
Assignees
Labels
GrantFox OSSIssue tracked in GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26Campaign: Official Campaign | FWC26area:onchainOn-chain (Soroban) areaOn-chain (Soroban) areakind:performancePerformance / scalabilityPerformance / scalability
Problem Statement.
get_aggregates(token)iterates from 0 toKEY_PKG_IDXevery calland reconstructs
total_committed,total_claimed,total_expired_cancelledfrom thepackage list. For a deployment with hundreds of packages this is O(N) per read and cannot
be cached.
Why it matters. Dashboard latency and off-chain indexer costs both grow linearly.
Technical Context.
lib.rs::get_aggregatesreads thepidxindex keys, then walksPackage status. A previous fix introduced per-package
KEY_PKG_IDXmapping thatpreserves enumeration but compounds the iteration cost.
Expected Outcome. Replace per-token
i128totals at status transitions andget_aggregatesreturns them in constant time.Acceptance Criteria.
KEY_TOTAL_COMMITTED: Map<Address, i128>mirrored afterKEY_TOTAL_LOCKEDsemantics.add_to_status_totals(env, token, status, amount).get_aggregatesconstant time regardless of package count.Implementation Notes. This can be coupled with #16 since both refactor storage access.
Files or modules likely to be affected.
src/lib.rs,tests/invariants.rs(new).Dependencies. #15 (invariant test), #16.
Difficulty. Medium
Estimated effort. M
Backlog item #18 from `docs/maintainer-issue-backlog.md.