refactor(soroban): track attesters with a single instance-storage Vec - #67
Merged
Merged
Conversation
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>
penDerGraft
approved these changes
Jul 23, 2026
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.
Summary
Cleans up the attester storage in
predicate-registryper 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:
atts—Vec<BytesN<32>>in instance storageatts—Vec<BytesN<32>>in instance storageatt_reg— per-attesterboolflag (persistent)att_idx— per-attesteru32index (persistent)extend_to_max/ per-attester TTL refreshSince the set is tiny, membership and removal scan the Vec linearly:
is_registered→Vec::containsderegister→Vec::first_index_of+ the same swap-and-pop as beforeTTL 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 invalidation.rsis updated accordingly.Verification
stellar contract build --package predicate-registry✅ (all 14 exported functions intact)cargo test --package predicate-registry→ 22 passed ✅ (existing tests unchanged, incl. swap-and-pop, duplicate, and unregistered error cases)cargo clippy→ clean (one pre-existing lifetime-elision warning in the testsetuphelper, unrelated)Net: 38 insertions, 104 deletions.
🤖 Generated with Claude Code