Skip to content

feat: migrate state variables in access control contracts with tests …#157

Open
mgtmdccix-oss wants to merge 2 commits into
OpenLedger-Foundation:mainfrom
mgtmdccix-oss:feature/issue-migrate-state-variables-in-access-control-contracts
Open

feat: migrate state variables in access control contracts with tests …#157
mgtmdccix-oss wants to merge 2 commits into
OpenLedger-Foundation:mainfrom
mgtmdccix-oss:feature/issue-migrate-state-variables-in-access-control-contracts

Conversation

@mgtmdccix-oss
Copy link
Copy Markdown

@mgtmdccix-oss mgtmdccix-oss commented Jun 1, 2026

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

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Jun 1, 2026

@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! 🚀

Learn more about application limits

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.

Migrate State Variables in Access Control Contracts

2 participants