Skip to content

[WIP] Add upgrade entrypoint to farming-pool for WASM hot-swap#51

Open
gaiabio12-design wants to merge 1 commit into
SmartDropLabs:mainfrom
gaiabio12-design:grantfox-issue-23
Open

[WIP] Add upgrade entrypoint to farming-pool for WASM hot-swap#51
gaiabio12-design wants to merge 1 commit into
SmartDropLabs:mainfrom
gaiabio12-design:grantfox-issue-23

Conversation

@gaiabio12-design

Copy link
Copy Markdown

Closes #23

Proposed Approach

I've been looking at this issue — the lack of in-place WASM upgrade on FarmingPool is a real gap since Soroban's env.deployer().update_current_contract_wasm() makes this totally doable without losing staker state.

Here's how I'd approach it:

  1. Add the upgrade function to contracts/soroban/farming-pool/src/lib.rs with admin-only guard using the existing auth pattern, emit an upgraded event with the new hash, and wire in the SCHEMA_VERSION constant for versioning.

  2. Mirror this on Factory with upgrade_pool that's factory-admin-only and enforces the same error handling (PoolError::Unauthorized for non-admins).

  3. Write two integration tests in the test suite — one verifying that after upgrade, all Position and Stake storage is preserved and balances match, another confirming the new contract functions are callable post-upgrade.

  4. Make sure the upgrade path doesn't touch the existing position/stake structs; I'll keep the storage layout stable so migrations aren't needed.

The repo's got 58 files in soroban/ so there's precedent for these patterns. Can have a PR ready tomorrow.

Acceptance Criteria

Overview

Soroban contracts can upgrade their own WASM at runtime via env.deployer().update_current_contract_wasm(new_hash). The farming-pool contract has no such entrypoint, making bug fixes require deploying an entirely new pool — all staker positions, credits, and lock states are lost.

Design

Add an admin-only upgrade function that replaces the contract WASM in place:

/// Admin: replace this contract's WASM with the implementation at `new_wasm_hash`.
///
/// Storage (positions, stakes, credits) is preserved across upgrades.
/// The new WASM must be installed on-chain be

---
_Implementation in progress — will remove `[WIP]` once code is ready._

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 upgrade entrypoint to farming-pool for WASM hot-swap

1 participant