Expand description
One-shot migration that populates decimal snapshots for a pre-existing PSM deployment.
Purpose: chains that approved external assets before the multi-decimal upgrade
have entries in ExternalAssets but no ExternalDecimals snapshots, and no
InternalDecimals either. Mint and redeem both require these snapshots and
will fail closed (Error::DecimalsMismatch / Error::Unexpected) until they
are populated. This migration reads live metadata and writes the snapshots.
Out-of-range assets are handled gracefully: if an existing asset’s decimals
differ from the internal asset’s decimals by more than MAX_DECIMALS_DIFF,
the migration still writes its decimals snapshot but flips its circuit
breaker to CircuitBreakerLevel::AllDisabled. The chain keeps upgrading;
governance can remove or re-enable the asset later once the off-chain
situation is resolved. The try-runtime post-upgrade hook verifies this
invariant — any out-of-range asset must end up disabled.
Safe to run multiple times — already-populated snapshots are not overwritten.
§Usage
pub type Migrations = (
pallet_psm::migrations::decimals::PopulateDecimals<Runtime>,
// ... other migrations
);Structs§
- Inner
Populate Decimals - Version-unchecked migration logic. Exposed only for use by
PopulateDecimals.
Type Aliases§
- Populate
Decimals - Version-gated v1 -> v2 migration that fills in decimal snapshots for all pre-existing external assets and the internal asset, and bumps the pallet on-chain storage version from 1 to 2.