📌 Description
storage.rs's module doc comment states "All persistent entries use the persistent storage with a TTL that is extended on every read/write," but get_balance in src/storage.rs only performs a plain .get() with no extend(env, &key) call — only set_balance extends. A provider whose balance is read-only for a long stretch (no provide_liquidity/withdraw_liquidity calls) could have their Balance(provider, asset) entry approach TTL expiry purely because balance()/anchor_balances() reads do not bump it, contradicting the documented policy.
🧩 Requirements and context
- Add an
extend(env, &key) call to get_balance in src/storage.rs, mirroring get_pool's read-side extend pattern.
- Confirm
anchor_balances, which calls get_balance in a loop, benefits automatically once the fix lands.
- Add a regression test simulating a long read-only gap and asserting the entry's TTL was bumped by a
balance() call.
🛠️ Suggested execution
- Update
get_balance in src/storage.rs to extend the entry's TTL on every successful read, not just on set_balance.
- Add a
src/test.rs case using the test harness's TTL/ledger-inspection utilities to assert the bump occurred after a read-only balance() call.
- Cross-check
get_min_liquidity, get_max_settlement_amount, get_asset_fee, is_fee_waived, and get_fees_accrued for the same gap (tracked in separate issues).
✅ Acceptance criteria
🔒 Security notes
A balance entry archived due to TTL expiry despite active read traffic is a silent data-availability risk on a fund-accounting field; fixing the read path closes the gap between the documented TTL policy and the actual implementation.
📋 Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
📌 Description
storage.rs's module doc comment states "All persistent entries use thepersistentstorage with a TTL that is extended on every read/write," butget_balanceinsrc/storage.rsonly performs a plain.get()with noextend(env, &key)call — onlyset_balanceextends. A provider whose balance is read-only for a long stretch (noprovide_liquidity/withdraw_liquiditycalls) could have theirBalance(provider, asset)entry approach TTL expiry purely becausebalance()/anchor_balances()reads do not bump it, contradicting the documented policy.🧩 Requirements and context
extend(env, &key)call toget_balanceinsrc/storage.rs, mirroringget_pool's read-side extend pattern.anchor_balances, which callsget_balancein a loop, benefits automatically once the fix lands.balance()call.🛠️ Suggested execution
get_balanceinsrc/storage.rsto extend the entry's TTL on every successful read, not just onset_balance.src/test.rscase using the test harness's TTL/ledger-inspection utilities to assert the bump occurred after a read-onlybalance()call.get_min_liquidity,get_max_settlement_amount,get_asset_fee,is_fee_waived, andget_fees_accruedfor the same gap (tracked in separate issues).✅ Acceptance criteria
get_balanceextends theBalance(provider, asset)entry's TTL on every read, matching the documented policy.balance()/anchor_balances()call, not just by writes.🔒 Security notes
A balance entry archived due to TTL expiry despite active read traffic is a silent data-availability risk on a fund-accounting field; fixing the read path closes the gap between the documented TTL policy and the actual implementation.
📋 Guidelines