diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index 1bf8b6a11f..b34eee2154 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -4713,7 +4713,7 @@ dependencies = [ [[package]] name = "pallet-proxy" -version = "2.0.0" +version = "2.0.1" dependencies = [ "frame-benchmarking", "frame-support", diff --git a/substrate/frame/proxy/Cargo.toml b/substrate/frame/proxy/Cargo.toml index 1c32edf162..219e72502e 100644 --- a/substrate/frame/proxy/Cargo.toml +++ b/substrate/frame/proxy/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-proxy" -version = "2.0.0" +version = "2.0.1" authors = ["Parity Technologies "] edition = "2018" license = "Apache-2.0" diff --git a/substrate/frame/proxy/src/lib.rs b/substrate/frame/proxy/src/lib.rs index 4746a4ab67..98d6ef47d3 100644 --- a/substrate/frame/proxy/src/lib.rs +++ b/substrate/frame/proxy/src/lib.rs @@ -226,22 +226,6 @@ decl_module! { /// `AnnouncementDepositFactor` metadata shadow. const AnnouncementDepositFactor: BalanceOf = T::AnnouncementDepositFactor::get(); - fn on_runtime_upgrade() -> Weight { - Proxies::::translate::<(Vec<(T::AccountId, T::ProxyType)>, BalanceOf), _>( - |_, (targets, deposit)| Some(( - targets.into_iter() - .map(|(a, t)| ProxyDefinition { - delegate: a, - proxy_type: t, - delay: Zero::zero(), - }) - .collect::>(), - deposit, - )) - ); - T::MaximumBlockWeight::get() - } - /// Dispatch the given `call` from an account that the sender is authorised for through /// `add_proxy`. /// @@ -675,3 +659,32 @@ impl Module { Self::deposit_event(RawEvent::ProxyExecuted(e.map(|_| ()).map_err(|e| e.error))); } } + +/// Migration utilities for upgrading the Proxy pallet between its different versions. +pub mod migration { + use super::*; + + /// Migration code for https://github.com/paritytech/substrate/pull/6770 + /// + /// Details: This migration was introduced between Substrate 2.0-RC6 and Substrate 2.0 releases. + /// Before this migration, the `Proxies` storage item used a tuple of `AccountId` and + /// `ProxyType` to represent the proxy definition. After #6770, we switched to use a struct + /// `ProxyDefinition` which additionally included a `BlockNumber` delay value. This function, + /// simply takes any existing proxies using the old tuple format, and migrates it to the new + /// struct by setting the delay to zero. + pub fn migrate_to_time_delayed_proxies() -> Weight { + Proxies::::translate::<(Vec<(T::AccountId, T::ProxyType)>, BalanceOf), _>( + |_, (targets, deposit)| Some(( + targets.into_iter() + .map(|(a, t)| ProxyDefinition { + delegate: a, + proxy_type: t, + delay: Zero::zero(), + }) + .collect::>(), + deposit, + )) + ); + T::MaximumBlockWeight::get() + } +}