This guide documents the safe upgrade process for the Scavenger smart contract, including data migration, backward compatibility, and rollback procedures.
- Backup current contract state
- Create production data snapshot
- Review all changes in new version
- Run full test suite
- Verify upgrade tests pass
- Notify stakeholders
# 1. Build new contract version
cargo build --target wasm32-unknown-unknown --release
# 2. Optimize WASM
soroban contract optimize \
--wasm target/wasm32-unknown-unknown/release/stellar_scavngr_contract.wasm
# 3. Deploy to testnet first
soroban contract deploy \
--wasm target/wasm32-unknown-unknown/release/stellar_scavngr_contract.optimized.wasm \
--source testnet-deployer \
--network testnet
# 4. Run upgrade tests
cargo test --test contract_upgrade_test
# 5. Deploy to mainnet
soroban contract deploy \
--wasm target/wasm32-unknown-unknown/release/stellar_scavngr_contract.optimized.wasm \
--source mainnet-deployer \
--network mainnet- All participant records are preserved
- Role information is maintained
- Registration timestamps are kept
- Stats are recalculated if needed
- All waste records are preserved
- Transfer history is maintained
- Metadata is kept intact
- Deactivation status is preserved
- Active incentives are preserved
- Budget information is maintained
- Reward points are kept
- Deactivation status is preserved
The contract maintains backward compatibility with:
- Old API function signatures
- Existing data structures
- Previous storage layouts
- Legacy query functions
If issues occur after upgrade:
# 1. Identify the issue
# Check logs and error reports
# 2. Revert to previous contract
soroban contract deploy \
--wasm previous_version.wasm \
--source mainnet-deployer \
--network mainnet
# 3. Restore from backup if needed
# Use backup data to restore state
# 4. Verify state integrity
cargo test --test contract_upgrade_test
# 5. Notify stakeholders
# Communicate status and next steps- Initial release
- Participant management
- Waste tracking
- Incentive system
- Token rewards
- Enhanced query functions
- Improved storage efficiency
- Additional security checks
- Performance optimizations
Run upgrade-specific tests:
cargo test --test contract_upgrade_testTests cover:
- State preservation
- Data migration
- Backward compatibility
- Rollback procedures
- Storage compatibility
- Production data snapshots
Run full integration suite:
cargo testAfter upgrade, monitor:
- Contract Calls: Track function invocations
- Error Rates: Monitor for new errors
- Performance: Check gas usage and latency
- Data Integrity: Verify data consistency
- User Reports: Monitor for issues
Solution:
- Verify backup was created
- Check storage migration logic
- Restore from backup if needed
Solution:
- Verify backward compatibility layer
- Check function signatures
- Update client code if needed
Solution:
- Profile contract execution
- Optimize hot paths
- Consider storage restructuring
For upgrade issues:
- Check this guide
- Review test results
- Contact development team
- Escalate if critical