I have just started exploring substrate and I am following this tutorial, (https://docs.substrate.io/tutorials/v3/add-a-pallet/).
Under step Implement the Nicks pallet Config trait -> Add Nicks to the construct_runtime! macro., I added Nicks pallet to my runtime, as shown in the screenshot.
Now, when I run cargo check -p node-template-runtime, I get a lot of errors;
asad#asad-Z440:~/Dev/Blockchain/polkadot/substrate-node-template$ cargo check -p node-template-runtime
warning: /home/asad/Dev/Blockchain/polkadot/substrate-node-template/node/Cargo.toml: version requirement `3.0.0-monthly-2021-09+1` for dependency `node-template-runtime` includes semver metadata which will be ignored, removing the metadata is recommended to avoid confusion
warning: /home/asad/Dev/Blockchain/polkadot/substrate-node-template/runtime/Cargo.toml: version requirement `3.0.0-monthly-2021-09+1` for dependency `pallet-template` includes semver metadata which will be ignored, removing the metadata is recommended to avoid confusion
Updating git repository `https://github.com/paritytech/substrate.git`
Updating crates.io index
Updating git repository `https://github.com/paritytech/substrate.git`
Compiling node-template-runtime v3.0.0-monthly-2021-09+1 (/home/asad/Dev/Blockchain/polkadot/substrate-node-template/runtime)
error: failed to run custom build command for `node-template-runtime v3.0.0-monthly-2021-09+1 (/home/asad/Dev/Blockchain/polkadot/substrate-node-template/runtime)`
Caused by:
process didn't exit successfully: `/home/asad/Dev/Blockchain/polkadot/substrate-node-template/target/debug/build/node-template-runtime-c9c48352bd7ed47e/build-script-build` (exit status: 1)
--- 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/asad/Dev/Blockchain/polkadot/substrate-node-template/target/debug/wbuild/node-template-runtime/Cargo.toml" "--color=always" "--release"
Using rustc version: rustc 1.57.0-nightly (aa7aca3b9 2021-09-30)
--- stderr
warning: /home/asad/Dev/Blockchain/polkadot/substrate-node-template/runtime/Cargo.toml: version requirement `3.0.0-monthly-2021-09+1` for dependency `pallet-template` includes semver metadata which will be ignored, removing the metadata is recommended to avoid confusion
Updating git repository `https://github.com/paritytech/substrate.git`
Compiling node-template-runtime v3.0.0-monthly-2021-09+1 (/home/asad/Dev/Blockchain/polkadot/substrate-node-template/runtime)
warning: unused doc comment
--> /home/asad/Dev/Blockchain/polkadot/substrate-node-template/runtime/src/lib.rs:253:1
|
253 | /// Nicks Config:
| ^^^^^^^^^^^^^^^^^ rustdoc does not generate documentation for macro invocations
|
= note: `#[warn(unused_doc_comments)]` on by default
= help: to document an item produced by a macro, the macro must produce the documentation as part of its expansion
error: duplicate lang item in crate `sp_io` (which `frame_support` depends on): `panic_impl`.
.........
310 | / construct_runtime!(
311 | | pub enum Runtime where
312 | | Block = Block,
313 | | NodeBlock = opaque::Block,
... |
327 | | }
328 | | );
| |__^
note: required by a bound in `sp_runtime::generic::UncheckedExtrinsic`
--> /home/asad/.cargo/git/checkouts/substrate-7e08433d4c370a21/20a9bbb/primitives/runtime/src/generic/unchecked_extrinsic.rs:39:40
|
39 | pub struct UncheckedExtrinsic<Address, Call, Signature, Extra>
| ^^^^ required by this bound in `sp_runtime::generic::UncheckedExtrinsic`
= note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info)
For more information about this error, try `rustc --explain E0277`.
warning: `node-template-runtime` (lib) generated 1 warning
error: could not compile `node-template-runtime` due to 112 previous errors; 1 warning emitted
Things I have tried:
Removing Cargo.lock file and then running cargo check -p node-template-runtime.
PS: I am just starting with rust and substrate, so spare me if i am asking something obvious here.
Related
When I try to build the ping-pong smart contract from here using:
erdpy build contract
I don't get the following expected output:
INFO:projects.core:WASM file generated: output/ping-pong.wasm
because of the following errors that appear in the sc_results.rs file:
Compiling elrond-codec v0.5.3
Compiling elrond-wasm v0.18.2
error[E0432]: unresolved import `core::ops::FromResidual`
--> /Users/<username>/elrondsdk/vendor-rust/registry/src/github.com-1ecc6299db9ec823/elrond-wasm-0.18.2/src/types/io/sc_result.rs:7:30
...
error[E0437]: type Output is not a member of trait `Try`
--> /Users/<username>/elrondsdk/vendor-rust/registry/src/github.com-1ecc6299db9ec823/elrond-wasm-0.18.2/src/types/io/sc_result.rs:62:5
...
error[E0437]: type Residual is not a member of trait `Try`
--> /Users/<username>/elrondsdk/vendor-rust/registry/src/github.com-1ecc6299db9ec823/elrond-wasm-0.18.2/src/types/io/sc_result.rs:63:5
...
error[E0407]: method branch is not a member of trait `Try`
--> /Users/<username>/elrondsdk/vendor-rust/registry/src/github.com-1ecc6299db9ec823/elrond-wasm-0.18.2/src/types/io/sc_result.rs:65:5
...
error[E0407]: method from_output is not a member of trait `Try`
--> /Users/<username>/elrondsdk/vendor-rust/registry/src/github.com-1ecc6299db9ec823/elrond-wasm-0.18.2/src/types/io/sc_result.rs:71:5
...
error aborting due to 5 previous errors
...
CRITICAL:cli:Build error: error code = 101, see output.
Environment:
elrond-wasm - v0.18.2
erdpy - v1.0.19
How to solve this build issue?
The problem was that Rust had a non-backwards-compatible change earlier this year.
So, there was an incompatibility with old versions, but it worked fine with newer versions.
Updating Rust using:
rustup update
solved the problem.
Now:
rustc --version | grep -o '^[^(]*'
prints
rustc 1.57.0-nightly
I got the compile error when I follow the latest substrate tutorial add-a-pallet.
compiler complain about the bind error u128 type doesn't satisfied with Event.
Using rustc version: rustc 1.57.0-nightly (54bb4fec6 2021-10-08)
Compiling node-template-runtime v3.0.0-monthly-2021-10 (/home/bruce/substrate-node-template/runtime)
error: failed to run custom build command for `node-template-runtime v3.0.0-monthly-2021-10 (/home/bruce/substrate-node-template/runtime)`
Caused by:
process didn't exit successfully: `/home/bruce/substrate-node-template/target/release/build/node-template-runtime-41f26d4f5bdef0b7/build-script-build` (exit status: 1)
--- 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/bruce/substrate-node-template/target/release/wbuild/node-template-runtime/Cargo.toml" "--color=always" "--release"
Using rustc version: rustc 1.57.0-nightly (54bb4fec6 2021-10-08)
--- stderr
Compiling node-template-runtime v3.0.0-monthly-2021-10 (/home/bruce/substrate-node-template/runtime)
error[E0277]: the trait bound `u128: Currency<AccountId32>` is not satisfied in `Event`
--> /home/bruce/substrate-node-template/runtime/src/lib.rs:303:1
|
303 | / construct_runtime!(
304 | | pub enum Runtime where
305 | | Block = Block,
306 | | NodeBlock = opaque::Block,
... |
320 | | }
321 | | );
| |__^ within `Event`, the trait `Currency<AccountId32>` is not implemented for `u128`
|
note: required because it appears within the type `Event`
error: could not compile `node-template-runtime` due to 10 previous errors
Substrate Node Template does not compile on any version of Rust compiler compiler. I suggest to:
execute init.sh script in scripts directory
working versions on my end looks like below:
stable-x86_64-unknown-linux-gnu
rustup default stable-x86_64-unknown-linux-gnu
After applying those two suggestions you should be able to compile source code.
I get this error when trying to compile and I seem to be unable to solve it...:
In terminal, after running 'cargo check' I get:
Compiling node-template-runtime v2.0.1 (/runtime)
error[E0405]: cannot find trait `Config` in crate `pallet_assets`
--> /runtime/src/lib.rs:360:21
|
360 | impl pallet_assets::Config for Runtime {
| ^^^^^^ not found in `pallet_assets`
error: aborting due to previous error...
I tried with 'Trait' instead of Config, but throws even more errors...?
A hint would be much appreciated. Thanks
The Config trait was introduced in version 3.0.0 of substrate. As you pointed out, it was previously Trait. It is only expected for any substrate project to be compile-able if you use all of the same major version (2.x or 3.x) for building. I highly recommend using v3+ from now on, v2 is not expected to be supported moving forward.
I need HELP
I have two major errors in creating my first substraste chain (cf. https://substrate.dev/docs/en/tutorials/create-your-first-substrate-chain/setup)
Error in Installing the Front-End Template
~/Bureau/ETH-BIT/substrate/substrate-front-end-template$ ls LICENSE
package.json public README.md src yarn.lock
pclf#ubuntu:~/Bureau/ETH-BIT/substrate/substrate-front-end-template$
yarn install
ERROR: [Errno 2] No such file or directory: 'install'
Error in compiling Substrate
cargo build --release
error: failed to run custom build command for node-template-runtime v2.0.0 (/home/pclf/Bureau/ETH-BIT/substrate/substrate-node-template/runtime)
Caused by: process didn't exit successfully:
/home/pclf/Bureau/ETH-BIT/substrate/substrate-node-template/target/release/build/node-template-runtime-663c8dc25926c960/build-script-build
(exit code: 1) --- stdout Executing build command: "rustup" "run"
"nightly" "cargo" "rustc" "--target=wasm32-unknown-unknown"
"--manifest-path=/home/pclf/Bureau/ETH-BIT/substrate/substrate-node-template/target/release/wbuild/node-template-runtime/Cargo.toml" "--color=always" "--release"
--- stderr
Compiling wasm-build-runner-impl v1.0.0 (/home/pclf/Bureau/ETH-BIT/substrate/substrate-node-template/target/release/wbuild-runner/node-template-runtime4021631938540302808)
Finished release [optimized] target(s) in 7.49s
Running /home/pclf/Bureau/ETH-BIT/substrate/substrate-node-template/target/release/wbuild-runner/node-template-runtime4021631938540302808/target/x86_64-unknown-linux-gnu/release/wasm-build-runner-impl
Compiling sp-arithmetic v2.0.0
Compiling sp-io v2.0.0
Compiling sp-inherents v2.0.0
Compiling frame-metadata v12.0.0
Compiling sp-finality-tracker v2.0.0 error[E0282]: type annotations needed
--> /home/pclf/.cargo/registry/src/github.com-1ecc6299db9ec823/sp-arithmetic-2.0.0/src/fixed_point.rs:541:9
| 541 | let accuracy = P::ACCURACY.saturated_into();
| ^^^^^^^^ consider giving accuracy a type ... 1595 | / implement_fixed!( 1596 | | FixedI64,
1597 | | test_fixed_i64, 1598 | | i64, ... | 1601 | |
"Fixed Point 64 bits signed, range = [-9223372036.854775808,
9223372036.854775807]", 1602 | | );
| |__- in this macro invocation
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0282]: type annotations needed
--> /home/pclf/.cargo/registry/src/github.com-1ecc6299db9ec823/sp-arithmetic-2.0.0/src/fixed_point.rs:541:9
| 541 | let accuracy = P::ACCURACY.saturated_into();
| ^^^^^^^^ consider giving accuracy a type ... 1604 | / implement_fixed!( 1605 | | FixedI128,
1606 | | test_fixed_i128, 1607 | | i128, ... | 1611 |
| [-170141183460469231731.687303715884105728,
170141183460469231731.687303715884105727]_", 1612 | | );
| |__- in this macro invocation
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0282]: type annotations needed
--> /home/pclf/.cargo/registry/src/github.com-1ecc6299db9ec823/sp-arithmetic-2.0.0/src/fixed_point.rs:541:9
| 541 | let accuracy = P::ACCURACY.saturated_into();
| ^^^^^^^^ consider giving accuracy a type ... 1614 | / implement_fixed!( 1615 | | FixedU128,
1616 | | test_fixed_u128, 1617 | | u128, ... | 1621 |
| [0.000000000000000000,
340282366920938463463.374607431768211455]_", 1622 | | );
| |__- in this macro invocation
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 3 previous errors
For more information about this error, try rustc --explain E0282.
error: could not compile sp-arithmetic
error: build failed
You can just run yarn in the front end template directory, it will work. But where is the "Is LICENCE public" message coming from? You shouldn't see that. Did you clone the substrate-front-end-template repo or just create the directory? The exact process is:
clone it with git clone https://github.com/substrate-developer-hub/substrate-front-end-template
enter folder with cd substrate-front-end-template
run yarn
As for the Substrate compilation error, please downgrade your nightly to an older version, it happens due to a bug in Rust. Here is how to do that:
rustup uninstall nightly
rustup install nightly-2020-10-01
rustup target add wasm32-unknown-unknown --toolchain nightly-2020-10-01
First thing first solve the Substrate compiling first.
run this scrip
https://github.com/substrate-developer-hub/substrate-node-template/blob/master/scripts/init.sh
When you get the node up and running then start using frontend.
I am trying to build Boost library locally and want to use it as a local_repository in my own project. I am referring to this (https://github.com/nelhage/rules_boost) for help.
I have a directory tree like this:
boost/ // root of the boost project
|
bazel/
| |
| boost.bzl // contains "boost_library" function from https://github.com/nelhage/rules_boost/blob/master/boost/boost.bzl
| |
| BUILD // empty
boost/ // the original boost headers folder from original boost dist
|
lib/ // the original boost sources folder from original boost dist
|
BUILD
|
WORKSPACE
The BUILD file looks like this one:
https://github.com/nelhage/rules_boost/blob/master/BUILD.boost
with properly loading boost.bzl
The WORKSPACE is just:
workspace( name = "boost" )
The issue:
Now I am trying to build individual components (bazel build //:<component>).
Some of the components (Boost.Container, Boost.Test) are failing to build for a similar reason (not finding header files).
bazel build //:container 1 ↵
INFO: Found 1 target...
ERROR: /home/spyder/codebase/boost/BUILD:103:1: C++ compilation of rule '//:container' failed: Process exited with status 1 [sandboxed].
libs/container/src/global_resource.cpp:12:51: fatal error: boost/container/pmr/memory_resource.hpp: No such file or directory
compilation terminated.
Use --strategy=CppCompile=standalone to disable sandboxing for the failing actions.
Target //:container failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.519s, Critical Path: 0.18s
bazel build //:test 1 ↵
INFO: Found 1 target...
ERROR: /home/spyder/codebase/boost/BUILD:581:1: C++ compilation of rule '//:test' failed: Process exited with status 1 [sandboxed].
libs/test/src/junit_log_formatter.cpp:11:51: fatal error: boost/test/impl/junit_log_formatter.ipp: No such file or directory
compilation terminated.
Use --strategy=CppCompile=standalone to disable sandboxing for the failing actions.
Target //:test failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.027s, Critical Path: 0.82s
Can anyone guide me on fixing it ?
EDIT:
I also tried to query the expanded cc_library rule by bazel query --output=build //:container and got this
cc_library(
name = "container",
visibility = ["//visibility:public"],
generator_name = "container",
generator_function = "boost_library",
generator_location = "/home/spyder/codebase/boost/BUILD:103",
licenses = ["notice"],
deps = ["//:config", "//:core", "//:intrusive", "//:move"],
defines = [],
includes = ["boost/container/"],
copts = ["-Wno-unused-value"],
srcs = ["//:libs/container/src/alloc_lib.c", "//:libs/container/src/dlmalloc.cpp", "//:libs/container/src/dlmalloc_2_8_6.c", "//:libs/container/src/dlmalloc_ext_2_8_6.c", "//:libs/container/src/global_resource.cpp", "//:libs/container/src/monotonic_buffer_resource.cpp", "//:libs/container/src/pool_resource.cpp", "//:libs/container/src/synchronized_pool_resource.cpp", "//:libs/container/src/unsynchronized_pool_resource.cpp"],
hdrs = [ ....... , "//:boost/container/pmr/map.hpp", "//:boost/container/pmr/memory_resource.hpp", "//:boost/container/pmr/monotonic_buffer_resource.hpp", "//:boost/container/pmr/polymorphic_allocator.hpp", ........ ],
)
Very shockingly, the source file which is complaining (libs/container/src/global_resource.cpp) and the header that it is complaining about (boost/container/pmr/memory_resource.hpp) are both correctly included in the srcs and hdrs list.
I played with your rules a bit and the biggest problem I see is incomplete dependencies. For example I tried :algorithm component, and that needs to depend on :tuple. I guess you just needs to make sure all dependencies are set correctly.
I played more with container, and the problem I encountered was incorrect include dirs. If you run your build with -s flag, bazel will output all the command lines so you can inspect them and check that -isystem flags contain the directory that contains boost/container/... . What can also help you is the bazel flag --sandbox_debug, which will prevent the sandbox directory from being deleted so you can see which files are where and also you can reproduce the compiler invocation without running through bazel.
Last, bazel does not understand .ipp header extension yet (tbh I've never heard of it, but I also know next to nothing about boost). I have a change in flight that will introduce this.