Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
fix: migrations and try-runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
José Molina committed Nov 23, 2023
1 parent 4caeded commit a793eab
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/try-runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ jobs:
echo "---------- Running try-runtime for Trappist ----------"
cargo build -p trappist --locked --release --no-default-features --features trappist/trappist-runtime,try-runtime && \
try-runtime --runtime ./target/release/wbuild/trappist-runtime/target/wasm32-unknown-unknown/release/trappist_runtime.wasm \
on-runtime-upgrade live --uri wss://rococo-trappist-try-runtime-node.parity-chains.parity.io:443
on-runtime-upgrade --checks pre-and-post --disable-idempotency-checks live --uri wss://rococo-trappist-try-runtime-node.parity-chains.parity.io:443
env:
RUST_LOG: remote-ext=debug,runtime=debug
11 changes: 6 additions & 5 deletions runtime/trappist/src/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ use frame_support::{
parameter_types,
traits::{ConstBool, ConstU32, Nothing},
};
use pallet_contracts::{
migration::{v13, v14, v15},
Config, DebugInfo, DefaultAddressGenerator, Frame, Schedule,
};
use pallet_contracts::{Config, DebugInfo, DefaultAddressGenerator, Frame, Schedule};
pub use parachains_common::AVERAGE_ON_INITIALIZE_RATIO;
use sp_runtime::Perbill;

Expand Down Expand Up @@ -69,7 +66,11 @@ impl Config for Runtime {
type UnsafeUnstableInterface = ConstBool<true>;
type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>;
#[cfg(not(feature = "runtime-benchmarks"))]
type Migrations = (v13::Migration<Self>, v14::Migration<Self, Balances>, v15::Migration<Self>);
type Migrations = (
pallet_contracts::migration::v13::Migration<Self>,
pallet_contracts::migration::v14::Migration<Self, Balances>,
pallet_contracts::migration::v15::Migration<Self>,
);
#[cfg(feature = "runtime-benchmarks")]
type Migrations = pallet_contracts::migration::codegen::BenchMigrations;
type MaxDelegateDependencies = ConstU32<32>;
Expand Down
32 changes: 1 addition & 31 deletions runtime/trappist/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
(migrations::SetStorageVersions, pallet_contracts::Migration<Runtime>),
pallet_contracts::Migration<Runtime>,
>;

impl_opaque_keys! {
Expand Down Expand Up @@ -719,36 +719,6 @@ construct_runtime!(
}
);

pub mod migrations {
use super::*;
use frame_support::traits::{GetStorageVersion, OnRuntimeUpgrade, StorageVersion};

/// Migrations that set `StorageVersion`s we missed to set.
///
/// It's *possible* that these pallets have not in fact been migrated to the versions being set,
/// which we should keep in mind in the future if we notice any strange behavior.
/// We opted to not check exactly what on-chain versions each pallet is at, since it would be
/// an involved effort, this is testnet, and no one has complained
/// (https://github.com/paritytech/polkadot-sdk/issues/6657#issuecomment-1552956439).
pub struct SetStorageVersions;

impl OnRuntimeUpgrade for SetStorageVersions {
fn on_runtime_upgrade() -> Weight {
let mut writes = 0;
let mut reads = 0;

// Scheduler
if Scheduler::on_chain_storage_version() < 4 {
StorageVersion::new(4).put::<Scheduler>();
writes += 1;
}
reads += 1;

RocksDbWeight::get().reads_writes(reads, writes)
}
}
}

#[cfg(feature = "runtime-benchmarks")]
mod benches {
define_benchmarks!(
Expand Down

0 comments on commit a793eab

Please sign in to comment.