-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be generated from the pallet name string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not deriving the HEX from the name directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
0x37be294ab4b5aa76f1df3f80e7c180ef
Checklist:
array[3]
useget(3)
, ...)