Skip to content

feat: compress accrual history into anchor checkpoints - #664

Merged
thlpkee20-wq merged 2 commits into
RevoraOrg:masterfrom
ololadedavidvictor-bit:feat/accrual-checkpoint-compress
Jul 29, 2026
Merged

feat: compress accrual history into anchor checkpoints#664
thlpkee20-wq merged 2 commits into
RevoraOrg:masterfrom
ololadedavidvictor-bit:feat/accrual-checkpoint-compress

Conversation

@ololadedavidvictor-bit

Copy link
Copy Markdown
Contributor

Add checkpoint compression that folds N historical schedule entries into a running anchor once the count exceeds checkpoint_threshold.

  • Add DataKey2::AccrualAnchor and DataKey2::CheckpointThreshold storage keys
  • Add AccrualAnchor struct with end_idx and claimable_sum fields
  • Add CHECKPOINT_THRESHOLD_DEFAULT constant (1000)
  • Add set_checkpoint_threshold / get_checkpoint_threshold public functions
  • When record_holder_share_transition exceeds threshold, compress oldest entries into an anchor with a pre-computed claimable sum keyed by the highest folded period index
  • compute_claimable_preview consumes the anchor when the claim cursor advances past the anchor boundary
  • Both claim functions also consume anchors atomically when LastClaimedIdx crosses the anchor end_idx
  • Add 8 new tests covering compression, lossless computation, partial claims, threshold config, zero-threshold disable, and default threshold

closes #530

Add checkpoint compression that folds N historical schedule entries into
a running anchor once the count exceeds checkpoint_threshold.

- Add DataKey2::AccrualAnchor and DataKey2::CheckpointThreshold storage keys
- Add AccrualAnchor struct with end_idx and claimable_sum fields
- Add CHECKPOINT_THRESHOLD_DEFAULT constant (1000)
- Add set_checkpoint_threshold / get_checkpoint_threshold public functions
- When record_holder_share_transition exceeds threshold, compress oldest
  entries into an anchor with a pre-computed claimable sum keyed by the
  highest folded period index
- compute_claimable_preview consumes the anchor when the claim cursor
  advances past the anchor boundary
- Both claim functions also consume anchors atomically when LastClaimedIdx
  crosses the anchor end_idx
- Add 8 new tests covering compression, lossless computation, partial
  claims, threshold config, zero-threshold disable, and default threshold
@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@ololadedavidvictor-bit 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! 🚀

Learn more about application limits

@thlpkee20-wq
thlpkee20-wq merged commit 025a4de into RevoraOrg:master Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add accrual-index checkpoint compression to bound growth of per-holder accrual history

2 participants