feat: [INFRA] Optimize Storage Architecture for State Archival Limits - #34
Merged
Merged
Conversation
…d O(1) cycle reset - Replace 3 persistent entries per member (Contributions, HasContributedThisCycle, HasReceivedPayout) with single MemberState struct under DataKey::Member(Address) - Add dynamic TTL: extend_instance_ttl() uses CycleLengthLedgers from init param (expected_cycle_days, default 30 days); extend_member_ttl() covers full rotation - O(1) reset_cycle() via CurrentCycleId increment instead of per-member iteration - All 19 tests pass, clippy clean, fmt clean, release build succeeds
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Contributor
|
Thank you for your contribution @Skinny001 , please fix conflict, it was as a result of the previously merged PR. |
…remove trigger_payout tests (different API)
Skinny001
force-pushed
the
storage-rent-optimization
branch
from
August 22, 2026 16:58
ff81f87 to
e15ffd0
Compare
…casts in TTL calculation
Contributor
Author
@Queenode all fixed |
Contributor
|
Thank you for your contribution @Skinny001 |
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.
This pull request refactors how member-related state is tracked and managed in the contract, consolidating multiple storage keys into a single
MemberStatestruct per member. It also introduces a new cycle tracking mechanism for contributions and payouts, and allows for a configurable cycle length during initialization. Several test cases are updated to reflect the new initialization parameter.Close #26
State Management Improvements
Introduced a
MemberStatestruct to hold each member'stotal_contributions,last_contribution_cycle_id, andhas_received_payout, replacing multiple scattered storage keys with a single entry per member (DataKey::Member). [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]All member-specific contribution and participation state is now accessed and updated through this struct, simplifying logic for contributions, withdrawals, and member removal. [1] [2] [3] [4] [5] [6] [7] [8]
Cycle and TTL Handling
Added
CurrentCycleIdandCycleLengthLedgersto the instance storage, enabling explicit cycle tracking and dynamic TTL calculation for both the contract and individual members. TTLs are now based on the number of members and the cycle length. [1] [2] [3] [4]The contract increments
CurrentCycleIdat the end of each cycle, and contribution checks use this ID to determine if a member has already contributed in the current cycle. [1] [2]Initialization and Configuration
initializemethod now accepts an optionalexpected_cycle_daysparameter, which determines the cycle length in ledgers. All tests are updated to supply this new parameter. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15]Code Cleanup and Simplification
Removed obsolete storage keys such as
Contributions,HasContributedThisCycle, andUser, consolidating all relevant state intoMemberState. [1] [2] [3] [4] [5] [6]Updated TTL extension logic to use the new member and cycle-based TTL calculations for both the contract instance and individual members. [1] [2]
Test Updates
All contract tests are updated to pass the new
expected_cycle_daysparameter to theinitializemethod. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]…d O(1) cycle resetReplace 3 persistent entries per member (Contributions, HasContributedThisCycle, HasReceivedPayout) with single MemberState struct under DataKey::Member(Address)
Add dynamic TTL: extend_instance_ttl() uses CycleLengthLedgers from init param (expected_cycle_days, default 30 days); extend_member_ttl() covers full rotation
O(1) reset_cycle() via CurrentCycleId increment instead of per-member iteration
All 19 tests pass, clippy clean, fmt clean, release build succeeds