You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Maintain incremental running totals for aggregates #226
Problem Statement.get_aggregates(token) iterates from 0 to KEY_PKG_IDX every call
and reconstructs total_committed, total_claimed, total_expired_cancelled from the
package 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_aggregates reads the pidx index keys, then walks
Package status. A previous fix introduced per-packageKEY_PKG_IDX mapping that
preserves enumeration but compounds the iteration cost.
Expected Outcome. Replace per-token i128 totals at status transitions and get_aggregates returns them in constant time.
Acceptance Criteria.
A new KEY_TOTAL_COMMITTED: Map<Address, i128> mirrored after KEY_TOTAL_LOCKED semantics.
Mutations encapsulated in a helper add_to_status_totals(env, token, status, amount).
Bench: get_aggregates constant 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).
I’m a full-stack software and blockchain engineer with hands-on experience delivering production-ready solutions across frontend, backend, and blockchain systems.
I’d like to take ownership of this issue. I’ve reviewed the requirements and can implement a scalable, maintainable, and well-tested solution that fully satisfies the acceptance criteria.
Ready to start immediately and keep the team updated throughout the process.
I would like to request assignment for this smart contract performance ticket to optimize get_aggregates.I will introduce KEY_TOTAL_COMMITTED (along with mirrored totals) and encapsulate state mutations in an add_to_status_totals helper to track totals at status transitions. This will replace the linear $O(N)$ package iteration with $O(1)$ constant-time reads for dashboards and indexers, and add invariant tests in tests/invariants.rs.Please assign this to me so I can improve the contract's scalability and read performance.
🏆 @Moonwalker-rgb: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (557 total points). Track your full progress on GrantFox.
👏 Great work, @Moonwalker-rgb! Keep contributing to ChainForgee.
Activity
Clement-coder commentedon Jul 20, 2026
Hi,
I’m a full-stack software and blockchain engineer with hands-on experience delivering production-ready solutions across frontend, backend, and blockchain systems.
I’d like to take ownership of this issue. I’ve reviewed the requirements and can implement a scalable, maintainable, and well-tested solution that fully satisfies the acceptance criteria.
Ready to start immediately and keep the team updated throughout the process.
Moonwalker-rgb commentedon Jul 23, 2026
Hi maintainer,
I would like to request assignment for this smart contract performance ticket to optimize get_aggregates.I will introduce KEY_TOTAL_COMMITTED (along with mirrored totals) and encapsulate state mutations in an add_to_status_totals helper to track totals at status transitions. This will replace the linear$O(N)$ package iteration with $O(1)$ constant-time reads for dashboards and indexers, and add invariant tests in tests/invariants.rs.Please assign this to me so I can improve the contract's scalability and read performance.
grantfox-oss commentedon Jul 23, 2026
🦊 GrantFox — @Moonwalker-rgb has been assigned to this issue as part of the Official Campaign | FWC26 campaign!
Next steps:
Closes #226)Good luck! Track your progress on GrantFox.
feat(onchain): maintain incremental running totals for aggregates (#226…
grantfox-oss commentedon Jul 28, 2026
🎉 This issue has been marked as completed on GrantFox as part of the Official Campaign | FWC26 campaign!
@Moonwalker-rgb's PR #416 was approved and merged by @kilodesodiq-arch.
🏆 @Moonwalker-rgb: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (557 total points). Track your full progress on GrantFox.
👏 Great work, @Moonwalker-rgb! Keep contributing to ChainForgee.