Find the source I have been working with at: https://github.com/al3mart/substrate-node-template/tree/al3mart/runtime-featuregated.
While building a node using the feature-gated runtimes added in https://github.com/paritytech/substrate/pull/11818 I encounter the following compilation errors.
- Scenario 1
construct_runtime!
includes a pallet decorated by #[cfg(feature = "template")]
.
Building with: $ cargo build --release
results in
--- stderr
Compiling node-template-runtime v4.0.0-dev (/home/ale/Projects/substrate/substrate-node-template/runtime)
error[E0277]: the trait bound `Event: From<pallet_template::Event<Runtime>>` is not satisfied
--> /home/ale/Projects/substrate/substrate-node-template/runtime/src/lib.rs:270:15
|
270 | type Event = Event;
| ^^^^^ the trait `From<pallet_template::Event<Runtime>>` is not implemented for `Event`
|
= help: the following other types implement trait `From<T>`:
<Event as From<frame_system::Event<Runtime>>>
<Event as From<pallet_balances::Event<Runtime>>>
<Event as From<pallet_grandpa::Event>>
<Event as From<pallet_sudo::Event<Runtime>>>
<Event as From<pallet_transaction_payment::Event<Runtime>>>
note: required by a bound in `pallet_template::Config::Event`
--> /home/ale/Projects/substrate/substrate-node-template/pallets/template/src/lib.rs:30:15
|
30 | type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
| ^^^^^^^^^^^^^^^^^ required by this bound in `pallet_template::Config::Event`
For more information about this error, try `rustc --explain E0277`.
- Scenario 2
construct_runtime!
includes a pallet decorated by #[cfg(feature = "template")]
.
Building with: $ cargo build --release --features template
results in
--- stdout
Information that should be included in a bug report.
Executing build command: "rustup" "run" "nightly" "cargo" "rustc" "--target=wasm32-unknown-unknown" "--manifest-path=/home/ale/Projects/substrate/substrate-node-template/target/release/wbuild/node-template-runtime/Cargo.toml" "--color=always" "--profile" "release"
Using rustc version: rustc 1.65.0-nightly (2e35f954a 2022-09-01)
--- stderr
Compiling node-template-runtime v4.0.0-dev (/home/ale/Projects/substrate/substrate-node-template/runtime)
error[E0428]: the name `AllPalletsWithSystem` is defined multiple times
--> /home/ale/Projects/substrate/substrate-node-template/runtime/src/lib.rs:280:1
|
280 | construct_runtime!(
| _^
| _|_|
| | |
281 | | | pub struct Runtime
282 | | | where
283 | | | Block = Block,
... | |
298 | | | }
299 | | | );
| | |_- in this macro invocation
... |
|
= note: `AllPalletsWithSystem` must be defined only once in the type namespace of this module
= note: this error originates in the macro `frame_support::construct_runtime` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0428]: the name `AllPalletsWithoutSystem` is defined multiple times
--> /home/ale/Projects/substrate/substrate-node-template/runtime/src/lib.rs:280:1
|
280 | construct_runtime!(
| _^
| _|_|
| | |
281 | | | pub struct Runtime
282 | | | where
283 | | | Block = Block,
... | |
298 | | | }
299 | | | );
| | |_- in this macro invocation
... |
|
= note: `AllPalletsWithoutSystem` must be defined only once in the type namespace of this module
= note: this error originates in the macro `frame_support::construct_runtime` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0428]: the name `AllPalletsWithSystemReversed` is defined multiple times
--> /home/ale/Projects/substrate/substrate-node-template/runtime/src/lib.rs:280:1
|
280 | construct_runtime!(
| _^
| _|_|
| | |
281 | | | pub struct Runtime
282 | | | where
283 | | | Block = Block,
... | |
298 | | | }
299 | | | );
| | |_- in this macro invocation
... |
|
= note: `AllPalletsWithSystemReversed` must be defined only once in the type namespace of this module
= note: this error originates in the macro `frame_support::construct_runtime` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0428]: the name `AllPalletsWithoutSystemReversed` is defined multiple times
--> /home/ale/Projects/substrate/substrate-node-template/runtime/src/lib.rs:280:1
|
280 | construct_runtime!(
| _^
| _|_|
| | |
281 | | | pub struct Runtime
282 | | | where
283 | | | Block = Block,
... | |
298 | | | }
299 | | | );
| | |_- in this macro invocation
... |
|
= note: `AllPalletsWithoutSystemReversed` must be defined only once in the type namespace of this module
= note: this error originates in the macro `frame_support::construct_runtime` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0428]: the name `AllPalletsReversedWithSystemFirst` is defined multiple times
--> /home/ale/Projects/substrate/substrate-node-template/runtime/src/lib.rs:280:1
|
280 | construct_runtime!(
| _^
| _|_|
| | |
281 | | | pub struct Runtime
282 | | | where
283 | | | Block = Block,
... | |
298 | | | }
299 | | | );
| | |_- in this macro invocation
... |
|
= note: `AllPalletsReversedWithSystemFirst` must be defined only once in the type namespace of this module
= note: this error originates in the macro `frame_support::construct_runtime` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: ignoring -C extra-filename flag due to -o flag
For more information about this error, try `rustc --explain E0428`.
warning: `node-template-runtime` (lib) generated 1 warning
error: could not compile `node-template-runtime` due to 5 previous errors; 1 warning emitted
To reproduce the above behavior run the build commands posted above.