Feat/contract upgradeability#312
Merged
manoahLinks merged 3 commits intoApr 28, 2026
Merged
Conversation
The workspace on `origin/main` does not currently compile: a botched merge replaced `event_manager/src/lib.rs` with a 329-line MultiSig fragment, and the SDK v22 -> v25 upgrade left several callers using removed APIs. - Restore event_manager/src/lib.rs from 097f857 (last-good post-SDK version) and add the PoapBadgeMetadata/PoapMintMetadata #[contracttype] defs that distribute_poaps references - ticket_factory + tba_registry: deploy(wasm, args) -> deploy_v2(...) - ticket_nft: clone Address before storage move so the subsequent events.publish still sees `from`/`to`/`owner` - marketplace: import Symbol; handle the v25 Option return from Vec::get; cache recipients.len() before the move into RoyaltyConfig - dao_governance: drop env.invoker() in favor of admin require_auth(); cast usize -> u32 for Vec::remove; cast i128 -> u128 for the voting-power return type; stub total_supply() (removed in v25) returning 0 with a TODO After this commit `cargo check --workspace` is green; storage optimization for crowdpass-live#203 follows in a separate commit.
Adds a robust upgrade mechanism to all CrowdPass Soroban contracts, enabling future improvements and bug fixes without changing contract addresses. - Add upgrade() function gated behind admin require_auth() - Implement migrate() hook for state schema transformations - Store contract version in instance storage for upgrade tracking - Add version() view function for on-chain version querying - Include upgrade event emission for transparency and auditability - Comprehensive tests covering upgrade flow and unauthorized access Closes crowdpass-live#205
|
@Sage-senpai 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.
feat/contract-upgradeability
Description
Adds a secure, auditable upgrade mechanism to all CrowdPass Soroban contracts, enabling future improvements and bug fixes to land without changing contract addresses or breaking existing storage.
This PR ships two upgrade paths side-by-side:
Fast-path upgrade(new_wasm_hash) — admin-gated, single call, no timelock. Useful for emergency response (live exploit / critical hotfix).
Existing timelocked schedule_upgrade → wait 24h → commit_upgrade — already in the upgradeable lib, untouched and recommended for routine upgrades.
Plus a migrate(target_version) hook for state-shape transformations between versions, with a strict downgrade guard.
The branch carries two commits:
fix(contracts): restore event_manager and resolve SDK v25 build errors — same prerequisite cherry-picked from the #203 branch. The workspace on origin/main doesn't compile because of a botched merge in event_manager plus left-over SDK v22 → v25 migration debt. Without this, no #205 work can be tested.
feat(contracts): implement secure contract upgradeability pattern — the actual #205 work.
If you'd prefer one commit on the merge, squash. If the build-fix lands first via a separate PR (e.g. via the #203 branch), this branch will rebase cleanly onto it.
Type of Change
Bug fix (behavioral)
New feature
Build fix (prerequisite — upstream main was broken before this PR)
Breaking change
Related Issues
What's added
upgradeable lib (contracts/upgradeable/src/lib.rs)
pub fn upgrade(env, new_wasm_hash) — fast-path WASM swap. require_admin() → bump_version() → env.deployer().update_current_contract_wasm(...) → emit UpgradedEvent.
pub fn require_version_increase(env, target_version) — guard that panics with "downgrade not allowed" if target_version <= current_version. Used by every migrate entry point.
pub fn migration_completed(env, target_version) — sets stored version to target_version and emits MigratedEvent. Does not call require_auth() itself — Soroban auth frames forbid double-auth in one call, so the surrounding migrate() does the auth check once.
pub struct MigratedEvent { contract_address, from_version, to_version } — new #[contracttype] event payload for off-chain indexers.
SECURITY NOTE block above upgrade() explicitly flagging the timelock-skip risk so anyone reading the lib understands the trade-off.
Closes #205