Skip to content

"Add a pallet to the runtime" tutorial not working #2032

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
2 tasks done
arjanvaneersel opened this issue Jul 31, 2023 · 2 comments
Open
2 tasks done

"Add a pallet to the runtime" tutorial not working #2032

arjanvaneersel opened this issue Jul 31, 2023 · 2 comments
Labels
bug 🐛 Something isn't working.

Comments

@arjanvaneersel
Copy link

arjanvaneersel commented Jul 31, 2023

Is there an existing issue?

  • I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • 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

  1. Clone substrate-node-template
  2. Follow the steps in the tutorial
@arjanvaneersel arjanvaneersel added the bug 🐛 Something isn't working. label Jul 31, 2023
@arjanvaneersel
Copy link
Author

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.

@sgerodes
Copy link

Nicks does not exists anymore in the polkadot sdk. The tutorial should be updated
paritytech/polkadot-sdk@dc4a455

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working.
Projects
None yet
Development

No branches or pull requests

2 participants