Substrate常见问题

article/2025/8/26 11:24:05

目录标题

  • 1. Rust nightly not installed, please install it!
  • 2. Rust WASM toolchain not installed, please install it!
  • 3. use pallet::*出错
  • 4. failed to load manifest for workspace member
  • 5. error: failed to run custom build command for `node-template-runtime v4.0.0-dev
  • 6. 使用subkey生成公私钥
  • 7. duplicate definitions with name `is_soa`
  • 8. error[E0583]: file not found for module `sys`
  • 9. no method named `using_encoded` found for struct `SignedPayload` in the current scope
      • 该问题只需要runtime/src/lib.rs文件上方加:use codec::Encode;

1. Rust nightly not installed, please install it!

执行如下命令:

rustup update nightly

2. Rust WASM toolchain not installed, please install it!

 can't find crate for `std`

执行如下命令:

rustup target add wasm32-unknown-unknown --toolchain nightly

3. use pallet::*出错

在这里插入图片描述
cargo build后提示中有这样的信息

--- stderrCompiling pallet-strange v4.0.0-dev (/Users/xuanwenchao/Documents/projects/Rust/substrate/substrate-node-template/pallets/strange)error: Invalid usage of RuntimeEvent, `Config` contains no associated type `RuntimeEvent`, but enum `Event` is declared (in use of `#[pallet::event]`). An RuntimeEvent associated type must be declare on trait `Config`.

将这个全换成RuntimeEvent后,所有错误全部消失!

4. failed to load manifest for workspace member

error: failed to load manifest for workspace member `/Users/xuanwenchao/Documents/projects/Rust/substrate/substrate-node-template/node`Caused by:failed to load manifest for dependency `node-template-runtime`Caused by:failed to parse manifest at `/Users/xuanwenchao/Documents/projects/Rust/substrate/substrate-node-template/runtime/Cargo.toml`Caused by:could not parse input as TOMLCaused by:TOML parse error at line 43, column 1|43 | }| ^Could not parse the line

这个错误通常出现在 Cargo.toml 文件中引用的依赖不存在或者路径错误时。请确保依赖的名称和版本号正确,并且在您的 Cargo.toml 文件中使用了正确的路径。

5. error: failed to run custom build command for `node-template-runtime v4.0.0-dev

error: failed to run custom build command for node-template-runtime v4.0.0-dev (/Users/xuanwenchao/Documents/projects/Rust/substrate/substrate-node-template/runtime)
Caused by:
process didn’t exit successfully: /Users/xuanwenchao/Documents/projects/Rust/substrate-node-template/target/debug/build/node-template-runtime-e70130b014f78268/build-script-build (exit status: 101)

rustc --version
rustc 1.68.2 (9eb3afe9e 2023-03-27)
cargo --version
cargo 1.68.2 (6feb7c9cf 2023-03-26)
rustup +nightly show
Default host: aarch64-apple-darwin
rustup home:  /Users/xuanwenchao/.rustupinstalled toolchains
--------------------stable-aarch64-apple-darwin (default)
nightly-aarch64-apple-darwininstalled targets for active toolchain
--------------------------------------aarch64-apple-darwin
wasm32-unknown-unknownactive toolchain
----------------nightly-aarch64-apple-darwin (overridden by +toolchain on the command line)
rustc 1.70.0-nightly (9df3a39fb 2023-04-11)

执行以下命令、命名用nightly指定版本号

rustup default nightly-2023-01-01

再次执行cargo build后出现了新错误

  --- stderrRust WASM toolchain not installed, please install it!Further error information:------------------------------------------------------------Compiling wasm-test v1.0.0 (/var/folders/8z/hq_yvw055hg0rt8hkgt75ty00000gn/T/.tmpjVtHMb)error[E0463]: can't find crate for `std`|= note: the `wasm32-unknown-unknown` target may not be installed= help: consider downloading the target with `rustup target add wasm32-unknown-unknown`= help: consider building the standard library from source with `cargo build -Zbuild-std`error: requires `sized` lang_itemFor more information about this error, try `rustc --explain E0463`.

这个看提示就好解决了,重新安装wasm toolchain

rustup target add wasm32-unknown-unknown --toolchain nightly
cargo install wasm-bindgen-cli

6. 使用subkey生成公私钥

获取substrate代码

git clone https://github.com/paritytech/substrate.git

编译subkey模块

cargo build -p subkey --release

生成公私钥

./target/release/subkey generate

在这里插入图片描述

7. duplicate definitions with name is_soa

error[E0592]: duplicate definitions with name `is_soa`--> /Users/xuanwenchao/.cargo/registry/src/github.com-1ecc6299db9ec823/trust-dns-proto-0.22.0/src/rr/record_data.rs:55:17|
55  | #[derive(Debug, EnumAsInner, PartialEq, Clone, Eq)]|                 ^^^^^^^^^^^ duplicate definitions for `is_soa`
...
994 |     pub fn is_soa(&self) -> bool {|     ---------------------------- other definition for `is_soa`|= note: this error originates in the derive macro `EnumAsInner` (in Nightly builds, run with -Z macro-backtrace for more info)For more information about this error, try `rustc --explain E0592`.
error: could not compile `trust-dns-proto` due to previous error
warning: build failed, waiting for other jobs to finish...

先将新加的pallet从最外层的cargo.toml中移动确认是否可以编译通过
通常是因为添加依赖时的版本号不一致导致

[dependencies] 
codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive",
] }

8. error[E0583]: file not found for module sys

  error[E0583]: file not found for module `sys`--> /Users/xuanwenchao/.cargo/registry/src/github.com-1ecc6299db9ec823/errno-0.2.8/src/lib.rs:33:1|33 | mod sys;| ^^^^^^^^|= help: to create the module `sys`, create file "/Users/xuanwenchao/.cargo/registry/src/github.com-1ecc6299db9ec823/errno-0.2.8/src/sys.rs" or "/Users/xuanwenchao/.cargo/registry/src/github.com-1ecc6299db9ec823/errno-0.2.8/src/sys/mod.rs"error[E0425]: cannot find function `errno` in module `sys`--> /Users/xuanwenchao/.cargo/registry/src/github.com-1ecc6299db9ec823/errno-0.2.8/src/lib.rs:101:10|101 |     sys::errno()|          ^^^^^ not found in `sys`error[E0425]: cannot find function `set_errno` in module `sys`--> /Users/xuanwenchao/.cargo/registry/src/github.com-1ecc6299db9ec823/errno-0.2.8/src/lib.rs:106:10|106 |     sys::set_errno(err)|          ^^^^^^^^^ not found in `sys`Some errors have detailed explanations: E0425, E0583.For more information about an error, try `rustc --explain E0425`.

default-features = false没有加;

  sp-io = { version = "7.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }

9. no method named using_encoded found for struct SignedPayload in the current scope

error[E0599]: no method named using_encoded found for struct SignedPayload in the current scope
–> /Users/xuanwenchao/Documents/projects/Rust/substrate/substrate-node-template/runtime/src/lib.rs:304:37
|
304 | let signature = raw_payload.using_encoded(|payload| C::sign(payload, public))?;
| ^^^^^^^^^^^^^ method not found in SignedPayload<RuntimeCall, (CheckNonZeroSender<Runtime>, CheckSpecVersion<Runtime>, CheckTxVersion<Runtime>, CheckGenesis<Runtime>, CheckMortality<Runtime>, CheckNonce<Runtime>, CheckWeight<Runtime>, ChargeTransactionPayment<Runtime>)>

该问题只需要runtime/src/lib.rs文件上方加:use codec::Encode;


http://chatgpt.dhexx.cn/article/XUCml9Ym.shtml

相关文章

什么是 Substrate

如果你关注了 Polkadot 项目&#xff0c;可能会多次看到「Substrate」这个词。 它是 Polkadot 项目的重要组成部分&#xff0c;但有关它的信息非常少。 白皮书或黄皮书里找不到&#xff0c; 至少没有专门的介绍「Substrate」。 从较高的层面来看&#xff0c;Substrate 是一个可…

Substrate之旅3:Substrate是什么

Substrate 是从Polkadot 孵化出来的项目。它是一个用来搭建区块链的通用框架&#xff0c;具有以下特点&#xff1a; 可扩展。模块化。开源。 Substrate的框架与组件 框架 其中&#xff1a; P2P: libp2p网络协议&#xff0c;Substrate基于该协议实现了一个不带任何假设的&…

Substrate 基础 -- 教程(Tutorials)

官网 github DOC 面向未来的区块链框架 Substrate 使开发人员能够快速、轻松地构建适合任何用例的未来 证明区块链(future proof blockchains)。 Substrate 文档包括区块链构建器&#xff08;blockchain builders&#xff09;和parachain 项目团队的概念、过程和参考信息。…

【Android 逆向】substrate 框架 ( substrate 简介 | substrate 相关文档资料 )

文章目录 一、substrate 简介二、substrate 相关文档资料 一、substrate 简介 substrate 官网 : http://www.cydiasubstrate.com substrate 框架 是 Cydia 下的逆向工具 , 该框架是开源的 ; substrate 配合对应的 so 动态库 和 头文件 , 可以在 Android / iOS 平台中独立运行 …

ios tableView那些事(三)给tableView添加些图片

感觉光有数据的tableView很丑&#xff0c;那么我们就来美化下吧&#xff0c;加一些图片 #import <UIKit/UIKit.h> /*tableview 一定要用到这两个delegate UITableViewDataSource,UITableViewDelegate */ interface ViewController :UIViewController <UITableViewDa…

QT的TableView实现多级表头

QT的TableView实现多级表头 最近项目需要支持多级表头&#xff0c;QT本身不支持。可重写QHeaderView表头实现。 demo如下&#xff1a; FSItemDelegate.h #pragma once/* 自定义委托类 */ #include <QItemDelegate> #include <QSpinBox> #include <QDoubleSpin…

QML类型:TableView

一、描述 TableView 显示从内置 QML 类型&#xff08;如 ListModel 和 XmlListModel&#xff09;创建的模型中的数据&#xff0c;这些模型仅填充 TableView 中的第一列。要创建具有多列的模型&#xff0c;请使用 TableModel 或继承 QAbstractItemModel 的 C 模型。 TableView…

QML TableView表格使用示例

前言 QML中实现表格可以使用多种方式&#xff0c;比如直接使用ListView&#xff0c;定义每一行delegate&#xff0c;或者自定义Rectangle&#xff0c;放到Flipable中组合使用。Qt Quick Control1中 从5.1版本开始就提供了表格控件&#xff0c;但是感觉不怎么好用&#xff0c;在…

Qt TableView的简单使用

软件环境&#xff1a; ubuntu -------------------------------------------------------------------------------------------------------- 最终效果图&#xff1a; --------------------------------------------------------------------------------------------------…

PyQt5 TableView组件

一、话不多说&#xff0c;先看图 本次要实现的是主窗口内添加widget组件&#xff0c;widget内设置成垂直盒布局&#xff0c;然后在布局中添加tableView、PushButton组件 二、看main函数 if __name__ __main__:app QApplication(sys.argv)# 现在这创建 主窗口 &#xff08;不然…

优雅的开发TableView

前言 UITableView&#xff08;UITableViewController&#xff09;是iOS开发使用频率最高的一个组件。 不管是使用UITableView还是还是UITableViewController&#xff0c;在开发的时候&#xff0c;我们都需要实现两个协议&#xff1a; UITableViewControllerDataSourceUITabl…

JavaFX控件——TableView

在JavaFX 应用中对创建表格最重要的是TableView, TableColumn和TableCell这三个类。 你可以通过实现数据模型&#xff08;data model&#xff09; 和 实现 单元格工厂(cell factory) 来填充表格。 表格类提供了表格列嵌入式的排序能力和必要时调整列宽度的功能。 下面开始学…

ios开发:多个Section的TableView

开发多个Section的tableView。 首先应该考虑到数据源该如何得到 我们这里可以通过两种方式:第一种是读取plist文件。第二种是通过代码进行数据存储以及读取。 多个Section需要的数据源是一个字典&#xff0c;字典里的内容是一个数组。在plist文件中可以这样去创建 在.h文件中…

tableview概述

转自&#xff1a;http://www.cnblogs.com/smileEvday/archive/2012/06/28/tableView.html                 下面分9个方面进行介绍&#xff1a; 一、UITableView概述 UITableView继承自UIScrollView&#xff0c;可以表现为Plain和Grouped两种风格&#xff0c;分…

ios tableView那些事(一)创建一个简单的tableView

工作也有半年多了&#xff01;几乎每个项目中的会用到tableview这个神奇而好用的控件&#xff0c;在学习和工作中都会看别人的博客&#xff01;对我有很大的帮助&#xff0c;就如同站在巨人的肩膀上的感觉吧 哈哈&#xff01;于是决定重新开始写博客&#xff0c;希望能帮助像我…

JavaFX TableView和ListView的点击事件

项目场景&#xff1a; 最近在用JavaFX做一个简易的商城界面&#xff0c;大概想实现这样的功能&#xff1a; 左边显示用户的最近五个购买的产品 使用ListView 点击ListView的项目会定位到相应的tablerow位置 方便用户快速查找中间显示所有可用产品 使用TableView 双击tablerow…

JavaFX【TableView使用详解】

目录 概述 组件 Student ObservableList TableView setCellValueFactory() TableColumn 1. Callback 2. PropertyValueFactory 增加到末行 1、tableView.getItems().add(Student s) 2、list.add(Student s) 删除指定行 1、tableView.getItems().remove(int i) 2、…

QT中TableView数据展示

QT中TableView数据展示 最近在学习QT,大量数据从数据库取出放入QT界面中展示&#xff0c;这时用到了tableView&#xff0c;一些简单的使用分享给大家。 创建数据模型 QStandardItemModel *modelnew QStandardItemModel(); QStandardItemModel是Qt库中的一个类&#xff0c;它…

JAVAFX的TableView基本用法

JAVAFX中的表格显示主要使用TableView 与TableView相关的类: TableColumn TableRow TableCell TablePosition TableViewFocusModel TableViewSelectionModel JavaFX TableView例子: import javafx.application.Application; import javafx.scene.Scene; import javafx.scene…

QT之Tableview

想要了解更多的tableview可以看这位博客Qt深入浅出&#xff08;十五&#xff09;QTableView​ 这里做了一个简单的学生系统查询功能显示Tableview&#xff1a; 表格视图控件QTableView&#xff0c;需要和QStandardItemModel, 配套使用&#xff0c;这套框架是基于MVC设计模式设…