frame: Enable GenesisConfig in no_std (#14108)

* frame: Default for GenesisConfig in no_std

`Default` for `GenesisConfig` will be required for no_std in no native
runtime world. It must be possible to instantiate default GenesisConfig
for pallets and runtime.

* ".git/.scripts/commands/fmt/fmt.sh"

* hash69 in no_std reverted

* derive(DefaultNoBound) for GenesisConfig used when possible

* treasury: derive(Default)

* Cargo.lock update

* genesis_config: compiler error improved

When std feature is not enabled for pallet, the GenesisConfig will be
defined, but serde::{Serialize,Deserialize} traits will not be
implemented.

The compiler error indicates the reason of latter errors.

This is temporary and serde traits will be enabled with together with
`serde` support in frame.

---------

Co-authored-by: command-bot <>
This commit is contained in:
Michal Kucharczyk
2023-05-20 09:34:23 +02:00
committed by GitHub
parent 5100a0376e
commit 613420a035
31 changed files with 149 additions and 173 deletions
@@ -1,4 +1,4 @@
error: `Pallet` does not have the std feature enabled, this will cause the `test_pallet::GenesisConfig` type to be undefined.
error: `Pallet` does not have the std feature enabled, this will cause the `test_pallet::GenesisConfig` type to not implement serde traits.
--> tests/construct_runtime_ui/no_std_genesis_config.rs:40:1
|
40 | / construct_runtime! {
@@ -12,7 +12,7 @@ error: `Pallet` does not have the std feature enabled, this will cause the `test
|
= note: this error originates in the macro `test_pallet::__substrate_genesis_config_check::is_std_enabled_for_genesis` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0412]: cannot find type `GenesisConfig` in crate `test_pallet`
error[E0277]: the trait bound `frame_support_test_pallet::GenesisConfig: Serialize` is not satisfied
--> tests/construct_runtime_ui/no_std_genesis_config.rs:40:1
|
40 | / construct_runtime! {
@@ -22,10 +22,109 @@ error[E0412]: cannot find type `GenesisConfig` in crate `test_pallet`
... |
48 | | }
49 | | }
| |_^ not found in `test_pallet`
| |_^ the trait `Serialize` is not implemented for `frame_support_test_pallet::GenesisConfig`
|
= help: the following other types implement trait `Serialize`:
&'a T
&'a mut T
()
(T0, T1)
(T0, T1, T2)
(T0, T1, T2, T3)
(T0, T1, T2, T3, T4)
(T0, T1, T2, T3, T4, T5)
and $N others
note: required by a bound in `hidden_include::serde::ser::SerializeStruct::serialize_field`
--> $CARGO/serde-1.0.162/src/ser/mod.rs
|
| T: Serialize;
| ^^^^^^^^^ required by this bound in `SerializeStruct::serialize_field`
= note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this struct
error[E0277]: the trait bound `frame_support_test_pallet::GenesisConfig: Deserialize<'_>` is not satisfied
--> tests/construct_runtime_ui/no_std_genesis_config.rs:47:3
|
1 | use frame_system::GenesisConfig;
47 | Pallet: test_pallet::{Pallet, Config},
| ^^^^^^ the trait `Deserialize<'_>` is not implemented for `frame_support_test_pallet::GenesisConfig`
|
= help: the following other types implement trait `Deserialize<'de>`:
<&'a [u8] as Deserialize<'de>>
<&'a std::path::Path as Deserialize<'de>>
<&'a str as Deserialize<'de>>
<() as Deserialize<'de>>
<(T0, T1) as Deserialize<'de>>
<(T0, T1, T2) as Deserialize<'de>>
<(T0, T1, T2, T3) as Deserialize<'de>>
<(T0, T1, T2, T3, T4) as Deserialize<'de>>
and $N others
note: required by a bound in `next_element`
--> $CARGO/serde-1.0.162/src/de/mod.rs
|
| T: Deserialize<'de>,
| ^^^^^^^^^^^^^^^^ required by this bound in `SeqAccess::next_element`
error[E0277]: the trait bound `frame_support_test_pallet::GenesisConfig: Deserialize<'_>` is not satisfied
--> tests/construct_runtime_ui/no_std_genesis_config.rs:47:3
|
47 | Pallet: test_pallet::{Pallet, Config},
| ^^^^^^ the trait `Deserialize<'_>` is not implemented for `frame_support_test_pallet::GenesisConfig`
|
= help: the following other types implement trait `Deserialize<'de>`:
<&'a [u8] as Deserialize<'de>>
<&'a std::path::Path as Deserialize<'de>>
<&'a str as Deserialize<'de>>
<() as Deserialize<'de>>
<(T0, T1) as Deserialize<'de>>
<(T0, T1, T2) as Deserialize<'de>>
<(T0, T1, T2, T3) as Deserialize<'de>>
<(T0, T1, T2, T3, T4) as Deserialize<'de>>
and $N others
note: required by a bound in `next_value`
--> $CARGO/serde-1.0.162/src/de/mod.rs
|
| V: Deserialize<'de>,
| ^^^^^^^^^^^^^^^^ required by this bound in `MapAccess::next_value`
error[E0277]: the trait bound `frame_support_test_pallet::GenesisConfig: Deserialize<'_>` is not satisfied
--> tests/construct_runtime_ui/no_std_genesis_config.rs:40:1
|
40 | / construct_runtime! {
41 | | pub struct Runtime where
42 | | Block = Block,
43 | | NodeBlock = Block,
... |
48 | | }
49 | | }
| |_^ the trait `Deserialize<'_>` is not implemented for `frame_support_test_pallet::GenesisConfig`
|
= help: the following other types implement trait `Deserialize<'de>`:
<&'a [u8] as Deserialize<'de>>
<&'a std::path::Path as Deserialize<'de>>
<&'a str as Deserialize<'de>>
<() as Deserialize<'de>>
<(T0, T1) as Deserialize<'de>>
<(T0, T1, T2) as Deserialize<'de>>
<(T0, T1, T2, T3) as Deserialize<'de>>
<(T0, T1, T2, T3, T4) as Deserialize<'de>>
and $N others
note: required by a bound in `hidden_include::serde::__private::de::missing_field`
--> $CARGO/serde-1.0.162/src/private/de.rs
|
| V: Deserialize<'de>,
| ^^^^^^^^^^^^^^^^ required by this bound in `missing_field`
= note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `frame_support_test_pallet::GenesisConfig: BuildModuleGenesisStorage<Runtime, ()>` is not satisfied
--> tests/construct_runtime_ui/no_std_genesis_config.rs:40:1
|
40 | / construct_runtime! {
41 | | pub struct Runtime where
42 | | Block = Block,
43 | | NodeBlock = Block,
... |
48 | | }
49 | | }
| |_^ the trait `BuildModuleGenesisStorage<Runtime, ()>` is not implemented for `frame_support_test_pallet::GenesisConfig`
|
= help: the trait `BuildModuleGenesisStorage<T, ()>` is implemented for `frame_system::GenesisConfig`
= note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info)
@@ -28,7 +28,9 @@ error[E0412]: cannot find type `GenesisConfig` in module `pallet`
| |_^ not found in `pallet`
|
= note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this struct
help: consider importing one of these items
|
1 | use frame_system::GenesisConfig;
|
1 | use test_pallet::GenesisConfig;
|