0

Adding the below section to the rs.lib file

impl pallet_node_authorization::Config for Runtime {
   type RuntimeEvent = RuntimeEvent;
   type MaxWellKnownNodes = MaxWellKnownNodes;
   type MaxPeerIdLength = MaxPeerIdLength;
   type AddOrigin = EnsureRoot<AccountId>;
   type RemoveOrigin = EnsureRoot<AccountId>;
   type SwapOrigin = EnsureRoot<AccountId>;
   type ResetOrigin = EnsureRoot<AccountId>;
   type WeightInfo = ();
  }

  

produce this error when building the node::

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 /home/ubuntu/substrate/substrate_auth_palet/target/release/wbuild/node-template-runtime/target/wasm32-unknown-u
nknown/release/deps/libsp_io-05621afa7ed3c196.rmeta
    = note: second definition in `sp_io` loaded from /home/ubuntu/substrate/substrate_auth_palet/target/release/wbuild/node-template-runtime/target/wasm32-unknown-
unknown/release/deps/libsp_io-276985975586ba28.rmeta

(without this section --> no error when building the node)

The same error occurs when add the last row to the construct_runtime

construct_runtime!(
        pub struct Runtime
        where
                Block = Block,
                NodeBlock = opaque::Block,
                UncheckedExtrinsic = UncheckedExtrinsic,
        {
                System: frame_system,
                RandomnessCollectiveFlip: 
                    pallet_randomness_collective_flip,
                Timestamp: pallet_timestamp,
                Aura: pallet_aura,
                Grandpa: pallet_grandpa,
                Balances: pallet_balances,
                TransactionPayment: pallet_transaction_payment,
                Sudo: pallet_sudo,
 
                TemplateModule: pallet_template,
                NodeAuthorization: pallet_node_authorization::{Pallet, 
                    Call, Storage, Event<T>, Config<T>}
        }
);

The lib.rs file includes this section: #![cfg_attr(not(feature = "std"), no_std)].

Any idea on how to prevent this error?

My Cargo.toml :

[package]
name = "node-template-runtime"
version = "4.0.0-dev"
description = "A fresh FRAME-based Substrate node, ready for hacking."
authors = ["Substrate DevHub <https://github.com/substrate-developer-hub>"]
homepage = "https://substrate.io/"
edition = "2021"
license = "Unlicense"
publish = false
repository = "https://github.com/substrate-developer-hub/substrate-node-template/"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }

pallet-aura = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", " branch" = "polkadot-v0.9.35" }
pallet-balances = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", " branch" = "polkadot-v0.9.35" }
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", " branch" = "polkadot-v0.9.35" }
pallet-grandpa = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", " branch" = "polkadot-v0.9.35" }
pallet-randomness-collective-flip = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", " branch" = "polkadot-v0.9.35" }
pallet-sudo = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", " branch" = "polkadot-v0.9.35" }
frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", " branch" = "polkadot-v0.9.35" }
frame-try-runtime = { version = "0.10.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", optional = true , " branch" = "polkadot-v0.9.35" }
pallet-timestamp = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", " branch" = "polkadot-v0.9.35" }
pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", " branch" = "polkadot-v0.9.35" }
frame-executive = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", " branch" = "polkadot-v0.9.35" }
sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", " branch" = "polkadot-v0.9.35" }
sp-block-builder = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", " branch" = "polkadot-v0.9.35" }
sp-consensus-aura = { version = "0.10.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", " branch" = "polkadot-v0.9.35" }
sp-core = { version = "7.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", " branch" = "polkadot-v0.9.35" }
sp-inherents = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", " branch" = "polkadot-v0.9.35" }
sp-offchain = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", " branch" = "polkadot-v0.9.35" }
sp-runtime = { version = "7.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", " branch" = "polkadot-v0.9.35" }
sp-session = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", " branch" = "polkadot-v0.9.35" }
sp-std = { version = "5.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", " branch" = "polkadot-v0.9.35" }
sp-transaction-pool = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", " branch" = "polkadot-v0.9.35" }
sp-version = { version = "5.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", " branch" = "polkadot-v0.9.35" }
pallet-node-authorization = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.35" }    

# Used for the node template's RPCs
frame-system-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", " branch" = "polkadot-v0.9.35" }
pallet-transaction-payment-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", " branch" = "polkadot-v0.9.35">

# Used for runtime benchmarking
frame-benchmarking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", optional = true , " branch" = "polkadot-v0.9.35" }
frame-system-benchmarking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", optional = true , " branch" = "polkadot-v0.9.35>

# Local Dependencies
pallet-template = { version = "4.0.0-dev", default-features = false, path = "../pallets/template" }

[build-dependencies]
substrate-wasm-builder = { version = "5.0.0-dev", git = "https://github.com/paritytech/substrate.git", " branch" = "polkadot-v0.9.35" }

[features]
default = ["std"]
std = [
        "frame-try-runtime?/std",
        "frame-system-benchmarking?/std",
        "frame-benchmarking?/std",
        "codec/std",
       "scale-info/std",
        "frame-executive/std",
        "frame-support/std",
        "frame-system-rpc-runtime-api/std",
        "frame-system/std",
        "frame-try-runtime/std",
        "pallet-aura/std",
        "pallet-balances/std",
        "pallet-grandpa/std",
        "pallet-randomness-collective-flip/std",
        "pallet-sudo/std",
        "pallet-template/std",
        "pallet-timestamp/std",
        "pallet-transaction-payment-rpc-runtime-api/std",
        "pallet-transaction-payment/std",
        "sp-api/std",
        "sp-block-builder/std",
        "sp-consensus-aura/std",
        "sp-core/std",
        "sp-inherents/std",
        "sp-offchain/std",
        "sp-runtime/std",
        "sp-session/std",
        "sp-std/std",
        "sp-transaction-pool/std",
        "sp-version/std",
        "pallet-node-authorization/std",
]
runtime-benchmarks = [
        "frame-benchmarking/runtime-benchmarks",
        "frame-support/runtime-benchmarks",
        "frame-system-benchmarking/runtime-benchmarks",
        "frame-system/runtime-benchmarks",
        "pallet-balances/runtime-benchmarks",
        "pallet-grandpa/runtime-benchmarks",
        "pallet-template/runtime-benchmarks",
        "pallet-timestamp/runtime-benchmarks",
        "sp-runtime/runtime-benchmarks",
]
try-runtime = [
        "frame-try-runtime/try-runtime",
        "frame-executive/try-runtime",
        "frame-system/try-runtime",
        "frame-support/try-runtime",
        "pallet-aura/try-runtime",
        "pallet-balances/try-runtime",
        "pallet-grandpa/try-runtime",
        "pallet-randomness-collective-flip/try-runtime",
        "pallet-sudo/try-runtime",
        "pallet-template/try-runtime",
        "pallet-timestamp/try-runtime",
        "pallet-transaction-payment/try-runtime",
]
3
  • Can you share the full Cargo.toml? This error can be an issue with versions
    – Alex Bean
    Dec 27, 2022 at 8:30
  • Just did @AlexBean Dec 27, 2022 at 9:23
  • @AlexBean - I tried to change polkadot branch from 9.35 to 34 and 33 but didn't solve it Dec 27, 2022 at 10:44

2 Answers 2

1

This error is mostly about that not having std feature of any dependency in cargo.toml.

In your case, pallet-nicks does not have std feature in Cargo.toml. Either remove pallet-nicks, if you are not using it or add pallet-nicks/std in std features list.

4
  • It is not relevant, even if it is not needed. I just add this pallet to test it too and it creates the same problem. I also tried to build without it and the issue still exists. Dec 27, 2022 at 18:55
  • BTW: I tried it on 2 separate machine and the issue returned on itself. (Linux and mac) Dec 27, 2022 at 19:01
  • @PazDiamant As I said, in most of the cases, not having std feature of any dependency in cargo.toml could be the reason. There might be other reasons as well. I can also see wrong versions in your Cargo.toml. Can you correct versions in your Cargo.toml? For ex: In your Cargo.toml, you have used 7.0.0 for sp-core. Ideally it should be 6.0.0 according to this github.com/paritytech/substrate/blob/polkadot-v0.9.33/… same for sp-runtime. Please check for other dependencies too Dec 29, 2022 at 6:46
  • thanks @Ayush-Mishra, this is not the culprit, i just tried it with 9.33 , 9.34, 9.35 (see changes in the above code) and in 9.35 the sp-core should be v 7.0.0(if I'm not mistaken). I also do not see any missing std feature. Wil be great if you can please give me one. Thanks in advance Dec 30, 2022 at 8:11
1

Upgrade to the latest version and now the problem does not exists

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.