Fix/issue 41 datakey enums - #56
Closed
Phantomcall wants to merge 5 commits into
Closed
Conversation
added 3 commits
July 20, 2026 14:54
…ADR-0011) Refactor all contracts using raw symbol_short! storage keys to a documented DataKey enum, add a migration generator (scripts/generate_datakey_migration.py), and add per-contract tests asserting variant-to-key uniqueness.
Author
|
check my follow up messages in issue #54 |
Author
|
Hello maintainer, i was wondering if there is any reason as to why I still have not gotten feedback on the issues i solved |
Author
|
all checks have passed now please consider the merge |
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.
Fix #41 — Namespace all storage under documented
DataKeyenums (ADR-0011)Why it matters
Raw
symbol_short!(...)storage keys such as"admin","config"and"paused"are shared across every contract that uses them. When contracts are deployed
behind a shared proxy (Issue #25) or share an instance, these short keys collide
silently and corrupt state. ADR-0011 mandates that every contract namespace its
storage under a
DataKeyenum whose variants are documented. This change closesthat gap.
What changed
Affected contracts refactored to a documented
DataKeyenumEvery contract that previously used raw
symbol_short!/Symbol::newstoragekeys now defines a
pub enum DataKey { ... }with a doc comment on each variantdescribing the stored type and whether it lives in instance or persistent
storage:
contracts/rbac—Admin,EmergencyAdmin,Paused,UserRoles(Address),RolePermissions(Symbol),RoleParent(Symbol),AuditLogs.contracts/oracle—Config,Signers,Dispute(Symbol).contracts/oracle_price_feed—Config,History(Symbol).contracts/oracle_integration—Config,Cache(Symbol),Emergency.contracts/event_ticket—Config,Event(u64),Ticket(u64),HolderTickets(Address),Attendance(u64).contracts/proof_of_activity—Config,Oracles,ProofCounter,NextProofId,Proof(u64),ActivityCount(Address, u32),ActivityScore(Address).contracts/completion_certificate—Admin,TokenCount,Paused,Cert(u64),OwnerCerts(Address),PuzzleMinted(String, Address).contracts/whitelist—Admin,Entry(Address),MerkleRoot,Snapshot,TierPermissions(u32).contracts/liquidity_pool— the existing#[repr(u32)]enum was converted toa
#[contracttype]enum (required for soroban 21.x to accept it as a keytype) and the raw
symbol_short!("balance")map key was namespaced asDataKey::Balance.Documentation-only change
contracts/conditional_rewardalready declared aDataKeyenum; variant docswere added to satisfy the "variant docs" criterion.
Migration generator (acceptance criterion)
scripts/generate_datakey_migration.pyscans the workspace, detects anycontract that still uses raw
symbol_short!/Symbol::newstorage keys, andemits a per-contract migration plan with a proposed
DataKeyenum. Contractsthat already declare a
DataKeyenum are reported compliant.scripts/datakey_migration_plan.md. After this change thegenerator reports 112 compliant, 0 affected.
Test coverage of variant-to-key mapping (acceptance criterion)
datakey_keys_test.rswas added to each refactored contract. Each testasserts that every
DataKeyvariant serializes (viaIntoVal) to a distinctstorage key, pairwise, and that none of them collides with the legacy raw
symbol_short!key it replaces. This is the direct regression guard for thecross-proxy collision described in Issue Oracle-price staleness to prevent front-running in
oracle_price_feed#25.Verification
cargo buildfor the 8 top-workspace affected crates (rbac,oracle,oracle_price_feed,oracle_integration,event_ticket,proof_of_activity,whitelist,conditional_reward) succeeds.completion_certificateandliquidity_poolare standalone crates that arenot members of the root workspace and have pre-existing, unrelated build issues
in this checkout (
liquidity_pooluses old-SDK APIs such asenv.invoker(),u128::sqrt,Error: From<{integer}>, and a 12-charsymbol_short!("pool_created")event topic that exceeds the 9-char limit). Their
DataKeyrefactors arevalidated; the remaining errors are pre-existing and outside the scope of this
issue.
cargo test --no-runcurrently fails repository-wide in this sandboxbecause the regenerated
Cargo.lockresolveded25519-dalek 3.0.0, which isincompatible with
soroban-env-host'stestutils. This affects all contracts'test builds and is unrelated to these changes.
Acceptance criteria checklist
enum DataKey { ... }with variant docs.scripts/generate_datakey_migration.py).datakey_keys_test.rs).Labels
area:architecture,kind:refactor,priority:P1,adr:0011Dependency
Depends on Issue #10.
closes #41