substrate-docs
substrate-docs copied to clipboard
"Add a pallet to the runtime" tutorial not working
Is there an existing issue?
- [X] I have searched the existing issues
Experiencing problems? Have you tried our Stack Exchange first?
- [X] This is not a support question.
Bug report for compiling, code snippets, templates, etc.
I followed the instructions as described in https://docs.substrate.io/tutorials/build-application-logic/add-a-pallet/.
After I implemented the instructions under the chapter "Implement the configuration for Nicks" and run cargo check -p node-template-runtime --release I get a bunch of errors about various parts not being found in the scope, such as:
error[E0412]: cannot find type `Runtime` in this scope
--> /opt/dev/arjanvaneersel/substrate/substrate-node-template/runtime/src/lib.rs:252:31
|
252 | impl pallet_nicks::Config for Runtime {
| ^^^^^^^ not found in this scope
error[E0412]: cannot find type `RuntimeEvent` in this scope
--> /opt/dev/arjanvaneersel/substrate/substrate-node-template/runtime/src/lib.rs:274:22
|
274 | type RuntimeEvent = RuntimeEvent;
| ^^^^^^^^^^^^ help: you might have meant to use the associated type: `Self::RuntimeEvent`
error[E0433]: failed to resolve: use of undeclared type `TransactionPayment`
--> /opt/dev/arjanvaneersel/substrate/substrate-node-template/runtime/src/lib.rs:530:4
|
530 | TransactionPayment::length_to_fee(length)
| ^^^^^^^^^^^^^^^^^^
| |
| use of undeclared type `TransactionPayment`
| help: a type alias with a similar name exists: `TransactionValidity`
One thing I noticed in particular is that in the tutorial Runtime is an enum:
construct_runtime!(
pub enum Runtime where
Block = Block,
NodeBlock = opaque::Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
/* --snip-- */
Balances: pallet_balances,
/*** Add This Line ***/
Nicks: pallet_nicks,
}
);
while in my code (which is a clean substrate-node-template clone) it's a struct:
construct_runtime!(
pub struct Runtime {
System: frame_system,
Timestamp: pallet_timestamp,
Aura: pallet_aura,
Grandpa: pallet_grandpa,
Balances: pallet_balances,
Nicks: pallet_nicks,
TransactionPayment: pallet_transaction_payment,
Sudo: pallet_sudo,
// Include the custom logic from the pallet-template in the runtime.
TemplateModule: pallet_template,
}
);
Perhaps substrate-node-template got updated causing the tutorial or maybe Nick's pallet now being outdated.
Steps to reproduce the problem
- Clone substrate-node-template
- Follow the steps in the tutorial
The problem was caused by the following line
pallet-nicks = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
which should be:
pallet-nicks = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } to work with the current version of substrate-node-template.
Nicks does not exists anymore in the polkadot sdk. The tutorial should be updated https://github.com/paritytech/polkadot-sdk/commit/dc4a4559111988300f1a2493b649956d48728ccc