frequency-chain / frequency

Frequency: A Polkadot Parachain
https://www.frequency.xyz
Apache License 2.0
49 stars 18 forks source link

bugfix: schema name migration #2012

Closed aramikm closed 3 months ago

aramikm commented 4 months ago

Goal

The goal of this PR is to make to fix the schema names on main-net that incorrectly got updated with test-net values.

Closes #2006

Changes

Checklist

Verification on Mainnet

[2024-06-05T23:49:26Z INFO  frequency_runtime] try-runtime::on_runtime_upgrade frequency.
[2024-06-05T23:49:26Z INFO  runtime::schemas] Running pre_upgrade...
[2024-06-05T23:49:26Z INFO  runtime::schemas] Found genesis... 0x4a587bf17a404e3572747add7aab7bbe56e805a5479c6c436f07f36fcc8d3ae1
[2024-06-05T23:49:26Z INFO  runtime::schemas] Detected Chain is FrequencyMain
[2024-06-05T23:49:26Z INFO  runtime::schemas] Running storage migration...
[2024-06-05T23:49:26Z INFO  runtime::schemas] onchain_version= StorageVersion(3), current_version=StorageVersion(4)
[2024-06-05T23:49:26Z INFO  runtime::schemas] Storage migrated to version 4  read=13, write=13, bytes=9544
[2024-06-05T23:49:26Z INFO  runtime::schemas] Migration Calculated weights=Weight { ref_time: 1625000000, proof_size: 9544 }
[2024-06-05T23:49:26Z INFO  runtime::schemas] Running post_upgrade...
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for System
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for ParachainSystem
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Timestamp
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for ParachainInfo
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Preimage
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Democracy
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Scheduler
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Utility
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Balances
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for TransactionPayment
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Council
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for TechnicalCommittee
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Treasury
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Authorship
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for CollatorSelection
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Session
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Aura
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for AuraExt
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Multisig
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for TimeRelease
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Proxy
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Msa
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Messages
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Schemas
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for StatefulStorage
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Capacity
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for FrequencyTxPayment
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Handles
[2024-06-05T23:49:26Z DEBUG wasm-heap] allocator dropped: AllocationStats { bytes_allocated: 56, bytes_allocated_peak: 792, bytes_allocated_sum: 19240, address_space_used: 1048 }
[2024-06-05T23:49:26Z DEBUG wasm-runtime] Allocated WASM instance 1/2
[2024-06-05T23:49:26Z INFO  try_runtime_core::commands::on_runtime_upgrade] -------------------------------------------------------------------

[2024-06-05T23:49:26Z INFO  try_runtime_core::commands::on_runtime_upgrade] 🔬 TryRuntime_on_runtime_upgrade succeeded! Running it again without checks for weight measurements.

[2024-06-05T23:49:26Z INFO  try_runtime_core::commands::on_runtime_upgrade] -------------------------------------------------------------------
[2024-06-05T23:49:26Z INFO  frequency_runtime] try-runtime::on_runtime_upgrade frequency.
[2024-06-05T23:49:26Z INFO  runtime::schemas] Running storage migration...
[2024-06-05T23:49:26Z INFO  runtime::schemas] onchain_version= StorageVersion(3), current_version=StorageVersion(4)
[2024-06-05T23:49:26Z INFO  runtime::schemas] Storage migrated to version 4  read=13, write=13, bytes=9544
[2024-06-05T23:49:26Z INFO  runtime::schemas] Migration Calculated weights=Weight { ref_time: 1625000000, proof_size: 9544 }
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for System
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for ParachainSystem
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Timestamp
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for ParachainInfo
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Preimage
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Democracy
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Scheduler
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Utility
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Balances
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for TransactionPayment
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Council
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for TechnicalCommittee
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Treasury
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Authorship
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for CollatorSelection
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Session
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Aura
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for AuraExt
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Multisig
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for TimeRelease
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Proxy
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Msa
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Messages
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Schemas
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for StatefulStorage
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Capacity
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for FrequencyTxPayment
[2024-06-05T23:49:26Z DEBUG runtime::frame-support] ✅ no migration for Handles
[2024-06-05T23:49:26Z DEBUG wasm-heap] allocator dropped: AllocationStats { bytes_allocated: 56, bytes_allocated_peak: 792, bytes_allocated_sum: 11664, address_space_used: 1048 }
[2024-06-05T23:49:26Z INFO  try_runtime_core::commands::on_runtime_upgrade] -------------------------------------------------------------------

[2024-06-05T23:49:26Z INFO  try_runtime_core::commands::on_runtime_upgrade] 🔬 Running TryRuntime_on_runtime_upgrade again to check idempotency: PreAndPost

[2024-06-05T23:49:26Z INFO  try_runtime_core::commands::on_runtime_upgrade] -------------------------------------------------------------------
[2024-06-05T23:49:26Z INFO  frequency_runtime] try-runtime::on_runtime_upgrade frequency.
[2024-06-05T23:49:26Z INFO  runtime::schemas] Running pre_upgrade...
[2024-06-05T23:49:26Z INFO  runtime::schemas] Running storage migration...
[2024-06-05T23:49:26Z INFO  runtime::schemas] onchain_version= StorageVersion(4), current_version=StorageVersion(4)
[2024-06-05T23:49:26Z INFO  runtime::schemas] Migration did not execute. This probably should be removed onchain:StorageVersion(4), current:StorageVersion(4)
[2024-06-05T23:49:26Z INFO  runtime::schemas] Running post_upgrade...

Verification on Paseo

[2024-06-05T23:56:01Z INFO  frequency_runtime] try-runtime::on_runtime_upgrade frequency.
[2024-06-05T23:56:01Z INFO  runtime::schemas] Running pre_upgrade...
[2024-06-05T23:56:01Z INFO  runtime::schemas] Found genesis... 0x203c6838fc78ea3660a2f298a58d859519c72a5efdc0f194abd6f0d5ce1838e0
[2024-06-05T23:56:01Z INFO  runtime::schemas] Detected Chain is FrequencyPaseo
[2024-06-05T23:56:01Z INFO  runtime::schemas] Running storage migration...
[2024-06-05T23:56:01Z INFO  runtime::schemas] onchain_version= StorageVersion(3), current_version=StorageVersion(4)
[2024-06-05T23:56:01Z INFO  runtime::schemas] Storage migrated to version 4  read=1, write=1, bytes=0
[2024-06-05T23:56:01Z INFO  runtime::schemas] Migration Calculated weights=Weight { ref_time: 125000000, proof_size: 0 }
[2024-06-05T23:56:01Z INFO  runtime::schemas] Running post_upgrade...
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for System
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for ParachainSystem
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Timestamp
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for ParachainInfo
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Sudo
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Preimage
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Democracy
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Scheduler
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Utility
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Balances
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for TransactionPayment
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Council
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for TechnicalCommittee
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Treasury
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Authorship
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for CollatorSelection
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Session
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Aura
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for AuraExt
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Multisig
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for TimeRelease
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Proxy
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Msa
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Messages
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Schemas
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for StatefulStorage
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Capacity
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for FrequencyTxPayment
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Handles
[2024-06-05T23:56:01Z DEBUG wasm-heap] allocator dropped: AllocationStats { bytes_allocated: 40, bytes_allocated_peak: 456, bytes_allocated_sum: 12592, address_space_used: 720 }
[2024-06-05T23:56:01Z DEBUG wasm-runtime] Allocated WASM instance 1/2
[2024-06-05T23:56:01Z INFO  try_runtime_core::commands::on_runtime_upgrade] -------------------------------------------------------------------

[2024-06-05T23:56:01Z INFO  try_runtime_core::commands::on_runtime_upgrade] 🔬 TryRuntime_on_runtime_upgrade succeeded! Running it again without checks for weight measurements.

[2024-06-05T23:56:01Z INFO  try_runtime_core::commands::on_runtime_upgrade] -------------------------------------------------------------------
[2024-06-05T23:56:01Z INFO  frequency_runtime] try-runtime::on_runtime_upgrade frequency.
[2024-06-05T23:56:01Z INFO  runtime::schemas] Running storage migration...
[2024-06-05T23:56:01Z INFO  runtime::schemas] onchain_version= StorageVersion(3), current_version=StorageVersion(4)
[2024-06-05T23:56:01Z INFO  runtime::schemas] Storage migrated to version 4  read=1, write=1, bytes=0
[2024-06-05T23:56:01Z INFO  runtime::schemas] Migration Calculated weights=Weight { ref_time: 125000000, proof_size: 0 }
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for System
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for ParachainSystem
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Timestamp
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for ParachainInfo
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Sudo
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Preimage
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Democracy
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Scheduler
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Utility
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Balances
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for TransactionPayment
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Council
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for TechnicalCommittee
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Treasury
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Authorship
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for CollatorSelection
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Session
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Aura
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for AuraExt
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Multisig
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for TimeRelease
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Proxy
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Msa
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Messages
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Schemas
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for StatefulStorage
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Capacity
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for FrequencyTxPayment
[2024-06-05T23:56:01Z DEBUG runtime::frame-support] ✅ no migration for Handles
[2024-06-05T23:56:01Z DEBUG wasm-heap] allocator dropped: AllocationStats { bytes_allocated: 40, bytes_allocated_peak: 416, bytes_allocated_sum: 4792, address_space_used: 680 }
[2024-06-05T23:56:01Z INFO  try_runtime_core::commands::on_runtime_upgrade] -------------------------------------------------------------------

[2024-06-05T23:56:01Z INFO  try_runtime_core::commands::on_runtime_upgrade] 🔬 Running TryRuntime_on_runtime_upgrade again to check idempotency: PreAndPost

[2024-06-05T23:56:01Z INFO  try_runtime_core::commands::on_runtime_upgrade] -------------------------------------------------------------------
[2024-06-05T23:56:01Z INFO  frequency_runtime] try-runtime::on_runtime_upgrade frequency.
[2024-06-05T23:56:01Z INFO  runtime::schemas] Running pre_upgrade...
[2024-06-05T23:56:01Z INFO  runtime::schemas] Running storage migration...
[2024-06-05T23:56:01Z INFO  runtime::schemas] onchain_version= StorageVersion(4), current_version=StorageVersion(4)
[2024-06-05T23:56:01Z INFO  runtime::schemas] Migration did not execute. This probably should be removed onchain:StorageVersion(4), current:StorageVersion(4)
[2024-06-05T23:56:01Z INFO  runtime::schemas] Running post_upgrade...
codecov[bot] commented 4 months ago

Codecov Report

Attention: Patch coverage is 71.79487% with 11 lines in your changes missing coverage. Please review.

Files Coverage Δ
common/primitives/src/utils.rs 87.50% <100.00%> (+1.78%) :arrow_up:
pallets/schemas/src/types.rs 92.30% <ø> (ø)
pallets/schemas/src/migration/v4.rs 41.53% <50.00%> (ø)

... and 3 files with indirect coverage changes

enddynayn commented 3 months ago

Why not submit transactions for these instead of writing a migration script?

wilwade commented 3 months ago

Why not submit transactions for these instead of writing a migration script?

Good question!

  1. They were migrations originally and we wanted to understand (and document in code) what was wrong and right.
  2. As a pair was setup wrong, the transactions to make that change would be hard to audit for governance voting on it (as it would be a direct state set which could be anything from a tx view)
  3. Clear trail per #2