昨天在升級substrate茵乱,問了大牛亮哥(https://mp.weixin.qq.com/s/pp7brVHizDu-a0S-qEe9bA)很多問題,今天來做個總結(jié)如何升級2.0
不在乎過程慕爬,可以直接翻到下面模板的github地址
1.0 生成
在產(chǎn)生新substrate模塊中
substrate-node-new substrate-node-template <author-name>
產(chǎn)生的節(jié)點是 1.0的目錄結(jié)構(gòu)是
1.1 修改
如果升級2.0窑眯,現(xiàn)在仍沒有詳細文檔, 最基本的模板在substrate的倉庫node-template里https://github.com/paritytech/substrate/blob/0c08276bdbeac2e0f9bf1a5bc91b04271460e652/node-template/Cargo.toml
但是直接復制來出錯医窿,因為cargo都是引用相對路徑的磅甩,這時只要改成git就好了。
以下是根目錄cargo.toml的代碼姥卢,可以直接復制以下代碼:
# 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"
基本上就把相對路徑化成git地址了卷要,
2.0新增了grandpa共識和新的功能,很多接口也變了地方了独榴,檢查很久才發(fā)現(xiàn)還在runtime多了一個生產(chǎn)wasm的build.rc文件
還有以下文件需要改
image.png
難道要貼代碼嗎僧叉?為了節(jié)省時間我把改好模板放到git上自己下載,是最新版的2.0改過來的棺榔,花了一整天
2.0 Git地址
直接clone就可以
https://github.com/skyh24/substrate-node20
另外就是把我的node名字改成自己的就OK
grep -r skystrate *
于是運行
cargo build
cargo run -- --dev
2.1 問題
改toml也慢慢試出rust排錯的方法瓶堕,可以嘗試其中substrate很多模板,自己在toml里面增加就可以
image.png
RLS好像可以自動查找定義模塊的定義症歇,必須在根目錄有toml郎笆,但是運行好慢,運行起來還會卡主其他cargo build進程忘晤,有沒有更好的工具求推薦
image.png
可以查到定義
image.png
Cargo這個工具好耗資源宛蚓,每次都要重新網(wǎng)上下載重新編譯,RLS也是设塔,這也是rust開發(fā)限制凄吏,cpu8核都像爆炸一樣,如果有國人做個可以復用包管理工具類似npm等的更好