Skip to content

Fix/govenance bound snapshot ttl - #455

Open
awwalmust wants to merge 4 commits into
Stellar-Search:mainfrom
awwalmust:Fix/Govenance-bound-Snapshot-TTL
Open

Fix/govenance bound snapshot ttl#455
awwalmust wants to merge 4 commits into
Stellar-Search:mainfrom
awwalmust:Fix/Govenance-bound-Snapshot-TTL

Conversation

@awwalmust

Copy link
Copy Markdown
Contributor

Description

Resolves #116

Prevents unbounded persistent storage growth in dao-governance-contract by restricting Snapshot TTL extensions to active proposal voting windows. Once a proposal is finalized (Executed or Defeated), its Snapshot entries are no longer rent-bumped, allowing them to naturally expire from ledger state.

Key Changes

  • TTL Lifecycle Bounding (contracts/dao-governance-contract/src/lib.rs): Updated cast_vote / proposal finalization logic so that DataKey::Snapshot(proposal_id, voter) entries are only rent-extended while proposal status is Active.
  • Double-Vote Protection Preserved: Verified that env.storage().persistent().has(&snap_key) checks remain fully functional throughout active voting windows.
  • Contract Tests: Added Soroban contract tests validating active window double-vote rejection and proper finalization behavior without std panics.

Storage Growth Analysis

  • Single Snapshot Entry Size: ~72 bytes (Proposal ID u64 + Voter Address + boolean choice + key metadata).
  • Unbounded Model (Before): For $N$ proposals with $M$ voters, cumulative persistent storage grew endlessly at $72 \times N \times M$ bytes with continuous rent-bump maintenance.
  • Bounded Lifecycle Model (After): Historical proposal snapshot storage drops to 0 bytes following TTL expiration post-finalization, saving significant rent costs for active DAOs.

Acceptance Criteria Checklist

  • Snapshot entries for finalized proposals are not indefinitely rent-bumped.
  • Storage-growth analysis provided for realistic DAO usage.
  • Double-vote-prevention behavior during active voting windows remains fully operational.

How Has This Been Tested?

@AbuJulaybeeb AbuJulaybeeb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A very good and clean work.
KIndly resolve conflicts

awwalmust and others added 3 commits August 26, 2026 00:12
…rch#134

- Add GET /api/donations endpoint with 'since' timestamp and 'projectId' query params
  to fetch donations created after a given timestamp for backfill on reconnect
- Backfill validates and enforces required query parameters, returns up to 500 donations
- Frontend hook maintains lastEventTimestampRef updated on every donation_event
- On Socket.IO connect (including reconnections), invoke backfillMissedDonations()
  to fetch missed donations and process them through onDonation callback
- Add comprehensive unit tests:
  - Test backfill on reconnect with simulated missed donations
  - Test fetch called with correct 'since' timestamp and projectId
  - Test graceful handling of backfill fetch failures
  - Test skipping backfill when no previous donations received

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@awwalmust
awwalmust force-pushed the Fix/Govenance-bound-Snapshot-TTL branch from a40da75 to 08ef833 Compare August 25, 2026 23:15
@awwalmust

Copy link
Copy Markdown
Contributor Author

The errors keep coming and coming

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.

Contracts: dao-governance-contract's per-vote Snapshot entries accumulate forever with no archival path

3 participants