Skip to content

Commit

Permalink
Release koi-6800 (#1629)
Browse files Browse the repository at this point in the history
* Bump storage version

* Bump spec ver
  • Loading branch information
AurevoirXavier authored Nov 25, 2024
1 parent 1f85158 commit 1d4c28e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
28 changes: 25 additions & 3 deletions pallet/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,27 @@ pub mod migration {
where
T: Config,
{
let ver = StorageVersion::get::<Pallet<T>>();
let (mut r, mut w) = (1, 0);

if ver != 2 {
log::warn!(
"\
[pallet::staking] skipping v2 to v3 migration: executed on wrong storage version.\
Expected version 2, found {ver:?}\
",
);

return (r, w);
}

fn clear(item: &[u8], r: &mut u64, w: &mut u64) {
let res = migration::clear_storage_prefix(PALLET, item, &[], None, None);

*r += res.loops as u64;
*w += res.backend as u64;
}

let rw @ (mut r, mut w) = (1, 1);

clear(b"Collators", &mut r, &mut w);
clear(b"Nominators", &mut r, &mut w);
clear(b"ExposureCacheStates", &mut r, &mut w);
Expand All @@ -69,9 +81,16 @@ pub mod migration {
)>(PALLET, b"AuthoredBlocksCount", &[])
{
<AuthoredBlockCount<T>>::put(abc);

r += 1;
w += 1;
}

rw
StorageVersion::new(3).put::<Pallet<T>>();

w += 1;

(r, w)
}

pub fn post_check<T>()
Expand Down Expand Up @@ -138,6 +157,8 @@ pub mod pallet {
// darwinia
use crate::*;

const STORAGE_VERSION: StorageVersion = StorageVersion::new(3);

#[pallet::config]
pub trait Config: frame_system::Config {
/// Override the [`frame_system::Config::RuntimeEvent`].
Expand Down Expand Up @@ -256,6 +277,7 @@ pub mod pallet {
}

#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
Expand Down
2 changes: 1 addition & 1 deletion runtime/koi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion {
spec_name: sp_runtime::create_runtime_str!("Darwinia Koi"),
impl_name: sp_runtime::create_runtime_str!("DarwiniaOfficialRust"),
authoring_version: 0,
spec_version: 6_7_2_0,
spec_version: 6_8_0_0,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 0,
Expand Down

0 comments on commit 1d4c28e

Please sign in to comment.