Skip to content

Commit

Permalink
v0.9.39 - Adjust bagslist renaming migration and add migration test t…
Browse files Browse the repository at this point in the history
…o runtime
  • Loading branch information
mnaamani committed Apr 4, 2023
1 parent 767abda commit ffbe5b9
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 9 deletions.
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ pallet-im-online = { package = 'pallet-im-online', default-features = false, git
substrate-utility = { package = 'pallet-utility', version = "4.0.0-dev", default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '50cf239147a6f569e563bcadec6c7a1c5ad5c67e'}
pallet-vesting = { package = 'pallet-vesting', default-features = false, git = 'https://github.com/joystream/substrate', rev = '50cf239147a6f569e563bcadec6c7a1c5ad5c67e' }
pallet-multisig = { package = 'pallet-multisig', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '50cf239147a6f569e563bcadec6c7a1c5ad5c67e'}
pallet-staking-runtime-api = { package = 'pallet-staking-runtime-api', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '50cf239147a6f569e563bcadec6c7a1c5ad5c67e'}

# Benchmarking
frame-benchmarking = { git = 'https://github.com/joystream/substrate.git', rev = '50cf239147a6f569e563bcadec6c7a1c5ad5c67e', default-features = false, optional = true }
Expand Down Expand Up @@ -95,6 +96,9 @@ project-token = { package = 'pallet-project-token', default-features = false, pa
[dev-dependencies]
sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '50cf239147a6f569e563bcadec6c7a1c5ad5c67e'}
strum = {version = "0.19", default-features = false}
remote-externalities = { package = "frame-remote-externalities", git = 'https://github.com/joystream/substrate.git', rev = '50cf239147a6f569e563bcadec6c7a1c5ad5c67e'}
tokio = { version = "1.24.2", features = ["macros"] }
sp-tracing = { package = 'sp-tracing', git = 'https://github.com/joystream/substrate.git', rev = '50cf239147a6f569e563bcadec6c7a1c5ad5c67e'}

[build-dependencies]
substrate-wasm-builder = { git = "https://github.com/joystream/substrate", rev = '50cf239147a6f569e563bcadec6c7a1c5ad5c67e' }
Expand Down Expand Up @@ -158,6 +162,7 @@ std = [
'pallet-bags-list/std',
'pallet-election-provider-multi-phase/std',
'pallet-election-provider-support-benchmarking?/std',
'pallet-staking-runtime-api/std',

# Joystream
'common/std',
Expand Down
52 changes: 50 additions & 2 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,8 @@ impl pallet_staking::Config for Runtime {
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type ElectionProvider = ElectionProviderMultiPhase;
type GenesisElectionProvider = onchain::OnChainExecution<OnChainSeqPhragmen>;
type VoterList = VoterList;
type VoterList = BagsList;
// type VoterList = VoterList; // not renaming for now
type TargetList = pallet_staking::UseValidatorsMap<Self>;
type MaxUnlockingChunks = ConstU32<32>;
type HistoryDepth = HistoryDepth;
Expand Down Expand Up @@ -1848,7 +1849,9 @@ construct_runtime!(
ImOnline: pallet_im_online,
Offences: pallet_offences,
RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip,
VoterList: pallet_bags_list::<Instance1>::{Pallet, Call, Storage, Event<T>},
BagsList: pallet_bags_list::<Instance1>::{Pallet, Call, Storage, Event<T>},
// Not renaming BagsList to VoterList until migration test failing can be fixed
// VoterList: pallet_bags_list::<Instance1>::{Pallet, Call, Storage, Event<T>},
Vesting: pallet_vesting,
Multisig: pallet_multisig,
// Joystream
Expand Down Expand Up @@ -1878,3 +1881,48 @@ construct_runtime!(
DistributionWorkingGroup: working_group::<Instance9>::{Pallet, Call, Storage, Event<T>},
}
);

#[cfg(all(test, feature = "try-runtime"))]
mod remote_tests {
use super::*;
use frame_try_runtime::{runtime_decl_for_TryRuntime::TryRuntime, UpgradeCheckSelect};
use remote_externalities::{
Builder, Mode, OfflineConfig, OnlineConfig, SnapshotConfig, Transport,
};
use std::env::var;

#[tokio::test]
async fn run_migrations() {
if var("RUN_MIGRATION_TESTS").is_err() {
return;
}

sp_tracing::try_init_simple();
let transport: Transport = var("WS")
.unwrap_or("wss://rpc.joystream.org:443".to_string())
.into();
let maybe_state_snapshot: Option<SnapshotConfig> = var("SNAP").map(|s| s.into()).ok();
let mut ext = Builder::<Block>::default()
.mode(if let Some(state_snapshot) = maybe_state_snapshot {
Mode::OfflineOrElseOnline(
OfflineConfig {
state_snapshot: state_snapshot.clone(),
},
OnlineConfig {
transport,
state_snapshot: Some(state_snapshot),
..Default::default()
},
)
} else {
Mode::Online(OnlineConfig {
transport,
..Default::default()
})
})
.build()
.await
.unwrap();
ext.execute_with(|| Runtime::on_runtime_upgrade(UpgradeCheckSelect::PreAndPost));
}
}
18 changes: 11 additions & 7 deletions runtime/src/runtime_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ use sp_runtime::{generic, ApplyExtrinsicResult};
use sp_std::vec::Vec;

use crate::{
AccountId, AllPalletsWithSystem, AuthorityDiscovery, AuthorityDiscoveryId, Babe, Balance,
BlockNumber, EpochDuration, Grandpa, GrandpaAuthorityList, GrandpaId, Historical, Index,
InherentDataExt, ProposalsEngine, Runtime, RuntimeBlockWeights, RuntimeCall, RuntimeVersion,
SessionKeys, Signature, System, TransactionPayment, VoterList, BABE_GENESIS_EPOCH_CONFIG,
VERSION,
AccountId, AllPalletsWithSystem, AuthorityDiscovery, AuthorityDiscoveryId, Babe, BagsList,
Balance, BlockNumber, EpochDuration, Grandpa, GrandpaAuthorityList, GrandpaId, Historical,
Index, InherentDataExt, ProposalsEngine, Runtime, RuntimeCall, RuntimeVersion, SessionKeys,
Signature, Staking, System, TransactionPayment, BABE_GENESIS_EPOCH_CONFIG, VERSION,
};

#[cfg(feature = "try-runtime")]
use crate::RuntimeBlockWeights;

use frame_support::weights::Weight;

/// The SignedExtension to the basic transaction logic.
Expand Down Expand Up @@ -98,8 +100,10 @@ pub type Migrations = (
pallet_staking::migrations::v9::InjectValidatorsIntoVoterList<Runtime>,
// slash all pending slashes correctly
pallet_staking::migrations::v10::MigrateToV10<Runtime>,
// Rename BagsList to VoterList
pallet_staking::migrations::v11::MigrateToV11<Runtime, VoterList, StakingMigrationV11OldPallet>,
// Rename BagsList to VoterList - SKIPPING FOR NOW BY KEEPING SAME NAME
// Post-Upgrade check is failing -> 'old pallet data hasn't been removed'
// Only storage version will be bumped. Is this a problem?
pallet_staking::migrations::v11::MigrateToV11<Runtime, BagsList, StakingMigrationV11OldPallet>,
// Kill HistoryDepth storage
pallet_staking::migrations::v12::MigrateToV12<Runtime>,
// Migrate to new storage versioning
Expand Down

0 comments on commit ffbe5b9

Please sign in to comment.