mirror of
https://github.com/datahaven-xyz/datahaven
synced 2026-05-24 01:38:32 +00:00
## Summary Replaced the `DefaultFailedMigrationHandler` (which completely froze the chain on migration failures) with `EnterSafeModeOnFailedMigration` across all three runtimes (mainnet, stagenet, testnet). When a migration fails, the chain now automatically enters SafeMode instead of freezing, allowing governance to intervene and fix issues while preventing regular user transactions. ## Problem Previously, when a runtime migration failed, the chain would use `FreezeChainOnFailedMigration`, which completely halted all operations including governance functions. This made it impossible to recover from migration failures without manual intervention at the node level. ## Solution Implemented `EnterSafeModeOnFailedMigration` which: - **Enters SafeMode** when a migration fails: the chain remains _indefinitely_ under safe mode until it is disabled, either with Sudo or Governance. - **Allows governance operations** to continue (Sudo, SafeMode, TxPause, Preimage, Scheduler, etc.) - **Blocks regular user transactions** to prevent interaction with potentially inconsistent storage - **Falls back to freezing** if SafeMode cannot be entered ## Changes ### Core Implementation - **`runtime/common/src/migrations.rs`**: Added `FailedMigrationHandler<SafeMode>` type alias that wraps `EnterSafeModeOnFailedMigration` with comprehensive documentation - **All three runtimes** (`mainnet`, `stagenet`, `testnet`): - Updated `pallet_migrations::Config::FailedMigrationHandler` to use `FailedMigrationHandler<SafeMode>` - Removed obsolete TODO comments ### Tests Added comprehensive migration failure tests to all three runtimes: - **`failed_migration_enters_safe_mode`**: Verifies SafeMode is activated, expiry is set, and event is emitted - **`safe_mode_allows_governance_during_migration_failure`**: Confirms governance can exit SafeMode after migration failure - **`migrations_force_calls_are_root_only`**: Existing test for migration management permissions Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Ahmad Kaouk <56095276+ahmadkaouk@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| governance | ||
| common.rs | ||
| fee_adjustment.rs | ||
| lib.rs | ||
| migrations.rs | ||
| native_token_transfer.rs | ||
| proxy.rs | ||
| safe_mode_tx_pause.rs | ||
| treasury.rs | ||