[WIP] Add upgrade entrypoint to farming-pool for WASM hot-swap#51
Open
gaiabio12-design wants to merge 1 commit into
Open
[WIP] Add upgrade entrypoint to farming-pool for WASM hot-swap#51gaiabio12-design wants to merge 1 commit into
gaiabio12-design wants to merge 1 commit into
Conversation
7 tasks
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.
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:
Add the
upgradefunction tocontracts/soroban/farming-pool/src/lib.rswith admin-only guard using the existing auth pattern, emit anupgradedevent with the new hash, and wire in theSCHEMA_VERSIONconstant for versioning.Mirror this on Factory with
upgrade_poolthat's factory-admin-only and enforces the same error handling (PoolError::Unauthorizedfor non-admins).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.
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
upgradefunction that replaces the contract WASM in place: