Skip to content

Feature/382 contract migration tools#433

Merged
Xhristin3 merged 5 commits intorinafcode:mainfrom
Oluwasuyi-Timilehin:feature/382-contract-migration-tools
Apr 28, 2026
Merged

Feature/382 contract migration tools#433
Xhristin3 merged 5 commits intorinafcode:mainfrom
Oluwasuyi-Timilehin:feature/382-contract-migration-tools

Conversation

@Oluwasuyi-Timilehin
Copy link
Copy Markdown
Contributor

#closes #382

📋 Description

This pull request improves the TeachLink contract migration workflow by hardening upgrade initialization, adding migration metadata validation, and improving rollback test coverage.

Contract: contracts/teachlink/src/upgrade.rs now enforces valid state and migration hashes, auto-initializes upgrade state when absent, and includes stronger rollback expiry behavior. contracts/teachlink/src/lib.rs now initializes the upgrade subsystem during bridge contract initialization.

🎯 Type of Change

  • ✅ Bug fix / stability improvement
  • ✨ New feature
  • ⚡ Performance improvement
  • 🧪 Test coverage

📝 Changes Made

  • Added upgrade::ContractUpgrader::initialize(&env)? to TeachLinkBridge::initialize(...) in contracts/teachlink/src/lib.rs.
  • Updated contracts/teachlink/src/upgrade.rs:
    • prepare_upgrade and execute_upgrade now auto-initialize upgrade storage if UPGRADE_VERSION is missing.
    • prepare_upgrade rejects an empty state_hash.
    • execute_upgrade rejects an empty migration_hash.
  • Added a dedicated regression test test_prepare_upgrade_auto_initializes.
  • Extended test_rollback_window_expiry to move the ledger past the rollback window, confirm rollback is rejected, and verify rollback availability is cleared.

🔗 Related Issue(s)

  • No issue number provided

🧪 Testing

Recommended commands

cd c:\Users\HomePC\Documents\D\teachLink_contract
cargo build --release --target wasm32-unknown-unknown -p teachlink-contract
cargo test -p teachlink-contract
cargo fmt --all -- --check
cargo clippy --all-targets --all-features

Notes

  • cargo was unavailable in the editor terminal environment used for file edits, so please run the commands locally to verify the build and test pass.

🔍 Review Checklist

  • Code follows repository style guidelines
  • Added or improved tests for upgrade lifecycle behavior
  • No new compiler diagnostics in modified files
  • No secrets or sensitive data committed

💥 Breaking Changes

  • This PR introduces breaking changes
  • N/A: additive validation and initialization fixes only.

🚀 Deployment Notes

  • Requires contract redeployment
  • Requires data migration
  • No deployment changes required beyond normal contract rebuild and redeploy

Ready for Review: yes

#closes

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 25, 2026

@Oluwasuyi-Timilehin 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! 🚀

Learn more about application limits

…ting scripts

- Implemented progress tracking script (progress.sh) for monitoring migration status, generating reports, and cleaning up artifacts.
- Created rollback script (rollback.sh) for automated and manual rollback functionalities, including validation checks and emergency procedures.
- Developed validation script (validate.sh) for comprehensive pre and post-migration checks, ensuring contract connectivity, versioning, and network health.
- Introduced test suite (test_tools.sh) to validate the functionality and structure of migration tools, including syntax checks and configuration validation.
@Xhristin3
Copy link
Copy Markdown
Contributor

@Oluwasuyi-Timilehin resolve conflicts.

@Xhristin3 Xhristin3 merged commit 49da4ce into rinafcode:main Apr 28, 2026
2 checks 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.

Implement comprehensive migration tools

2 participants