Skip to content

Optimize pallet_migrations storage reads in on_initialize #70

@tmpolaczyk

Description

@tmpolaczyk

pallet_migrations reads storage ShouldPauseXcm on every block in on_initialize, even though this is only needed for one block, during (or after?) a runtime upgrade:

fn on_initialize(_: BlockNumberFor<T>) -> Weight {
if ShouldPauseXcm::<T>::get() {
// Suspend XCM execution
if let Err(error) = T::XcmExecutionManager::suspend_xcm_execution() {
<Pallet<T>>::deposit_event(Event::FailedToSuspendIdleXcmExecution { error });
}
// Account on_finalize write
T::DbWeight::get().reads_writes(1, 1)
} else {
T::DbWeight::get().reads(1)
}
}

Explore an alternative approach that pauses xcm execution in some other way that doesn't require the on_initialize hook.

Same for on_finalize.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions