feat(storage): namespace storage keys across contract modules (#1055) - #1094
Open
Killerjunior wants to merge 1 commit into
Open
feat(storage): namespace storage keys across contract modules (#1055)#1094Killerjunior wants to merge 1 commit into
Killerjunior wants to merge 1 commit into
Conversation
…aOrg#1055) - Add ContractNamespace, KeyCategory, KeyOwnershipMarker, and NamespacedKey to callora-helpers - Implement NamespacedStorage with TTL management, instance/persistent/temporary durability, and cross-contract isolation - Expose pub mod ns with module-specific CONTRACT_NS and storage() helper across all 28 workspace contract crates - Add integration test suite in callora-cross-contract-tests verifying namespace isolation, lifecycle paths, and contract bindings - Ensure full unit test coverage and local CI verification passes
|
@Killerjunior 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! 🚀 |
Contributor
Author
|
Kindly review and merge @greatest0fallt1me |
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.
feat(storage): namespace storage keys across contract modulesCloses #1055
Summary
This PR implements a type-safe, production-ready storage key namespacing framework across the entire Callora workspace, resolving
[Quality-2][High] Namespace storage keys across contract modules.Prior to this change, storage keys used by individual contracts had no structural namespace, no explicit ownership semantics, inconsistent TTL/archival policies, and no protection against cross-module state collision. This PR addresses all of that systematically.
Changes
contracts/helpers— Core FrameworkContractNamespace—#[contracttype]enum covering all workspace contract modules. Each variant uniquely scopes every key written by that module.KeyCategory— Structural classification (Config,State,Accounting,Ephemeral,Idempotency,Migration) with explicit durability mapping (Instance/Persistent/Temporary) and TTL parameters per category.NamespacedKey<K>— Composite tuple key(ContractNamespace, KeyCategory, K)with manual SorobanIntoVal/TryFromValserialization that is compatible with#[contracttype]restrictions on generic types.KeyOwnershipMarker— Audit trail record capturing namespace, category, optional owner address, creation ledger sequence, and lifecycle timestamps (migration, archival).NamespacedStorage<'a>— Safe storage engine providinginstance_*,persistent_*, andtemporary_*operations with:bulk_instance_bumpfor contract liveness managementAll 28 Workspace Contract Crates
callora-helpersas a dependency in each contract'sCargo.tomlpub mod nsin each contract'ssrc/lib.rsbinding:CONTRACT_NS: ContractNamespace— the module-level namespace discriminantstorage(env: &Env) -> NamespacedStorage<'_>— zero-overhead namespace-bound accessorconfig_key,state_key,accounting_key,ephemeral_key,idempotency_key,migration_key)contracts/tests— Integration Test SuiteAdded
namespaced_storage.rstocallora-cross-contract-testswith four test cases:test_namespaced_storage_lifecycle_and_isolationtest_ownership_marker_audit_traildescribe()outputintegrated_contracts_expose_own_namespaceCONTRACT_NSintegrated_storage_accessors_bind_matching_namespacestorage(&env)return the correct namespaceTest Results
CI Checklist
cargo fmt --all -- --check— cleancargo clippy --package callora-helpers --package callora-cross-contract-tests -- -D warnings— cleanpub mod nsbindings are additive — no existing code paths touched