feat: add launch pallet removal migration#359
Conversation
136ef24 to
76456e2
Compare
runtimes/common/src/migrations.rs
Outdated
| pub struct RemoveKiltLaunch<R>(PhantomData<R>); | ||
| impl<R: frame_system::Config> frame_support::traits::OnRuntimeUpgrade for RemoveKiltLaunch<R> { | ||
| fn on_runtime_upgrade() -> frame_support::weights::Weight { | ||
| let items = match frame_support::storage::unhashed::kill_prefix(&hex!("37be294ab4b5aa76f1df3f80e7c180ef"), None) |
There was a problem hiding this comment.
Can this be generated from the pallet name string?
There was a problem hiding this comment.
Was just playing around, and this is what apparently works: let hash = sp_io::hashing::twox_128(b"KiltLaunch");.
No need to change it, but I think it's better for readability and for potentially fix any issues we identify in the future.
runtimes/common/src/migrations.rs
Outdated
| "🚀 Pre check: Launch pallet storage exists {}?", | ||
| frame_support::storage::migration::have_storage_value( | ||
| &hex!("37be294ab4b5aa76f1df3f80e7c180ef"), | ||
| // b"KiltLaunch" |
There was a problem hiding this comment.
Why not deriving the HEX from the name directly?
There was a problem hiding this comment.
The hex macro requires an input of type string. I did not manage to quickly get it running with any permutation of the pallet name, e.g. hex!(b"KiltLaunch".into()). Just using b"KiltLaunch" without hex! wrapping leads to a different storage prefix.
ntn-x2
left a comment
There was a problem hiding this comment.
LGTM! I only have one small question about the logic of the pre_upgrade() migration check.
runtimes/common/src/migrations.rs
Outdated
| let prefix: [u8; 16] = sp_io::hashing::twox_128(b"KiltLaunch"); | ||
|
|
||
| assert!( | ||
| sp_io::storage::next_key(&prefix).map_or(true, |next_key| next_key.starts_with(&prefix)), |
There was a problem hiding this comment.
Probably not relevant, but shouldn't the assertion fail in case there is no key under the given prefix, as we do indeed expect a key?
| sp_io::storage::next_key(&prefix).map_or(true, |next_key| next_key.starts_with(&prefix)), | |
| sp_io::storage::next_key(&prefix).map_or(false, |next_key| next_key.starts_with(&prefix)), |
There was a problem hiding this comment.
Good catch! You are correct. Fixed in a4c3a5e
* feat: add launch pallet removal migration * chore: rm launch pallet code * fix: migration * fix: clippy + suggestion (cherry picked from commit 6ce128e)
* Adds two more relaychain bootnodes for staging environment (#334) * chore: reset peregrine stg (#335) * ci: use custom ci image (#336) * Optimizes docker layer (#337) * fix: add did lookup pallet to DID authorization logic + reverse lookup index (#343) * chore: update toolchain version to nightly 1.59 (#339) * feat: proxy type for disableling deposit claiming (#341) * fix: rococo protocol id (#369) * feat: generic access control (#316) * Updates toolchain version (#345) * refactor: enforce no runtime in pallet (#349) * fix: features (#353) * feat: add tips pallet (#352) * feat: upgrade to Polkadot v0.9.19 (#357) * chore: upgrade and clean up (#360) * Adds the new rococo chainspec (#363) * feat: add launch pallet removal migration (#359) * refactor: update rilt para id from 2015 to 2108 (#364) * fix: rilt para id (#365) * feat: upgrade to Polkadot v0.9.23 (#366) * use ci-linx:production base image (#368) * feat: upgrade to Polkadot v0.9.24 (#370) * fix: fix CI builders compilation errors and pin to a specific hash (#372)

fixes KILTProtocol/ticket#1951
0x37be294ab4b5aa76f1df3f80e7c180efChecklist:
array[3]useget(3), ...)