feat: migrate state variables in access control contracts with tests …#157
Open
mgtmdccix-oss wants to merge 2 commits into
Conversation
|
@mgtmdccix-oss Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Closes #99
Summary
Migrates state variables in contracts/access_control to improve robustness, security, and performance of the Kora Protocol.
Changes
Storage key migration
Split the single DataKey enum into two purpose-specific enums:
InstanceKey (Admin, Paused) — instance storage for contract-level config tied to the instance lifetime
PersistentKey (Role(Address)) — persistent storage for per-address role data with independently managed TTLs
This makes the storage layout explicit and prevents accidental misuse of storage tiers.
Instance storage TTL management
Added bump_instance() calling env.storage().instance().extend_ttl(...) on every state-mutating function. Previously, instance storage TTL was never extended, risking expiry of the Admin and Paused keys on a live network.
read_paused() helper
Extracted the repeated paused-flag read into a single private method used by pause, unpause, and is_paused.
Duplicate test block removed and extended
The old file had two mod tests blocks. Consolidated into one comprehensive suite and added 4 new tests that specifically validate the storage key migration:
test_instance_key_admin_and_paused_are_independent
test_persistent_key_role_entries_are_independent
test_no_role_none_tombstone_after_revoke
test_transfer_admin_removes_old_role_entry
Checklist
Compatible with existing Soroban infrastructure
Safe arithmetic (no silent overflows; no arithmetic in this contract)
Scoped to contracts/access_control only — no cross-contract changes
Input validation unchanged and robust
Comprehensive tests covering all edge cases