Skip to content

Feat/issue 29 upgrade governance#32

Merged
MaryammAli merged 3 commits into
Proof-Stell:mainfrom
Cybermaxi7:feat/issue-29-upgrade-governance
Jun 21, 2026
Merged

Feat/issue 29 upgrade governance#32
MaryammAli merged 3 commits into
Proof-Stell:mainfrom
Cybermaxi7:feat/issue-29-upgrade-governance

Conversation

@Cybermaxi7

Copy link
Copy Markdown
Contributor

Description
Adds contract upgrade mechanism, on-chain versioning, data migration path, and feature flag governance to the ProofStell Soroban contract. The admin address (set once at initialize) controls all governance operations. Indexers can detect contract version transitions via ContractInitialized and ContractUpgraded events, and existing document records remain fully accessible after migration.

Type of Change
Bug fix (non-breaking change that fixes an issue)
New feature (non-breaking change that adds functionality)
Breaking change (fix or feature that would cause existing functionality to not work as expected)
Refactor (code change that neither fixes a bug nor adds a feature)
Documentation update
Related Issues
Closes #29

Changes Made
Add DataKey::Admin, DataKey::Version, DataKey::FeatureFlag(Symbol) to persistent storage
Add CONTRACT_VERSION constant (currently 1)
Add ContractInitialized and ContractUpgraded contract events for indexer version tracking
Add AlreadyInitialized (9), NotInitialized (10), Unauthorized (11), MigrationNotNeeded (12) error codes
Implement initialize(admin) — sets admin + version on first deployment; fails if called again
Implement upgrade(admin, new_wasm_hash) — admin-gated WASM replacement via env.deployer().update_current_contract_wasm
Implement migrate(admin) — detects pre-versioned state (v0) and bootstraps to v1; returns MigrationNotNeeded if already current; extensible for future version transitions
Implement get_version() and get_admin() — read-only accessors
Implement set_feature_flag / get_feature_flag — admin-gated named feature toggles stored per Symbol
Add upgrade runbook to README (build → install → upgrade → migrate → rollback plan)
Add docs/UPGRADE_GOVERNANCE.md with change classification, governance roles, standard and emergency upgrade processes, and storage migration rules
Testing
cargo test passes locally
cargo build --target wasm32-unknown-unknown --release succeeds
New tests added for new functionality (if applicable)
13 new tests: initialize_sets_admin_and_version, double_initialize_fails, get_version_returns_zero_before_init, get_admin_returns_none_before_init, upgrade_requires_initialization, non_admin_cannot_upgrade, migrate_v0_to_v1_sets_versioning, migrate_already_current_fails, documents_still_work_after_migration, get_feature_flag_returns_false_for_unset, admin_can_set_and_get_feature_flag, non_admin_cannot_set_feature_flag, set_feature_flag_requires_initialization. All 87 tests pass.

Checklist
My code follows the project's coding conventions
I have performed a self-review of my code
I have commented my code where necessary
No unused imports or dead code remains
CI checks pass (build + test + wasm)

…roof-Stell#30)

- Add DocumentInfo contracttype for batch registration input
- Add BatchTooLarge (code 7) and BatchEmpty (code 8) error variants
- Implement batch_register_documents with 20-doc limit, fail-fast atomicity
- Implement batch_revoke_documents with 20-doc limit, fail-fast atomicity
- Emit per-document events for each item in successful batch
- Fix pre-existing format! macro visibility under #![no_std] with #[macro_use]
- Add 10 new tests covering success, partial failure, empty, and oversized batches
- Document batch operations and limits in README
…overnance (closes Proof-Stell#29)

- Add DataKey::Admin, Version, FeatureFlag(Symbol) to persistent storage
- Add CONTRACT_VERSION constant (currently 1)
- Add ContractInitialized and ContractUpgraded contract events
- Add AlreadyInitialized (9), NotInitialized (10), Unauthorized (11), MigrationNotNeeded (12) error codes
- Implement initialize, get_version, get_admin, upgrade, migrate, set_feature_flag, get_feature_flag
- migrate handles v0 (pre-versioned) state to bootstrap versioning on existing deployments
- Add 13 new tests covering init, double-init, version checks, admin gating, migration, feature flags, and post-migration document compatibility
- Add upgrade runbook to README with step-by-step deploy, upgrade, and rollback procedures
- Add docs/UPGRADE_GOVERNANCE.md with change classification, governance roles, and emergency upgrade process

@MaryammAli MaryammAli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@MaryammAli MaryammAli merged commit e0fc42a into Proof-Stell:main Jun 21, 2026
1 check passed
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.

Add contract upgrade and migration path governance

2 participants