Implements pallet versioning (#7208)

* Start

* Make macro work

* Rename `ModuleToIndex` to `PalletRuntimeSetup`

Besides the renaming it also adds support getting the name of a pallet
as configured in the runtime.

* Rename it to `PalletInfo`

* Remove accidentally added files

* Some work

* Make everything compile

* Adds a test and fixes some bugs

* Implement ordering for `PalletVersion`

* Apply suggestions from code review

* Review feedback

* Update frame/support/src/dispatch.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Update frame/support/src/dispatch.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Fix compilation

* Fix test

* Fix doc test

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
Bastian Köcher
2020-10-21 19:05:52 +02:00
committed by GitHub
parent 8cebbd142d
commit ed1d0fa815
30 changed files with 640 additions and 161 deletions
@@ -4,10 +4,7 @@ macro_rules! reserved {
mod $reserved {
pub use frame_support::dispatch;
pub trait Trait {
type Origin;
type BlockNumber: Into<u32>;
}
pub trait Trait: frame_support_test::Trait {}
pub mod system {
use frame_support::dispatch;
@@ -18,7 +15,7 @@ macro_rules! reserved {
}
frame_support::decl_module! {
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=frame_support_test {
#[weight = 0]
fn $reserved(_origin) -> dispatch::DispatchResult { unreachable!() }
}
@@ -1,39 +1,39 @@
error: Invalid call fn name: `on_finalize`, name is reserved and doesn't match expected signature, please refer to `decl_module!` documentation to see the appropriate usage, or rename it to an unreserved keyword.
--> $DIR/on_initialize.rs:31:1
--> $DIR/on_initialize.rs:28:1
|
31 | reserved!(on_finalize on_initialize on_runtime_upgrade offchain_worker deposit_event);
28 | reserved!(on_finalize on_initialize on_runtime_upgrade offchain_worker deposit_event);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: Invalid call fn name: `on_initialize`, name is reserved and doesn't match expected signature, please refer to `decl_module!` documentation to see the appropriate usage, or rename it to an unreserved keyword.
--> $DIR/on_initialize.rs:31:1
--> $DIR/on_initialize.rs:28:1
|
31 | reserved!(on_finalize on_initialize on_runtime_upgrade offchain_worker deposit_event);
28 | reserved!(on_finalize on_initialize on_runtime_upgrade offchain_worker deposit_event);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: Invalid call fn name: `on_runtime_upgrade`, name is reserved and doesn't match expected signature, please refer to `decl_module!` documentation to see the appropriate usage, or rename it to an unreserved keyword.
--> $DIR/on_initialize.rs:31:1
--> $DIR/on_initialize.rs:28:1
|
31 | reserved!(on_finalize on_initialize on_runtime_upgrade offchain_worker deposit_event);
28 | reserved!(on_finalize on_initialize on_runtime_upgrade offchain_worker deposit_event);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: Invalid call fn name: `offchain_worker`, name is reserved and doesn't match expected signature, please refer to `decl_module!` documentation to see the appropriate usage, or rename it to an unreserved keyword.
--> $DIR/on_initialize.rs:31:1
--> $DIR/on_initialize.rs:28:1
|
31 | reserved!(on_finalize on_initialize on_runtime_upgrade offchain_worker deposit_event);
28 | reserved!(on_finalize on_initialize on_runtime_upgrade offchain_worker deposit_event);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: Invalid call fn name: `deposit_event`, name is reserved and doesn't match expected signature, please refer to `decl_module!` documentation to see the appropriate usage, or rename it to an unreserved keyword.
--> $DIR/on_initialize.rs:31:1
--> $DIR/on_initialize.rs:28:1
|
31 | reserved!(on_finalize on_initialize on_runtime_upgrade offchain_worker deposit_event);
28 | reserved!(on_finalize on_initialize on_runtime_upgrade offchain_worker deposit_event);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)