Giter VIP home page Giter VIP logo

substrate-node-template's Introduction

(Old) Substrate Developer Hub (ARCHIVED)

THIS SITE IS ARCHIVED.

This repository houses documentation for the Substrate blockchain framework.

The docs are written in markdown, processed by Docusaurus, and hosted at the Substrate Developer Hub.

Contributing

Thank you for your interest in contributing to the Developer Hub and to the larger Substrate community! Please review our contributor guidelines prior to any contribution. If you have any further questions, don't hesitate to reach out on our substrate technical community channel.

Directory Structure

This repository is structured as a Docusaurus project with the markdown files organized in the /docs directory. Images and other assets are in the /docs/assets/ directory. The /website directory is a Yarn Docusaurus project with many helpful scripts (e.g. yarn build, yarn start) for working with this codebase.  In the /website directory you will find sidebars.json and siteConfig.js, which are important Docusaurus files. You will find the source code for some top-level pages in /website/pages/en. Follow our contribution guidelines.

Adding a new document

To add a new markdown document:

  • Create your markdown document in a suitable directory inside /docs.
  • If you have images in your document, put them in the /docs/assets/ directory.
  • Documentation should follow our contribution guidelines.
  • If you want your document to appear in the sidebar, add its reference in the /website/sidebar.json file under the   corresponding section.

Rename an existing document

To rename an existing document:

  • Change the name or path of the document.
  • After the change has been merged, go to the Crowdin project,   make sure the translation is already migrated to the new file automatically for all the target languages.
  • Then go to Crowdin project settings, remove the   old source file in Files tab.
  • If you don't have access to the Crowdin project, please send email to [email protected] with the   file information you want to remove.

Local Testing

  • cd into the /website directory.
  • Execute yarn install and then yarn start.

The Substrate Developer Hub website should open in a browser window.

Link Checker

Once the website is running, you should use the included Yarn script (yarn check-links) to ensure that your changes do not introduce any broken links and to check for any links that have broken since the last time the check was executed. Please ensure all links are fixed before submitting any changes; if you have questions about broken links that you did not introduce, please create an Issue.

Once you are done with your changes, feel free to submit a PR.

Updates

There is a helper script that can be used to update substrate.dev/rustdocs links in the docs/knowledgebase directory.

# This examples demonstrates updating links from v2.0.0-rc3 to v2.0.0-rc4
OLD_VERSION=v2.0.0-rc3 NEW_VERSION=v2.0.0-rc4 ./scripts/update-kb-rustdocs

Production Deployment

Our production site is at substrate.dev. To deploy to production, merge your update into the source branch. This triggers the CI to build the website AND also pull in multilingual translation from our Crowdin project. The final built static site is then pushed to the master branch and hosted on GitHub Pages.

Staging Deployment

We have a staging deployment at devhub-maindocs.herokuapp.com, which is hosted on Heroku. Please check with the devhub team for the username and password to access the staging site.

To deploy to staging, you could push to the staging-source branch in the repository. This will trigger the CI to build the website, pull in multilingual translations from crowdin, and have the final built static site being pushed to staging branch. This in turn triggers Heroku to pick up the latest commit from staging branch and deploy to the staging site.

License

Substrate documentation is licenced under the Apache 2 license.

substrate-node-template's People

Contributors

alfellati avatar alvicsam avatar anderssorby avatar brunopgalvao avatar c410-f3r avatar cab404 avatar chenzongxiong avatar danforbes avatar dependabot[bot] avatar ffarall avatar h4n0 avatar hamidra avatar jamesbayly avatar jeluard avatar jingnanzhou avatar joshorndorff avatar kaichaosun avatar ltfschoen avatar mordamax avatar nuke-web3 avatar paritytech-ci avatar riusricardo avatar sacha-l avatar sameerdhoot avatar shawntabrizi avatar srslafazan avatar thiolliere avatar tripleight avatar vyorkin avatar xlc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

substrate-node-template's Issues

Accounts error

I installed Chain. "https://polkadot.js.org/apps/#/accounts" when I want to withdraw my accounts from this website "Uncaught error. Something went wrong with the query and rendering of this component. Cannot read property 'locks' of undefined "I'm getting this error.
There is no problem on other pages.

Substrate Node v2.0.0-alpha.7-e7f3167-x86_64-linux-gnu
api v1.14.0-beta.9
apps v0.42.0-beta.113

How to add pallet-identity

Question
How to add pallet-identity to node-template?
Please include information such as the following: is your question to clarify an existing resource
or are you asking about something new? what are you trying to accomplish? where have you looked for
answers?

Two different peer id, for single node.

I was going through the starting your own private network with https://www.substrate.io/tutorials/start-a-private-network/v2.0.0-rc2. I generated keys with subkey. Created chainspec, started node 1 and node2 . But node 2 failed with

Error: Service(Network(The same bootnode (`/ip4/127.0.0.1/tcp/30333`) is registered with two different peer ids: `QmYkKnqtB46sufgYSPUBCFUdYn8ipvZ1H8jSDzvpMjx6wp` and `QmYb6raWsGsw5rpncKW2iJUBTxP3SdFy8KzjofaEtBAiJy`))

Id QmYb6raWsGsw5rpncKW2iJUBTxP3SdFy8KzjofaEtBAiJy was printed in logs of node1. But using it as bootnode peer id for node2 failed. Using QmYkKnqtB46sufgYSPUBCFUdYn8ipvZ1H8jSDzvpMjx6wp worked and I was successfully able to complete it.

Why is node1 printing a peer id and using another peer one?

Interface mismatch in sp-io calling sp-sandbox

Problem

When adding the contracts crate as a dependency to this template, the sp-sandbox crate fails to compile.

Source

In the substrate revision that's currently referenced: 40a16efefc070faf5a25442bc3ae1d0ea2478eee

the sp-sandbox crate has an updated interface that takes a self primitives/sandbox/without_std.rs#L253

but the sp-io crate that calls sandbox is not updated to reflect that change (though it is at the current head of master).

Recommendation

Substrate-node-template may need to reference a newer revision where sp-io matches the sandbox interface.

first time install failed, error[E0282]: type annotations needed

Description

I did manage to install the node and run it together with the web front-end maybe 5 days ago. But when I started all over again I can't get it compiled. I did to reinstall rust and de-brew dependency modules but all in vain. Also tried with rustc 1.46, restarted mac, reinstalled cmake, openssl...
Attached is the log with the whole installation procedure.
subrtrate-install.log

Steps to Reproduce

following step by step Create Your First Substrate Chain

Environment

  • Operating system: MacOS, Kernel Version: Darwin 18.2.0
  • Template version/tag: v2.0.0
  • Rust version (run rustup show):
Default host: x86_64-apple-darwin
rustup home:  /Users/mario/.rustup

installed toolchains

stable-x86_64-apple-darwin (default)
nightly-x86_64-apple-darwin

active toolchain

stable-x86_64-apple-darwin (default)
rustc 1.47.0 (18bf6b4f0 2020-10-07)

Logs, Errors or Screenshots

...
   Compiling frame-support-procedural v2.0.0
   Compiling libp2p-core v0.22.1
error: failed to run custom build command for `node-template-runtime v2.0.0 (/Users/mario/projects/substrate-node-template/runtime)`

Caused by:
  process didn't exit successfully: `/Users/mario/projects/substrate-node-template/target/release/build/node-template-runtime-cae9ad6029c9f681/build-script-build` (exit code: 1)
  --- stdout
  Executing build command: "rustup" "run" "nightly" "cargo" "rustc" "--target=wasm32-unknown-unknown" "--manifest-path=/Users/mario/projects/substrate-node-template/target/release/wbuild/node-template-runtime/Cargo.toml" "--color=always" "--release"

  --- stderr
      Updating crates.io index
   Downloading crates ...
    Downloaded getrandom v0.1.15
    Downloaded substrate-wasm-builder v2.0.0

This error comes after random file and doesn't look connected with libp2p-core v0.22.1 in this case.
After continuing with compile it always breaks with following error:

...     
     Compiling sp-wasm-interface v2.0.0
     Compiling sp-arithmetic v2.0.0
     Compiling finality-grandpa v0.12.3
  error[E0282]: type annotations needed
      --> /Users/mario/.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)

Additional Information

Compile runtime hanges over ten mins

Question

When compiling node-template, The compiler stuck here for over 10 minutes without any output.

   Checking kvdb-rocksdb v0.9.0
    Checking sc-client-db v0.8.0-rc6 (https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186)
    Checking sc-service v0.8.0-rc6 (https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186)
    Checking sc-cli v0.8.0-rc6 (https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186)
    Building [=====================================================> ] 853/857: node-template-runtime(build)     

I have no idea how to deal with this situation, just wait ? or something else I can do. My local rust env is rustc 1.48.0-nightly (7f7a1cbfd 2020-09-27).

wasm-builder-runner cargo version

1.0.5 doesn't exist in a2512e83

sorry my bad, bad link. 1.0.5 exists in a2512e83 but

It looks like my cargo cargo 1.45.0-nightly (cb06cb269 2020-05-08) can't fetch the right commit. It alters between the two errors below depending on the version I put into Cargo.toml and cargo.lock.

cargo.lock ->

[[package]]
name = "substrate-wasm-builder-runner"
version = "1.0.5"
source = "git+https://github.com/paritytech/substrate.git#a2512e837003db3d3267764283edf31cf95a206c"

getting error after cargo clean

Updating git repository `https://github.com/paritytech/substrate.git`
error: failed to select a version for the requirement `substrate-wasm-builder-runner = "= 1.0.5"`
  candidate versions found which didn't match: 1.0.6
  location searched: Git repository https://github.com/paritytech/substrate.git
cargo build --release
error: failed to select a version for the requirement `substrate-wasm-builder-runner = "= 1.0.6"`
  candidate versions found which didn't match: 1.0.5
  location searched: Git repository https://github.com/paritytech/substrate.git#a2512e83

web3.eth.Contract API forces using 32-byte length return value even for `bytes` type

Description

I've been experimenting with precompiles, and I wrote a precompile that just returns "0xdeadbeef" for testing. Nothing special. I was looking for a way to call it in the tests, and I used the web3.eth.Contract API. Even though the return value in the ABI doesn't (seem to) require 32 bytes, the tests would crash if that size isn't in the returned.

Steps to Reproduce

Replace the example steps below with actual steps to reproduce the bug you're reporting.

  1. See the test: https://github.com/PureStake/moonbeam/blob/41b4461aa7e4fc2af9d7e26a9565915985cbd7c8/tests/tests/test-contract-precompiled.ts#L42
  2. See the precompiled implementation: https://github.com/PureStake/moonbeam/blob/41b4461aa7e4fc2af9d7e26a9565915985cbd7c8/runtime/src/lib.rs#L319
  3. Clone and checkout that commit 41b4461aa7e4fc2af9d7e26a9565915985cbd7c8
  4. Build
  5. Navigate to the tests directory
  6. Run the command npm install then: RUST_LOG=runtime=debug MOONBEAM_LOG='info,rpc=trace,evm=trace,ethereum=trace' npm test -- -g precompiled
  7. The test will work fine now.
  8. Remove the padding loop shown here then build again: https://github.com/PureStake/moonbeam/blob/41b4461aa7e4fc2af9d7e26a9565915985cbd7c8/runtime/src/lib.rs#L330
  9. Run the test again, and you'll get an out-of-bound error

Conclusion: The test will fail if the return value length is < 32 bytes

Expected vs. Actual Behavior

It should work without padding, especially that the return value isn't byte32.

Environment

Describe the environment in which you encountered this bug. Use the list below as a starting point
and add additional information if you think it's relevant.

  • Operating system: Ubuntu 18.04
  • Template version/tag: Commit: 41b4461aa7e4fc2af9d7e26a9565915985cbd7c8 in moonbeam repo
  • Rust version (run rustup show): 1.47.0-nightly

Logs, Errors or Screenshots

Please provide the text of any logs or errors that you experienced; if
applicable, provide screenshots to help illustrate the problem.

Additional Information

Now I understand this is not the right way to call a precompile (I changed it to eth_call in later commits), but still, this is a bug (apparently) in the contract API of RPC.

build-only-wasm script

The main substrate node has a script to build just the runtime wasm.

It is useful for doing runtime upgrades. It would be nice to have that script here too. One way to do that would be to add it to the node-template in the main Substrate repo.

Allow bootnodes to connect without specifying peer-id?

I note the following under a 2018 PR -

Allow bootnodes as IP:PORT, query Peer-id
paritytech/substrate#386

The PR suggests that Substrate should be able to connect to nodes without specifying peer-id (ie --bootnodes /ip4/127.0.0.1/tcp/30333/p2p), with the peer-id being requested during initial connection. Am I misunderstanding something here? As of today, Substrate still appears to require multiaddr specifying peer-id -

... --bootnodes /ip4/127.0.0.1/tcp/30333/p2p
error: Invalid value for '--bootnodes ...': invalid protocol string

There are no certificate authorities tying IP addresses to cryptographic identities etc.. so, just trying to understand the rationale here? This should not apply to PoW chains for example.

Is there block minting rewards pallet?

Hi guys,
I am trying to adding block minting reward function to my own chain, I am using the default staking pallet like this:

pallet_staking_reward_curve::build! {
	const REWARD_CURVE: PiecewiseLinear<'static> = curve!(
		min_inflation: 0_025_000,
		max_inflation: 0_100_000,
		ideal_stake: 0_500_000,
		falloff: 0_050_000,
		max_piece_count: 40,
		test_precision: 0_005_000,
	);
}

parameter_types! {
	// Six sessions in an era (6 sessions).
	pub const SessionsPerEra: SessionIndex = 6;
	// 28 eras for unbonding (7 days).
	pub const BondingDuration: staking::EraIndex = 28;
	// 28 eras in which slashes can be cancelled (7 days).
	pub const SlashDeferDuration: staking::EraIndex = 28;
	pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
}

/* snippet */

impl staking::Trait for Runtime {
	type Currency = Balances;
	type Time = Timestamp;

	type CurrencyToVote = CurrencyToVoteHandler;
	type RewardRemainder = Treasury;
	type Event = Event;
	type Slash = Treasury;
	type Reward = ();
	type SessionsPerEra = SessionsPerEra;
	type BondingDuration = BondingDuration;
	type SlashDeferDuration = SlashDeferDuration;

	// A majority of the council can cancel the slash.
	// TODO: add slash cancellation via collective pallet
	type SlashCancelOrigin = collective::EnsureProportionAtLeast<_1, _2, AccountId, CouncilCollective>;
	type SessionInterface = Self;
	type RewardCurve = RewardCurve;
}

and my chain constants are:

1 session = 10 block, 1 era = 2 session (for test)

But I found there has no block rewards in the end of each era. Am I writing the right way? or should I import more pallet?

upload contracts fail

I run my local private network.
When i use the builtin Alice and Bob to start the two nodes network. Upload the Contract wasm file is OK. The contract can be called normally. But when I use the <subkey --sr25519 generate > keys to boot a local two nodes network. when I am uploading the contract wasm file it failed. and say: invalid. why? Did someone knows what happened?

Error with latest Apps UI

The latest Polkadot Js Apps UI c5a85676 gives the error DRR: TypeError: "api.query.democracy is undefined" when connected to the node template. This may be solved by updating to a more recent Substrate upstream (further testing needed).

node 12

Suggestion for https://substrate.dev/docs/en/tutorials/creating-your-first-substrate-chain

sudo npm cache clean -f
sudo npm install -g n
sudo n v11.15.0
sudo npm install -g npm
node --version; npm --version

v11.15.0
6.13.0

had also tried

sudo n stable
node --version

v12.13.0

but that resulted in

substrate-ui-new substrate

failing to build, because blake2js ELIFECYCLE.

With node v11.15.0 it runs through just fine. It's from April 2019.

Panic: 'cannot access native cert store: Custom'

I'm trying to run substrate on my local machine and I'm trying it using this tutorial: https://substrate.dev/docs/en/tutorials/creating-your-first-substrate-chain

But after I have ran this commend:

./target/release/node-template --dev

I've got the error:

2020-04-02 10:29:08 Running in --dev mode, RPC CORS has been disabled.
2020-04-02 10:29:08 Substrate Node
2020-04-02 10:29:08   version 2.0.0-alpha.3-5b41f0b-x86_64-macos
2020-04-02 10:29:08   by Anonymous, 2017-2020
2020-04-02 10:29:08 Chain specification: Development
2020-04-02 10:29:08 Node name: elite-rain-5518
2020-04-02 10:29:08 Roles: AUTHORITY
2020-04-02 10:29:08 Initializing Genesis block/state (state: 0xf711…370f, header-hash: 0x884e…0f3b)
2020-04-02 10:29:08 Loading GRANDPA authority set from genesis on what appears to be first startup.
2020-04-02 10:29:08 Loaded block-time = 6000 milliseconds from genesis on first-launch
2020-04-02 10:29:08 Highest known block at #0
2020-04-02 10:29:08 Using default protocol ID "sup" because none is configured in the chain specs
2020-04-02 10:29:08 Local node identity is: QmWmRvRTBRZbaAQ2CMQJ48k6fdPzsyFZg2pr5eEFn3obUo
2020-04-02 10:29:09 Prometheus server started at 127.0.0.1:9615
2020-04-02 10:29:12 Starting consensus session on top of parent 0x884e4d3fd018d749c02122e7bd8f2684a51712149b6feabbcff6c54ec9970f3b
2020-04-02 10:29:12 Prepared block for proposing at 1 [hash: 0x8833f9556f283c44a270cdf62bc6658ea462ac3fa1107f12172c65c2dce97bc6; parent_hash: 0x884e…0f3b; extrinsics (1): [0xdb0d…4fc9]]
2020-04-02 10:29:12 Pre-sealed block for proposal at 1. Hash now 0xa163659df65684f40f8a50bf7016c6db8c91c17d0571021c701b63ae06900bc0, previously 0x8833f9556f283c44a270cdf62bc6658ea462ac3fa1107f12172c65c2dce97bc6.
2020-04-02 10:29:12 Imported #1 (0xa163…0bc0)

====================

Version: 2.0.0-alpha.3-5b41f0b-x86_64-macos

   0: backtrace::backtrace::trace
   1: backtrace::capture::Backtrace::new
   2: sp_panic_handler::set::{{closure}}
   3: std::panicking::rust_panic_with_hook
   4: rust_begin_unwind
   5: core::panicking::panic_fmt
   6: core::option::expect_none_failed
   7: hyper_rustls::connector::HttpsConnector<hyper::client::connect::http::HttpConnector>::new
   8: sc_offchain::api::http::http
   9: sc_offchain::OffchainWorkers<Client,Storage,Block>::on_block_imported
  10: futures_util::future::future::FutureExt::poll_unpin
  11: <futures_util::future::select::Select<A,B> as core::future::future::Future>::poll
  12: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
  13: tokio::task::core::Core<T>::poll
  14: std::panicking::try::do_call
  15: __rust_maybe_catch_panic
  16: tokio::task::harness::Harness<T,S>::poll
  17: tokio::runtime::thread_pool::worker::GenerationGuard::run_task
  18: tokio::runtime::thread_pool::worker::GenerationGuard::run
  19: std::thread::local::LocalKey<T>::with
  20: tokio::runtime::thread_pool::worker::Worker::run
  21: tokio::task::core::Core<T>::poll
  22: std::panicking::try::do_call
  23: __rust_maybe_catch_panic
  24: tokio::task::harness::Harness<T,S>::poll
  25: tokio::runtime::blocking::pool::Inner::run
  26: tokio::runtime::context::enter
  27: std::sys_common::backtrace::__rust_begin_short_backtrace
  28: std::panicking::try::do_call
  29: __rust_maybe_catch_panic
  30: core::ops::function::FnOnce::call_once{{vtable.shim}}
  31: <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once
  32: std::sys::unix::thread::Thread::new::thread_start
  33: _pthread_body
  34: _pthread_start


Thread 'main-tokio-' panicked at 'cannot access native cert store: Custom { kind: InvalidData, error: BadDER }', /Users/test/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-rustls-0.19.1/src/connector.rs:36

This repo takes forever to clone

When doing a fresh clone of this repo, the download takes a very long time. I believe this is because at one point there was a large binary file committed to the repo and it is still in the history.

We should solve this to lower friction for new template users.

sccache: error: Server startup failed: Address already in use (os error 98)

Hi, I just cloned the repository, and from master branch, when I try to run the docker container I get:

$ ./scripts/docker_run.sh
*** Start Substrate node template ***
Removing network aquila-validator-node_default
Creating network "aquila-validator-node_default" with the default driver
   Compiling autocfg v1.0.0
   Compiling lazy_static v1.4.0
   Compiling smallvec v1.4.1
   Compiling typenum v1.12.0
   Compiling getrandom v0.1.14
   Compiling memchr v2.3.3
sccache: error: Server startup failed: Address already in use (os error 98)
sccache: error: Server startup failed: Address already in use (os error 98)
error: could not compile `smallvec`.

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
sccache: error: Server startup failed: Address already in use (os error 98)
sccache: error: Server startup failed: Address already in use (os error 98)
sccache: error: Server startup failed: Address already in use (os error 98)
error: build failed

error: could not compile `frame-support`

I follow the tutorial at create-your-first-substrate-chain

When I ran cargo build --release , some errors happened as follow. My computer was macOs 10.14.3.

   Compiling frame-support v2.0.0-alpha.8 (https://github.com/paritytech/substrate.git?tag=v2.0.0-alpha.8#7e9a2ae7)
error[E0424]: expected value, found module `self`
   --> /Users/duval/.cargo/git/checkouts/substrate-7e08433d4c370a21/7e9a2ae/frame/support/src/traits.rs:903:11
    |
901 | / bitmask! {
902 | |     /// Reasons for moving funds out of an account.
903 | |     #[derive(Encode, Decode)]
    | |              ^^^^^^ `self` value is a keyword only available in methods with a `self` parameter
904 | |     pub mask WithdrawReasons: i8  where
...   |
919 | |     }
920 | | }
    | |_- this function has a `self` parameter, but a macro invocation can only access identifiers it receives from parameters
    |
    = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

For more information about this error, try `rustc --explain E0424`.
error: could not compile `frame-support`.

To learn more, run the command again with --verbose.

warning: build failed, waiting for other jobs to finish...
error: build failed

impl_name: create_runtime_str!("demo-node"),

in this tutorial https://substrate.dev/docs/en/tutorials/creating-your-first-substrate-chain
it says:

you can see at the top of the Substrate UI that the Runtime will have our updated name!

which will not happen with the suggested "complete version of this file"

Screenshot from 2019-11-17 10-56-05

unless you change these lines

https://github.com/substrate-developer-hub/substrate-package/blob/8d319c899395f6935a9b95250660f8b28f578a2a/substrate-node-template/runtime/src/lib.rs#L94-L95

to something different:

	spec_name: create_runtime_str!("DEMO"),
	impl_name: create_runtime_str!("DEMO-node"),

then the top will look like this:

Screenshot from 2019-11-17 11-00-27

Adding utils scripts for node-template

The reason is that I think:

  • "Renaming the Project Name" is a common feature that will be used. I also have that struggle before. Will be good to have a script to do that.
  • "Adding a Pallet" script, I am struggling with this. The pro side is it helps ppl easily add a default simple pallet. But it also hides the complexity that if they need further configuration, as they do need to do it at different places - runtime/lib.rs for more configurable trait, chain_spec for genesis config, etc.

And I don't mind it as javascript as well (this also make it cross-platform). We just need to document it well the env required and instructions to run these scripts.

So I open this issue and want to discuss this with you all @danforbes @riusricardo @wheresaddie (if we all feel yes, I also want to get some comments from 1-2 core-devs about this)

A question arise on how to do this automatically for release in future: I am thinking we may need a simple release script to grab whatever latest substrate/substrate-node-template content, and then pulling from another repo of these utils scripts and push to devhub/node-template repo for release.

Ref:

failed to run custom build command for `node-template-runtime v2.0.0-rc6

Failed to execute command: cargo build --release

_➜ substrate-node-template git:(fcd577e) cargo build --release
Compiling node-template-runtime v2.0.0-rc6 (/Users/luobin/project/substrate-node-template/runtime)
Compiling bindgen v0.53.3
Compiling parity-scale-codec v1.3.4
Compiling snow v0.7.1
Compiling web-sys v0.3.42
Compiling cranelift-codegen v0.66.0
Compiling wasm-bindgen-futures v0.4.15
Compiling frame-support-procedural v2.0.0-rc6 (https://github.com/paritytech/substrate.git?tag=v2.0.0-rc6#be8bb186)
Compiling tiny-bip39 v0.7.3
Compiling jsonrpc-client-transports v14.2.0
Compiling linregress v0.1.7
Compiling jsonrpc-server-utils v14.2.0
Compiling hyper v0.12.35
Compiling hyper-rustls v0.21.0
error: failed to run custom build command for node-template-runtime v2.0.0-rc6 (/Users/luobin/project/substrate-node-template/runtime)

Caused by:
process didn't exit successfully: ~/project/substrate-node-template/target/release/build/node-template-runtime-833ee7d7fff70513/build-script-build (exit code: 1)
--- stderr
Compiling wasm-build-runner-impl v1.0.0 (/~/project/substrate-node-template/target/release/wbuild-runner/node-template-runtime374117483696389994)
Finished release [optimized] target(s) in 1.35s
Running ~/project/substrate-node-template/target/release/wbuild-runner/node-template-runtime374117483696389994/target/x86_64-apple-darwin/release/wasm-build-runner-impl
Rust WASM toolchain not installed, please install it!
warning: build failed, waiting for other jobs to finish...
error: build failed

Clone the Node Template (version v2.0.0-rc6+1)
_

using canonical Python requests --> {"code":-32700,"message":"Parse error"}

Perhaps this should be submitted to the main paritytech/substrate repo? Or where else?

RPC flawed when using Python?

Adapting this tutorial to Python, this -very standard approach- is not working:

payload = {"method": "state_getMetadata", "id":"1", "jsonrpc":"2.0"}
url = "https://dev-node.substrate.dev:9933/"
r = requests.post(url, data=payload, headers = {"Content-Type" : "application/json"})
print (r.status_code, r.text)

Have a look at these 3 slightly different attempts:

python3 substrate_RPC-flaw.py 
All working on dev-node:  https://dev-node.substrate.dev:9933/ 

Passing a dict as data payload:
payload: {'id': '1', 'method': 'state_getMetadata', 'jsonrpc': '2.0'}
200 {"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error"},"id":null}

Turning the dict into a string first:
payload_string: {'id': '1', 'method': 'state_getMetadata', 'jsonrpc': '2.0'}
200 {"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error"},"id":null}

Manipulating that string to make substrate happy:
payload_string_manipulated: {"id": "1", "method": "state_getMetadata", "jsonrpc": "2.0"}
200 {'id': '1', 'result': '0x6d65746108601853797374656d01...', 'jsonrpc': '2.0'}

THAT took a LONG time to find. Almost proud that I eventually found it ;-)

You can replicate it with this code:

import requests # pip install requests

url = "https://dev-node.substrate.dev:9933/"
print ("All working on dev-node: ", url, "\n")

headers = {"Content-Type" : "application/json"}
payload = {"method": "state_getMetadata", "id":"1", "jsonrpc":"2.0"}

print ("Passing a dict as data payload:")
print ("payload:", payload)
r = requests.post(url, data=payload, headers=headers)
print (r.status_code, r.text)

print ("Turning the dict into a string first:")
payload_string = "%s" % payload
print ("payload_string:", payload_string)
r = requests.post(url, data=payload_string, headers=headers)
print (r.status_code, r.text)

print ("Manipulating that string to make substrate happy:")
payload_string_manipulated = payload_string.replace("'", '"')
print ("payload_string_manipulated:", payload_string_manipulated)
r = requests.post(url, data=payload_string_manipulated, headers=headers)
rj = r.json()
rj['result'] = rj['result'][:30] + "..."
print (r.status_code, rj)

You need that library:

pip3 install requests
python3 substrate_RPC-flaw.py 

Node Template not Compiling on Windows Following Official Tutorial

Hi, a friend of mine attempted to setup and build the substrate node template on Windows 10 following the official tutorial in preparation for the Hackusama hackathon.

He ended up getting this error during the process

error: failed to run custom build command for node-template-runtime v2.0.0-rc4 (C:\Users\jdurr\AppData\Roaming\SPB_16.6\substrate-node-template\runtime)

Caused by:
process didn't exit successfully: C:\Users\jdurr\AppData\Roaming\SPB_16.6\substrate-node-template\target\release\build\node-template-runtime-d6e898ad2ca934e3\build-script-build (exit code: 1)
--- stderr
Compiling winapi v0.3.9
error: failed to write C:\Users\jdurr\AppData\Roaming\SPB_16.6\substrate-node-template\target\release\wbuild-runner\node-template-runtime3267355145636852925\target\x86_64-pc-windows-msvc\release.fingerprint\winapi-2db33ecc220f2cd2\run-build-script-build_script_build-2db33ecc220f2cd2

Caused by:
The system cannot find the path specified. (os error 3)

warning: build failed, waiting for other jobs to finish...
error: build failed

We know what the error implies that there is an issue with his build environment but were unable to figure out how to fix it. Has anyone else run into this issue before and if so, how did you fix it?

cant compile anymore

since yesterday compiling the template on macos does not seem to compute anymore:

error[E0424]: expected value, found module `self`
   --> /Users/m/.cargo/git/checkouts/substrate-7e08433d4c370a21/45b9f0a/frame/support/src/traits.rs:913:11
    |
911 | / bitmask! {
912 | |     /// Reasons for moving funds out of an account.
913 | |     #[derive(Encode, Decode)]
    | |              ^^^^^^ `self` value is a keyword only available in methods with a `self` parameter
914 | |     pub mask WithdrawReasons: i8 where
...   |
929 | |     }
930 | | }
    | |_- this function has a `self` parameter, but a macro invocation can only access identifiers it receives from parameters
    |
    = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

For more information about this error, try `rustc --explain E0424`.
error: could not compile `frame-support`.

To learn more, run the command again with --verbose.

warning: build failed, waiting for other jobs to finish...
error: build failed

for some reason even going back to alpha 8 or 6 does not seem to make rustc happy anymore.
already tried separate machines, fresh pull, cleaning cache etc.

any ideas?

Transactions in orphaned blocks are not being replayed after re-org

The below testing was performed with utxo-workshop (a PoW chain), however, Joshy has also confirmed similar behaviour in the node template (Aura).

I wanted to test that transactions in orphaned blocks will indeed be replayed after re-orgs. Under re-org conditions, the assumed behaviour was that nodes will notice and repopulate the transaction mempool with any transactions that were previously in the shorter chain, but missing in the new longer (re-orged) chain. It would then re-broadcast them on the new fork.

Testing as follows (utxo-workshop, PoW) -

  • Launch 2 x nodes, they're in PoW consensus
  • Disconnecting/isolating them (docker network disconnect bridge xxxx)
  • wait for one of the nodes to have a significantly smaller chain and executing the utxo extrinsic spend on it only (tx 0xdbc75ab8ee9b83dcbcea4695f9c42754d94e92c3c397d63b1bc627c2a2ef94e6 as per https://github.com/substrate-developer-hub/utxo-workshop )
  • reconnect the 2 nodes, triggering the reorg to longer chain (which does not above tx)
  • the tx does not appear to be re-broadcasted and it never hits the new longer chain

Joshy has also tested this with 2 x node-template nodes by intermittently terminating each node, allowing one to extend further, bringing them both back online, allowing them to come to consensus on the longer chain - https://www.twitch.tv/videos/736038706 . I don't have a lot of experience with Aura, however, it appears the behaviour may be similar.

Perhaps I have misunderstood something or am doing something wrong. Regardless, transaction replay should work under the simple conditions I have described. This behaviour is important for any type of blockchain, regardless of consensus rules. Indeed, this is how Bitcoin behaves. Bitcoin will retain transactions for a period of time after many block confirmations on the off chance of a long re-org. This is important for PoW chains as there is no concept of a hard 'finality', with confidence rather being found due to probability as the chain is extended. Retaining and replaying transactions is particularly important for minority hash chains such as ETC (although bigger fundamental problems still apply ;) ).

I cannot comment too much on PoA, however, even PoA may break down under super-majority dishonest authority behaviour. In some scenarios re-orgs might be expected. Users should not have resubmit extrinsics. Nodes in the wild don't always play nice.

Environment
Ubuntu 20, utxo-workshop RC6, rustc 1.45.2

Self-authored blocks use partial import queue

Because of an upstream bug that exists when the rc6 node template was cut, when a node authors a block, it only passes that block through part of the import queue (the grandpa part, but not the aura part). That bug was fixed upstream paritytech/substrate#7014

Typically new node templates are cut only when new upstream versions are tagged, but in this case, because we have a user-facing bug in the codebase and it will be copied into each new template fork, I recommend we cut a new release right away. Perhaps it could be called v2.0.0-rc6+1.

PoE tutorial should support parachain template?

This issue is to consider and possibly implement changes to the PoE tutorial so that it can be applied to the parachain template as well as the node template. Because the two templates are structured so similarly, I suspect it will take very little wording changes and little confusion. Of course if this is not the case, we don't need to do it.

Renameing the template results in an error

I'm renameing the template using search and replace. After renaming extrinsics are not working anymore. The following error occures:
WARN sc_rpc::author Failed to submit extrinsic: Extrinsic verification error: Execution: Could not convert parameter `tx` between node and runtime: No such variant in enum MultiSignature
What did I do wrong?

What commands to build the node template?

I'm trying to build the node template. I checkout the latest code on master (5dc7853) and run cargo check. It fails with

  Rust WASM toolchain not installed, please install it!

  Further error information:
  ------------------------------------------------------------
     Compiling wasm-test v1.0.0 (/tmp/.tmpEGpa1b)
  error[E0463]: can't find crate for `std`
    |
    = note: the `wasm32-unknown-unknown` target may not be installed

  error: aborting due to previous error

  For more information about this error, try `rustc --explain E0463`.
  error: could not compile `wasm-test`

  To learn more, run the command again with --verbose.
  ------------------------------------------------------------

warning: build failed, waiting for other jobs to finish...

I also tried cargo build --release as suggested in the readme, but it fails with the less verbose

Rust WASM toolchain not installed, please install it!
warning: build failed, waiting for other jobs to finish...
error: build failed

I suspect this is related to #92 , but not sure.

zsh: no such file or directory: ./target/release/node-template

Question

I am trying to follow the Create Your First Substrate Chain Tutorial. I have successfully done all the steps with a small workaround for macOS suggested at Issue #85. Unfortunately the suggested workaround didn't work for nightly-2020-08-23 so I instead used nightly-2020-05-15.

After the compilation was successful without any errors, I tried to run a temporary dev node with the command:
./target/release/node-template --dev --tmp

I executed the command within the substrate-node-template folder and it seems like node-template is missing in the release directory getting the following error:
zsh: no such file or directory: ./target/release/node-template

Would be great if someone could help me out with this issue.
Thanks!

All template forks start with failing CI job

The node template is meant to be forked and turned into application specific blockchains.

Because this repo has a ci job that publishes a docker image (for the Substrate playground to use) so does every fork of this repo. None of the forks have the credentials to push the docker image, so the ci fails. The result is that every newly-forked node-template has a red ❌ .

"Blocking waiting for file lock on package cache" message when intializing node

cargo run -- --base-path /tmp/alice --chain=local --alice --node-key 0000000000000000000000000000000000000000000000000000000000000001 --telemetry-url ws://telemetry.polkadot.io:1024 --validator

While running above command. I'm getting "Blocking waiting for file lock on package cache". I have tried "crate clean" but no help. Can someone point on cause for this issue and solution?

 Compile error in building template: type annotation needed

When trying to compile the substrate node template the following error occurred:

Compiling sp-runtime-interface v2.0.0
error[E0282]: type annotations needed
--> /Users/wardline/.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)

Environment

_MacOS 10.15 Imac Pro
Default host: x86_64-apple-darwin
rustup home: /Users/wardline/.rustup

installed toolchains

stable-x86_64-apple-darwin (default)
nightly-x86_64-apple-darwin

active toolchain

stable-x86_64-apple-darwin (default)
rustc 1.47.0 (18bf6b4f0 2020-10-07)

I unsuccessfully tried cloning older versions of the template to see if this resolved the error.

mv: cannot move 'substrate-node-template' to a subdirectory of itself, 'substrate-node-template/substrate-node-template'

either the flaw is in the tutorial or in the script.

On this page https://substrate.dev/docs/en/tutorials/creating-your-first-substrate-chain
When doing this:

substrate-node-new substrate-node-template <author-name>
substrate-ui-new substrate

I see this error:

substrate-node-new substrate-node-template myname

  Substrate Node Template Setup 
  Downloading project...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 71537  100 71537    0     0   236k      0 --:--:-- --:--:-- --:--:--  236k
mv: cannot move 'substrate-node-template' to a subdirectory of itself, 'substrate-node-template/substrate-node-template'
Customizing project...
Initializing repository...
Initializing WebAssembly build environment...

versions:

substrate --version; subkey --version
substrate 2.0.0-dc16bac5e-x86_64-linux-gnu
subkey 2.0.0

Please also add a --version to the scripts; but with the hash you can probably identify which version I have, no?

substrate-node-new --version
  Substrate Node Template Setup 
  Usage: substrate-node-new <NAME> <AUTHOR>

sha256sum substrate-node-new
3d92bcbbd5f2e3d8517de121a2c4babec1b68232138187d38e11fd039b7b8fa2  substrate-node-new

docker-compose has "exec format error"

$ ./scripts/docker_run.sh
*** Start Substrate node template ***
Removing substrate-node-template_dev_run_6519c3d98f54 ... done
Removing node-template ... done
Removing substrate-node-template_dev_run_6e5476f0e5e3 ... done
Removing substrate-node-template_dev_run_a6ac63c25e50 ... done
Removing network substrate-node-template_default
Creating network "substrate-node-template_default" with the default driver
Creating substrate-node-template_dev_run ... done
standard_init_linux.go:211: exec user process caused "exec format error"

how can i solve this problem?

Node Template that pays Block Author

Hi, Ive successfully been able to activate fees by looking at substrate repo by creating the DealWithFees struct and implementing OnUnbalanced for DealWithFees , OnTransactionPayment.

I am now trying to pay the Block Author. However I am unsure on how I can identify the block author in Aura. Do i require the authority_discovery pallet? Does this work with Aura? Are their any examples I can look at to follow?

Code Snippet


pub struct DealWithFees;
impl OnUnbalanced<NegativeImbalance> for DealWithFees {
    fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {
        if let Some(fees) = fees_then_tips.next() {
            // for fees 80-20 split 
            let mut split = fees.ration(80, 20);
            if let Some(tips) = fees_then_tips.next() {
                // for tips, if any, 80-20 split 
                tips.ration_merge_into(80, 20, &mut split);
            }
            // Currently all fees 80% and 20% is paid to burner
            // TODO: Ideally 80% goes to the Block Author 
            Burner::on_nonzero_unbalanced(split.0);
            Burner::on_nonzero_unbalanced(split.1);
        }
    }
}


no node_runtime.compact.wasm but substrate_node_template_runtime_wasm.compact.wasm

In this tutorial https://substrate.dev/docs/en/tutorials/creating-your-first-substrate-chain

it says

If this completes successfully, it will update the file: ./runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm. You can go back to the Substrate UI, and in the Runtime Upgrade section, you can select this file and press upgrade.

but the filename after scripts/build.sh is slightly different; I suppose these are the files

ls  runtime/wasm/target/wasm32-unknown-unknown/release/*.wasm

runtime/wasm/target/wasm32-unknown-unknown/release/substrate_node_template_runtime_wasm.compact.wasm  runtime/wasm/target/wasm32-unknown-unknown/release/substrate_node_template_runtime_wasm.wasm

?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.