Skip to content

Commit

Permalink
fix graph keys on testnet attempt 2 (#2232)
Browse files Browse the repository at this point in the history
# Goal

The muti-block migration did not work as expected. It looks like the
code inside `on_initialize` did not get executed. I'm out of theories
why that would happen but there might be something related to the
feature flags. This is another attempt that replaces feature flag
attempt with the genesis hash.

# Changes
- replaced feature flags with genesis hash checks
- Added tighter checks `on_initialize` (for better readability)

# Discussions
If anyone have a theory why the code inside `on_initialize` didn't get
executed on paseo please contact me.

Closes #2227

# Checklist
- [X] Spec version incremented?
  • Loading branch information
aramikm authored Dec 6, 2024
1 parent 5457c8f commit 2e2cc3f
Showing 3 changed files with 12 additions and 13 deletions.
19 changes: 10 additions & 9 deletions pallets/stateful-storage/src/lib.rs
Original file line number Diff line number Diff line change
@@ -66,6 +66,8 @@ const LOG_TARGET: &str = "runtime::stateful-storage";
#[frame_support::pallet]
pub mod pallet {
use super::*;
use crate::migration::v1::{get_chain_type, get_testnet_msa_ids};
use common_primitives::utils::DetectedChainType;

#[pallet::config]
pub trait Config: frame_system::Config {
@@ -232,19 +234,18 @@ pub mod pallet {
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_initialize(_current: BlockNumberFor<T>) -> Weight {
// this should get removed after rolling out to testnet
#[cfg(any(feature = "frequency-testnet", test))]
{
if DetectedChainType::FrequencyPaseoTestNet == get_chain_type::<T>() || cfg!(test) {
let page_index = <MigrationPageIndex<T>>::get();
let (weight, continue_migration) = migration::v1::paginated_migration_testnet::<T>(
MIGRATION_PAGE_SIZE,
page_index,
);
if continue_migration {
if get_testnet_msa_ids().len() as u32 > page_index * MIGRATION_PAGE_SIZE {
let (weight, _) = migration::v1::paginated_migration_testnet::<T>(
MIGRATION_PAGE_SIZE,
page_index,
);
<MigrationPageIndex<T>>::set(page_index.saturating_add(1));
return T::DbWeight::get().reads_writes(1, 1).saturating_add(weight)
}
T::DbWeight::get().reads_writes(1, 1).saturating_add(weight)
return T::DbWeight::get().reads_writes(1, 0)
}
#[cfg(not(any(feature = "frequency-testnet", test)))]
Weight::zero()
}
}
2 changes: 0 additions & 2 deletions pallets/stateful-storage/src/migration/v1.rs
Original file line number Diff line number Diff line change
@@ -23,7 +23,6 @@ use sp_runtime::TryRuntimeError;
use sp_std::{vec, vec::Vec};

/// testnet specific msa ids for migration
#[cfg(any(feature = "frequency-testnet", test))]
pub fn get_testnet_msa_ids() -> Vec<MessageSourceId> {
vec![
8004, 8009, 8816, 8817, 8818, 8819, 8820, 8822, 8823, 8824, 8825, 8826, 9384, 9753, 9919,
@@ -229,7 +228,6 @@ pub fn migrate_msa_ids<T: Config>(msa_ids: &[MessageSourceId]) -> Weight {
}

/// paginated migration for testnet
#[cfg(any(feature = "frequency-testnet", test))]
pub fn paginated_migration_testnet<T: Config>(page_size: u32, page_index: u32) -> (Weight, bool) {
let msa_ids: Vec<MessageSourceId> = get_testnet_msa_ids();
let mut chunks = msa_ids.chunks(page_size as usize);
4 changes: 2 additions & 2 deletions runtime/frequency/src/lib.rs
Original file line number Diff line number Diff line change
@@ -404,7 +404,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("frequency"),
impl_name: create_runtime_str!("frequency"),
authoring_version: 1,
spec_version: 135,
spec_version: 136,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
@@ -418,7 +418,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("frequency-testnet"),
impl_name: create_runtime_str!("frequency"),
authoring_version: 1,
spec_version: 135,
spec_version: 136,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,

0 comments on commit 2e2cc3f

Please sign in to comment.