您正在查看: Surou 发布的文章

wsl: 无法配置 networkingMode Nat) (网络,回退到 networkingMode VirtioProxy。

1. 更新 WSL

wsl --update

2. 确保使用的是 WSL 2

wsl -l -v

如果显示为 WSL 1,可以通过以下方式转换:

wsl --set-version <发行版名称> 2

3. 启用相关功能

确保 Hyper-V 和虚拟机平台启用:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
dism.exe /online /enable-feature /featurename:Microsoft-Hyper-V-All /all /norestart

然后重启电脑。

Solana SPL 程序编译

代码Clone

git clone https://github.com/solana-program/token.git
cd token
git checkout program@v3.5.0

基础环境

# 安装nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
source ~/.bashrc

# 安装node
nvm install 20
node -v

# 安装pnpm
npm install -g pnpm

安装依赖

pnpm install

编译

cd program/
cargo build-sbf

默认编译可能出现以下错误

[2025-04-25T09:39:35.004769959Z ERROR cargo_build_sbf] Failed to obtain package metadata: `cargo metadata` exited with an error: error: current package believes it's in a workspace when it's not:
    current:   /mnt/d/github/token/program/Cargo.toml
    workspace: /mnt/d/github/token/Cargo.toml

    this may be fixable by adding `program` to the `workspace.members` array of the manifest located at: /mnt/d/github/token/Cargo.toml
    Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest.

解决

在 program 目录的 Cargo.toml 文件中添加空的 [workspace] 表

修改 program\Cargo.toml,在第一行增加

[workspace] // 增加此行
[package]
name = "spl-token"
version = "3.5.0"
...

执行成功后,程序编译出现在program\target\deploy\spl_token.so

Solana Secp256k1 ECDSA

no_std与 Secp256k1 曲线兼容的 ECDSA 实现,专为在 Solana 生态系统中使用而设计。

概述

该库使用 Secp256k1 曲线提供了 ECDSA 签名的轻量级实现。它旨在与各种环境兼容no_std,因此适用于嵌入式系统、WebAssembly 模块以及其他缺乏标准库支持的受限环境。

特征

  • no_std 兼容:在没有 Rust 标准库的环境中工作
  • 签名创建:使用各种方法生成 ECDSA 签名:
    • RFC6979 确定性随机数生成
    • 自定义临时密钥 (k) 支持
    • 预散列消息支持
  • 签名验证:根据公钥验证 ECDSA 签名
  • 签名规范化:使用可选的 s 值规范化(低 S)处理签名的可延展性
  • 最小依赖solana_secp256k1:建立在原语之上

https://github.com/deanmlittle/solana-secp256k1-ecdsa