Skip to content

Commit

Permalink
fix: add try-runtime feature to did lookup crate
Browse files Browse the repository at this point in the history
  • Loading branch information
ntn-x2 committed Mar 22, 2022
1 parent 52365eb commit 6a4445f
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

7 changes: 7 additions & 0 deletions pallets/pallet-did-lookup/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ sp-keystore = {branch = "polkadot-v0.9.17", default-features = false, git = "htt

[dependencies]
codec = {default-features = false, features = ["derive"], package = "parity-scale-codec", version = "2.3.1"}
log = "0.4"
scale-info = {version = "1.0", default-features = false, features = ["derive"]}

# KILT
Expand Down Expand Up @@ -49,7 +50,13 @@ std = [
"frame-benchmarking/std",
"frame-support/std",
"frame-system/std",
"log/std",
"scale-info/std",
"sp-runtime/std",
"sp-std/std",
]

try-runtime = [
"frame-support/try-runtime",
"kilt-support/try-runtime",
]
8 changes: 7 additions & 1 deletion pallets/pallet-did-lookup/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ pub struct LookupReverseIndexMigration<T>(PhantomData<T>);
impl<T: Config> OnRuntimeUpgrade for LookupReverseIndexMigration<T> {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<(), &'static str> {
assert!(Pallet::<T>::on_chain_storage_version() < Pallet::current_storage_version());
assert!(Pallet::<T>::on_chain_storage_version() < Pallet::<T>::current_storage_version());
assert_eq!(ConnectedAccounts::<T>::iter().count(), 0);

log::info!("👥 DID lookup pallet to v{:?} passes PRE migrate checks ✅", Pallet::<T>::current_storage_version());

Ok(())
}

Expand All @@ -50,6 +52,8 @@ impl<T: Config> OnRuntimeUpgrade for LookupReverseIndexMigration<T> {

Pallet::<T>::current_storage_version().put::<Pallet<T>>();

log::info!("👥 completed DID lookup pallet migration to v3 ✅",);

total_weight
}

Expand All @@ -70,6 +74,8 @@ impl<T: Config> OnRuntimeUpgrade for LookupReverseIndexMigration<T> {
assert_eq!(entry.did, did);
});

log::info!("👥 DID lookup pallet to v{:?} passes POST migrate checks ✅", Pallet::<T>::current_storage_version());

Ok(())
}
}
1 change: 1 addition & 0 deletions runtimes/peregrine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ try-runtime = [
"pallet-authorship/try-runtime",
"pallet-balances/try-runtime",
"pallet-collective/try-runtime",
"pallet-did-lookup/try-runtime",
"pallet-democracy/try-runtime",
"pallet-indices/try-runtime",
"pallet-membership/try-runtime",
Expand Down
2 changes: 1 addition & 1 deletion runtimes/peregrine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("mashnet-node"),
impl_name: create_runtime_str!("mashnet-node"),
authoring_version: 4,
spec_version: 10500,
spec_version: 10600,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 2,
Expand Down
1 change: 1 addition & 0 deletions runtimes/spiritnet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ try-runtime = [
"pallet-balances/try-runtime",
"pallet-collective/try-runtime",
"pallet-democracy/try-runtime",
"pallet-did-lookup/try-runtime",
"pallet-indices/try-runtime",
"pallet-membership/try-runtime",
"pallet-preimage/try-runtime",
Expand Down
2 changes: 1 addition & 1 deletion runtimes/spiritnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("kilt-spiritnet"),
impl_name: create_runtime_str!("kilt-spiritnet"),
authoring_version: 1,
spec_version: 10500,
spec_version: 10600,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down
1 change: 1 addition & 0 deletions runtimes/standalone/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ try-runtime = [
"pallet-aura/try-runtime",
"pallet-authorship/try-runtime",
"pallet-balances/try-runtime",
"pallet-did-lookup/try-runtime",
"pallet-grandpa/try-runtime",
"pallet-indices/try-runtime",
"pallet-proxy/try-runtime",
Expand Down
2 changes: 1 addition & 1 deletion runtimes/standalone/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("mashnet-node"),
impl_name: create_runtime_str!("mashnet-node"),
authoring_version: 4,
spec_version: 10500,
spec_version: 10600,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 2,
Expand Down

0 comments on commit 6a4445f

Please sign in to comment.