Yesterday in the upgrade of substrate2.0, asked Daniel Liangge wechat a lot of questions, today to make a summary of how to upgrade 2.0

Regardless of the process, go directly to the github address of the template below

1.0 to generate

In the substrate generation module

substrate-node-new substrate-node-template <author-name>
Copy the code

The resulting node is 1.0 and the directory structure is

1.1 to modify

If upgrade 2.0 is not fully documented, the most basic templates are available in Substrate’s warehouse node-template github.com/paritytech/…

But copying directly makes a mistake because cargo references relative paths, so you can just change it to git. Here is the code for the root directory, cargo. Toml, which can be copied directly:

# Cargo.toml
[package]
name = "skystrate-node"
version = "2.0.0"
authors = ["Skyh"]
build = "build.rs"
edition = "2018"

[profile.release]
panic = "unwind"

[[bin]]
name = "skystrate-node"
path = "src/main.rs"

[dependencies]
derive_more = "0.14.0"
futures = "0.1"
log = "0.4"
tokio = "0.1"
exit-future = "0.1"
parking_lot = "0.9.0"
trie-root = "0.15.2"
codec = { package = "parity-scale-codec", version = "1.0.0" }
ctrlc = { version = "3.0", features = ["termination"] }

sr-io = { git = "https://github.com/paritytech/substrate.git" }
substrate-cli = { git = "https://github.com/paritytech/substrate.git" }
substrate-client = { git = "https://github.com/paritytech/substrate.git" }
substrate-service = { git = "https://github.com/paritytech/substrate.git" }
substrate-executor = { git = "https://github.com/paritytech/substrate.git" }

network = { package = "substrate-network", git = "https://github.com/paritytech/substrate.git" }
inherents = { package = "substrate-inherents", git = "https://github.com/paritytech/substrate.git" }
basic-authorship = { package = "substrate-basic-authorship", git = "https://github.com/paritytech/substrate.git" }
transaction-pool = { package = "substrate-transaction-pool", git = "https://github.com/paritytech/substrate.git" }

primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate.git" }
babe = { package = "substrate-consensus-babe", git = "https://github.com/paritytech/substrate.git" }
grandpa = { package = "substrate-finality-grandpa", git = "https://github.com/paritytech/substrate.git" }
babe-primitives = { package = "substrate-consensus-babe-primitives", git = "https://github.com/paritytech/substrate.git" }
grandpa-primitives = { package = "substrate-finality-grandpa-primitives", git = "https://github.com/paritytech/substrate.git" }

skystrate-node-runtime = { path = "runtime" }

[build-dependencies]
vergen = "3"
Copy the code

Basically, the relative path to git address,

The grandpa consensus and new functionality have been added in 2.0, and many interface changes have been made. It was discovered that there is also a build.rc file that produces wASM in runtime and the following files need to be changed

Do I have to post code? In order to save time, I put the modified template on Git and downloaded it by myself. It was the latest version 2.0 and it took me a whole day

2.0 the Git address

Clone directly github.com/skyh24/subs…

Change my Node name to my own

grep -r skystrate *
Copy the code

Then run

cargo build

cargo run -- --dev
Copy the code

2.1 the problem

Toml is also slowly experimenting with rust troubleshooting methods. Try many substrates in the list and add them to TOML yourself

RLS seems to be able to automatically find the definition of the module. It must have tomL at the root, but it is slow and runs like cargo Build

You can look up the definition

Cargo is a drain on resources, it has to be re-downloaded and re-compiled every time, RLS is also a rust limitation, cpu8 cores are exploding, it would be nice if someone made a reusable package management tool like NPM etc