I'm trying to implement simple PoW for my node. After debugging all other stuff I've encountered the problem where finality-grandpa
and storage
do not get compiled because standard library macros are (for some reason) out of scope.
I've checked that std
features and enabled for all dependencies where they need to be enabled. Also I found this information about one of the dependencies. But as it's a non-local (pulled from github) I can't change that functionality.
Please note that I did not modify any of these two pallets (just imported my own, implementing PoW). Before that (on clear substrate-node-template which I use as a base for my project) those built without any problem.
The question is: How do I fix this? Should I enable std
for these crates somehow?
As far as I know, the node is built into native Rust and WASM, and for WASM it's built in no-std. By why did it build before in this case?
Here is a part of the error message I get:
cargo build --release
Updating crates.io index
Updating git repository `https://github.com/paritytech/substrate.git`
Updating git repository `https://github.com/paritytech/substrate`
Compiling node-template-runtime v4.0.0-dev (/home/creestl/programming/blockchain/crain/runtime)
error: failed to run custom build command for `node-template-runtime v4.0.0-dev (/home/creestl/programming/blockchain/crain/runtime)`
Caused by:
process didn't exit successfully: `/home/creestl/programming/blockchain/crain/target/release/build/node-template-runtime-d1d0301f1ce42478/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/creestl/programming/blockchain/crain/target/release/wbuild/node-template-runtime/Cargo.toml" "--color=always" "--profile" "release"
Using rustc version: rustc 1.62.0-nightly (de1bc0008 2022-04-21)
--- stderr
Compiling frame-support v4.0.0-dev (https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.18#fc3fd073)
Compiling sp-finality-grandpa v4.0.0-dev (https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.18#fc3fd073)
error: cannot find macro `format` in this scope
--> /home/creestl/.cargo/git/checkouts/substrate-7e08433d4c370a21/fc3fd07/primitives/finality-grandpa/src/lib.rs:43:2
|
43 | app_crypto!(ed25519, GRANDPA);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: consider importing one of these items:
alloc::format
scale_info::prelude::format
= note: this error originates in the macro `$crate::app_crypto_public_common_if_std` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: use of undeclared crate or module `std`
--> /home/creestl/.cargo/git/checkouts/substrate-7e08433d4c370a21/fc3fd07/primitives/finality-grandpa/src/lib.rs:43:2
|
43 | app_crypto!(ed25519, GRANDPA);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of undeclared crate or module `std`
|
= note: this error originates in the macro `$crate::app_crypto_public_common_if_std` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: use of undeclared type `String`
--> /home/creestl/.cargo/git/checkouts/substrate-7e08433d4c370a21/fc3fd07/primitives/finality-grandpa/src/lib.rs:43:2
|
43 | app_crypto!(ed25519, GRANDPA);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
|
= note: this error originates in the macro `$crate::app_crypto_public_common_if_std` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing one of these items
|
42 | use alloc::string::String;
|
42 | use codec::alloc::string::String;
|
42 | use scale_info::prelude::string::String;
|
And here is a link to the repo with my last changes