feat(meter-aggregator): bounded meter aggregation with rollups and inline pruning#40
Merged
elizabetheonoja-art merged 2 commits intoJun 25, 2026
Conversation
…line pruning Add a new meter-aggregator Soroban contract that prevents unbounded raw reading accumulation from exhausting per-device contract storage. - Raw readings stored by monotonic seq (O(1) append, time-ordered) - Each reading folded into hourly + daily rollup buckets (overflow-checked) - Inline amortized pruning via watermark cursor, batch-capped per call - 7-day raw retention (MAX_RAW_RETENTION_SECS), PRUNE_BATCH_SIZE=10 - get_aggregated_volume reads tiered: daily -> hourly -> raw - rollup_day reclaims a completed day's hourly buckets - Tests: rollup correctness, overflow, prune boundary, batch limit, storage-exhaustion prevention Registered as a workspace member in contracts/Cargo.toml.
…gator-rollup-pruning # Conflicts: # contracts/Cargo.toml
elizabetheonoja-art
approved these changes
Jun 25, 2026
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 #10
RawReading(device, seq)with amonotonic sequence number → O(1) append, seq order == time order.
submit_reading, the value is folded into the matching hourly anddaily rollup buckets using overflow-checked
i128 checked_add.MAX_RAW_RETENTION_SECS(7 days)are deleted during submission, amortized O(1) via a watermark cursor
PruneCursor(device), capped atPRUNE_BATCH_SIZE(10) per call.get_aggregated_volumereads tiered: daily → hourly → live raw fallback.rollup_day(admin) reclaims a completed day's redundant hourly buckets.Files
contracts/meter-aggregator/src/{constants,types,storage,lib,test}.rscontracts/meter-aggregator/{Cargo.toml,README.md}contracts/Cargo.toml(registers the new workspace member)