generate_storage_alias: Rewrite as proc macro attribute (#11387)

* generate_storage_alias: Rewrite as proc macro attribute

This rewrites the `generate_storage_alias!` declarative macro as proc-macro attribute. While doing
this the name is changed to `storage_alias`. The prefix can now also be the name of a pallet. This
makes storage aliases work in migrations for all kind of chains and not just for the ones that use
predefined prefixes.

* Fix compilation and FMT

* Moare fixes

* 🤦

* ......

* Rework the syntax and support instancing

* FMT

* Prefix variants with `Storage`

* Make it compile

* Fix where clause on rust stable
This commit is contained in:
Bastian Köcher
2022-05-18 00:45:56 +02:00
committed by GitHub
parent 27f08fec3a
commit 74428fa8ac
21 changed files with 884 additions and 379 deletions
+4 -7
View File
@@ -16,9 +16,7 @@
// limitations under the License.
use super::{Config, OffenceDetails, Perbill, SessionIndex};
use frame_support::{
generate_storage_alias, pallet_prelude::ValueQuery, traits::Get, weights::Weight,
};
use frame_support::{pallet_prelude::ValueQuery, storage_alias, traits::Get, weights::Weight};
use sp_staking::offence::{DisableStrategy, OnOffenceHandler};
use sp_std::vec::Vec;
@@ -31,10 +29,9 @@ type DeferredOffenceOf<T> = (
// Deferred reports that have been rejected by the offence handler and need to be submitted
// at a later time.
generate_storage_alias!(
Offences,
DeferredOffences<T: Config> => Value<Vec<DeferredOffenceOf<T>>, ValueQuery>
);
#[storage_alias]
type DeferredOffences<T: Config> =
StorageValue<crate::Pallet<T>, Vec<DeferredOffenceOf<T>>, ValueQuery>;
pub fn remove_deferred_storage<T: Config>() -> Weight {
let mut weight = T::DbWeight::get().reads_writes(1, 1);