Skip to content

refactor(soroban): track attesters with a single instance-storage Vec - #67

Merged
alex-predicate merged 1 commit into
mainfrom
alex-predicate/soroban-contract-fixes
Jul 23, 2026
Merged

refactor(soroban): track attesters with a single instance-storage Vec#67
alex-predicate merged 1 commit into
mainfrom
alex-predicate/soroban-contract-fixes

Conversation

@alex-predicate

Copy link
Copy Markdown
Contributor

Summary

Cleans up the attester storage in predicate-registry per review feedback: the registry will realistically never hold more than ~2 attesters (usually 1), so three storage constructs to track them is overkill.

Collapses the attester tracking from three storage constructs down to one:

Before After
attsVec<BytesN<32>> in instance storage attsVec<BytesN<32>> in instance storage
att_reg — per-attester bool flag (persistent) removed
att_idx — per-attester u32 index (persistent) removed
extend_to_max / per-attester TTL refresh removed

Since the set is tiny, membership and removal scan the Vec linearly:

  • is_registeredVec::contains
  • deregisterVec::first_index_of + the same swap-and-pop as before

TTL note

The old refresh_ttl(attester) existed only to keep the per-attester persistent entries alive. Since the attester set now lives entirely in instance storage, refresh_ttl(e) is repurposed to extend the contract instance TTL to max on each successful validation — preserving the original "actively-used registry is never archived" guarantee at the instance level. The one caller in validation.rs is updated accordingly.

Verification

  • stellar contract build --package predicate-registry ✅ (all 14 exported functions intact)
  • cargo test --package predicate-registry22 passed ✅ (existing tests unchanged, incl. swap-and-pop, duplicate, and unregistered error cases)
  • cargo clippy → clean (one pre-existing lifetime-elision warning in the test setup helper, unrelated)

Net: 38 insertions, 104 deletions.

🤖 Generated with Claude Code

The attester set was tracked with three storage constructs: the `atts`
Vec in instance storage, a per-attester `att_reg` bool flag, and a
per-attester `att_idx` u32 index (plus TTL bookkeeping to keep the
persistent flag/index entries from being archived).

Given the registry holds a tiny set (typically one attester, at most a
handful), collapse this to just the instance-storage Vec:

- is_registered -> Vec::contains
- deregister    -> Vec::first_index_of + the same swap-and-pop
- drop the per-attester persistent flag/index entries entirely

refresh_ttl now extends the contract instance TTL (where the attester
set lives) on each successful validation, preserving the "actively-used
registry is never archived" guarantee.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@alex-predicate
alex-predicate merged commit 6130aa4 into main Jul 23, 2026
4 checks passed
@alex-predicate
alex-predicate deleted the alex-predicate/soroban-contract-fixes branch July 23, 2026 18:50
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.

2 participants