Skip to content

Comments

[Optimization] Conditional storage TTL bump – fixes #16#21

Merged
JerryIdoko merged 2 commits intoGrant-Stream:mainfrom
onahiOMOTI:contract_update
Feb 20, 2026
Merged

[Optimization] Conditional storage TTL bump – fixes #16#21
JerryIdoko merged 2 commits intoGrant-Stream:mainfrom
onahiOMOTI:contract_update

Conversation

@onahiOMOTI
Copy link
Contributor

Closes #16

Changes

  • Added ensure_sufficient_ttl() helper
  • Uses extend_ttl(1000, max_ttl) so the bump only happens when remaining lifetime < 1000 ledgers
  • Automatically keeps both instance storage and contract WASM code alive
  • Called on every public endpoint (create_grant, withdraw, set_pause)

This eliminates unnecessary gas on 99% of interactions while guaranteeing the contract never expires.

Follows current Stellar best practices (see: https://developers.stellar.org/docs/build/guides/archival/test-ttl-extension and extending-wasm-ttl guide).

Testing

  • Deploy & call functions normally → gas should be lower on repeated calls
  • Advance ledger in tests until TTL < 1000 → confirm extension happens

@onahiOMOTI
Copy link
Contributor Author

Closes #17

Changes

  • Added dispute_active: bool to Grant struct
  • Stored global arbiter Address in instance storage (set via new set_arbiter fn)
  • New set_dispute_state(grant_id, active): callable only by arbiter
  • withdraw now blocked if dispute_active == true
  • Future-proof for "Court" system (block other mutating actions later)

Acceptance Criteria

  • Store arbiter address
  • If dispute_active, block withdraw (recover can be added later)

Low priority / governance label — minimal change, no breaking behavior.

Test plan:

  • Deploy, set arbiter
  • Create grant
  • Try withdraw normally → ok
  • Arbiter calls set_dispute_state(true) → withdraw panics
  • set_dispute_state(false) → withdraw works again

Ready for review!

@JerryIdoko JerryIdoko merged commit d13891b into Grant-Stream:main Feb 20, 2026
1 check failed
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.

#16 Issue 16: [Optimization] Optimize Storage Bumps

2 participants