问题描述
我遵循了 Write a Pallet in its Own Crate 教程。
我用教程仔细检查了所有内容,但是当我 cargo build --release
时,我收到 66 条错误消息。大多数错误消息类似于以下 2(更多详细信息):
cannot find type `Pallet` in crate/scope
the trait bound `Runtime: frame_system::pallet::Congig` is not satisfied
我创建了一个错误日志。在 stackoverflow.com 上发布错误日志或这么多错误消息的最佳方式是什么?
information that should be included in a bug report.
Executing build command: "/home/df/.rustup/toolchains/nightly-x86_64-unkNown-linux-gnu/bin/cargo" "rustc" "--target=wasm32-unkNown-unkNown" "--manifest-path=/mnt/f/Etp/Substrate/tutorials/02/substrate-node-template/target/release/wbuild/node-template-runtime/Cargo.toml" "--color=always" "--release"
Using rustc version: rustc 1.55.0-nightly (24bdc6d73 2021-06-12)
errorm: expected one of: `Pallet`,`Call`,`Storage`,`Event`,`Config`,`Origin`,`Inherent`,`ValidateUnsigned`
--> /mnt/f/Etp/Substrate/tutorials/02/substrate-node-template/runtime/src/lib.rs:338:29
|
338 | TestPallet: test_pallet::{Module,Call,Storage,Event<T>},| ^^^^^^ `
因此我从第 338 行中删除了 Module
:TestPallet: test_pallet::{Module,
如果我再次 cargo build --release
,我会收到 14 条错误消息,这些消息将在下面发布。你有什么想法,出了什么问题?
Compiling node-template-runtime v3.0.0 (/mnt/f/Etp/Substrate/tutorials/02/substrate-node-template/runtime)
error: Failed to run custom build command for `node-template-runtime v3.0.0 (/mnt/f/Etp/Substrate/tutorials/02/substrate-node-template/runtime)`
Caused by:
process didn't exit successfully: `/mnt/f/Etp/Substrate/tutorials/02/substrate-node-template/target/release/build/node-template-runtime-10b4571a8bd12437/build-script-build` (exit status: 1)
--- stdout
information that should be included in a bug report.
Executing build command: "/home/df/.rustup/toolchains/nightly-x86_64-unkNown-linux-gnu/bin/cargo" "rustc" "--target=wasm32-unkNown-unkNown" "--manifest-path=/mnt/f/Etp/Substrate/tutorials/02/substrate-node-template/target/release/wbuild/node-template-runtime/Cargo.toml" "--color=always" "--release"
Using rustc version: rustc 1.55.0-nightly (24bdc6d73 2021-06-12)
--- stderr
Compiling node-template-runtime v3.0.0 (/mnt/f/Etp/Substrate/tutorials/02/substrate-node-template/runtime)
error[E0412]: cannot find type `Pallet` in crate `test_pallet`
--> /mnt/f/Etp/Substrate/tutorials/02/substrate-node-template/runtime/src/lib.rs:321:1
|
321 | / construct_runtime!(
322 | | pub enum Runtime where
323 | | Block = Block,324 | | NodeBlock = opaque::Block,... |
340 | | }
341 | | );
| |__^ not found in `test_pallet`
|
= note: this error originates in the macro `construct_runtime` (in Nightly builds,run with -Z macro-backtrace for more info)
help: consider importing one of these items
|
9 | use crate::pallet_template::Pallet;
|
9 | use frame_system::Pallet;
|
9 | use pallet_aura::Pallet;
|
9 | use pallet_balances::Pallet;
|
and 7 other candidates
error: duplicate lang item in crate `sp_io` (which `frame_support` depends on): `panic_impl`.
|
= note: the lang item is first defined in crate `sp_io` (which `frame_support` depends on)
= note: first deFinition in `sp_io` loaded from /mnt/f/Etp/Substrate/tutorials/02/substrate-node-template/target/release/wbuild/node-template-runtime/target/wasm32-unkNown-unkNown/release/deps/libsp_io-68d2ddc13c0ddd99.rMeta
= note: second deFinition in `sp_io` loaded from /mnt/f/Etp/Substrate/tutorials/02/substrate-node-template/target/release/wbuild/node-template-runtime/target/wasm32-unkNown-unkNown/release/deps/libsp_io-0c3d7ed5f1bed9c8.rMeta
error: duplicate lang item in crate `sp_io` (which `frame_support` depends on): `oom`.
|
= note: the lang item is first defined in crate `sp_io` (which `frame_support` depends on)
= note: first deFinition in `sp_io` loaded from /mnt/f/Etp/Substrate/tutorials/02/substrate-node-template/target/release/wbuild/node-template-runtime/target/wasm32-unkNown-unkNown/release/deps/libsp_io-68d2ddc13c0ddd99.rMeta
= note: second deFinition in `sp_io` loaded from /mnt/f/Etp/Substrate/tutorials/02/substrate-node-template/target/release/wbuild/node-template-runtime/target/wasm32-unkNown-unkNown/release/deps/libsp_io-0c3d7ed5f1bed9c8.rMeta
error[E0277]: the trait bound `Runtime: frame_system::pallet::Config` is not satisfied
--> /mnt/f/Etp/Substrate/tutorials/02/substrate-node-template/runtime/src/lib.rs:316:6
|
316 | impl test_pallet::Config for Runtime {
| ^^^^^^^^^^^^^^^^^^^ the trait `frame_system::pallet::Config` is not implemented for `Runtime`
|
::: /mnt/f/Etp/Substrate/tutorials/02/substrate-node-template/pallets/test-pallet/src/lib.rs:17:19
|
17 | pub trait Config: frame_system::Config {
| -------------------- required by this bound in `test_pallet::Config`
error[E0277]: the trait bound `Runtime: frame_system::pallet::Config` is not satisfied
--> /mnt/f/Etp/Substrate/tutorials/02/substrate-node-template/runtime/src/lib.rs:321:1
|
321 | / construct_runtime!(
322 | | pub enum Runtime where
323 | | Block = Block,... |
340 | | }
341 | | );
| |__^ the trait `frame_system::pallet::Config` is not implemented for `Runtime`
|
= note: this error originates in the macro `$crate::impl_outer_event` (in Nightly builds,run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `Runtime: frame_system::pallet::Config` is not satisfied
--> /mnt/f/Etp/Substrate/tutorials/02/substrate-node-template/runtime/src/lib.rs:321:1
|
321 | / construct_runtime!(
322 | | pub enum Runtime where
323 | | Block = Block,run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `Event: TryInto<test_pallet::RawEvent<_>>` is not satisfied
--> /mnt/f/Etp/Substrate/tutorials/02/substrate-node-template/runtime/src/lib.rs:321:1
|
321 | / construct_runtime!(
322 | | pub enum Runtime where
323 | | Block = Block,... |
340 | | }
341 | | );
| |__^ the trait `TryInto<test_pallet::RawEvent<_>>` is not implemented for `Event`
|
= help: the following implementations were found:
<Event as TryInto<frame_system::Event<Runtime>>>
<Event as TryInto<pallet_balances::Event<Runtime>>>
<Event as TryInto<pallet_grandpa::Event>>
<Event as TryInto<pallet_nicks::RawEvent<AccountId32,u128>>>
and 3 others
= note: this error originates in the macro `$crate::impl_outer_event` (in Nightly builds,run with -Z macro-backtrace for more info)
error: aborting due to 14 prevIoUs errors
Some errors have detailed explanations: E0277,E0412.
For more information about an error,try `rustc --explain E0277`.
error: Could not compile `node-template-runtime`
To learn more,run the command again with --verbose.
解决方法
您应该替换 Module
为 Pallet
,而不是将其删除。
您可能需要在 test-pallet/lib.rs 中添加 pub use pallet::*;