linera-io/linera-protocol

GitHub: linera-io/linera-protocol

Linera 是基于微链架构的高性能区块链协议,通过并行执行独立链来实现低延迟和高可扩展性的 Web3 基础设施。

Stars: 32141 | Forks: 2320

# [![License](https://img.shields.io/github/license/linera-io/linera-protocol)](LICENSE) [![Build Status for Docker](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/7a6e543277214155.svg)](https://github.com/linera-io/linera-protocol/actions/workflows/docker-compose.yml) [![Build Status for Rust](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/1dba64470a214204.svg)](https://github.com/linera-io/linera-protocol/actions/workflows/rust.yml) [![Build Status for Documentation](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/f73f4c7d7f214208.svg)](https://github.com/linera-io/linera-protocol/actions/workflows/documentation.yml) [![Twitter](https://img.shields.io/twitter/follow/linera_io)](https://x.com/linera_io) [![Discord](https://img.shields.io/discord/984941796272521226)](https://discord.com/invite/linera) [Linera](https://linera.io) 是一种去中心化的区块链基础设施,旨在为高度可扩展、安全且低延迟的 Web3 应用程序提供支持。 ## 文档 请访问我们的 [开发者页面](https://linera.dev) 并阅读我们的 [白皮书](https://linera.io/whitepaper) 以了解更多关于 Linera 协议的信息。 ## 仓库结构 本仓库的主要 crate 和目录概括如下:(按依赖关系图从低到高列出) * [`linera-base`](https://linera-io.github.io/linera-protocol/linera_base/index.html) 基础定义,包括密码学。 * [`linera-version`](https://linera-io.github.io/linera-protocol/linera_version/index.html) 一个用于管理二进制文件和服务中版本信息的库。 * [`linera-views`](https://linera-io.github.io/linera-protocol/linera_views/index.html) 一个将复杂数据结构映射到键值存储的库。相应的过程宏在 `linera-views-derive` 中实现。 * [`linera-execution`](https://linera-io.github.io/linera-protocol/linera_execution/index.html) Linera 应用程序的运行时和执行的持久数据及相应逻辑。 * [`linera-chain`](https://linera-io.github.io/linera-protocol/linera_chain/index.html) 区块链、证书和跨链消息的持久数据及相应逻辑。 * [`linera-storage`](https://linera-io.github.io/linera-protocol/linera_storage/index.html) 在 `linera-chain` 之上定义协议的存储抽象。 * [`linera-core`](https://linera-io.github.io/linera-protocol/linera_core/index.html) 核心 Linera 协议,包括客户端和服务器逻辑、节点同步等。 * [`linera-rpc`](https://linera-io.github.io/linera-protocol/linera_rpc/index.html) 定义 RPC 消息的数据类型(目前包括所有客户端 ↔ 代理 ↔ 链 ↔ 链交互),并跟踪相应的数据模式。 * [`linera-client`](https://linera-io.github.io/linera-protocol/linera_client/index.html) 用于编写 Linera 客户端的库。用于 `linera-service` 中的命令行客户端和节点服务,以及 [`linera-web`](https://github.com/linera-io/linera-web/) 中的 Web 客户端。 * [`linera-service`](https://linera-io.github.io/linera-protocol/linera_service/index.html) 客户端(即 CLI 钱包)、代理(即验证器前端)和服务器的可执行文件。 * [`linera-sdk`](https://linera-io.github.io/linera-protocol/linera_sdk/index.html) 为 Wasm 虚拟机开发的 Rust 编写的 Linera 应用程序库。相应的过程宏在 `linera-sdk-derive` 中实现。 * [`examples`](./examples) Rust 编写的 Linera 应用程序示例。 ## 前置条件 请参阅 [`INSTALL.md`](./INSTALL.md) 了解在本仓库中进行开发的软件要求。 ## Linera CLI 工具快速入门 以下命令用于设置本地测试网络,并在单个钱包拥有的微链之间运行一些转账操作。 ``` # Make sure to compile the Linera binaries and add them in the $PATH. # cargo build -p linera-storage-service -p linera-service --bins export PATH="$PWD/target/debug:$PATH" # Import the optional helper function `linera_spawn`. source /dev/stdin <<<"$(linera net helper 2>/dev/null)" # Run a local test network with the default parameters and a number of microchains # owned by the default wallet. This also defines `LINERA_TMP_DIR`. linera_spawn \ linera net up --with-faucet --faucet-port 8080 # Remember the URL of the faucet. FAUCET_URL=http://localhost:8080 # If you're using a testnet, start here and run this instead: # LINERA_TMP_DIR=$(mktemp -d) # FAUCET_URL=https://faucet.testnet-XXX.linera.net # for some value XXX ``` 启用用户应用程序的日志: ``` export LINERA_APPLICATION_LOGS=true ``` 设置未来钱包的路径: ``` export LINERA_WALLET="$LINERA_TMP_DIR/wallet.json" export LINERA_KEYSTORE="$LINERA_TMP_DIR/keystore.json" export LINERA_STORAGE="rocksdb:$LINERA_TMP_DIR/client.db" # Initialize a new user wallet. linera wallet init --faucet $FAUCET_URL # Request chains. INFO1=($(linera wallet request-chain --faucet $FAUCET_URL)) INFO2=($(linera wallet request-chain --faucet $FAUCET_URL)) CHAIN1="${INFO1[0]}" ACCOUNT1="${INFO1[1]}" CHAIN2="${INFO2[0]}" ACCOUNT2="${INFO2[1]}" # Show the different chains tracked by the wallet. linera wallet show # Query the chain balance of some of the chains. linera query-balance "$CHAIN1" linera query-balance "$CHAIN2" # Transfer 10 units then 5 back. linera transfer 10 --from "$CHAIN1" --to "$CHAIN2" linera transfer 5 --from "$CHAIN2" --to "$CHAIN1" # Query balances again. linera query-balance "$CHAIN1" linera query-balance "$CHAIN2" # Now let's fund the user balances. linera transfer 5 --from "$CHAIN1" --to "$ACCOUNT1@$CHAIN1" linera transfer 2 --from "$ACCOUNT1@$CHAIN1" --to "$ACCOUNT2@$CHAIN2" # Query user balances again. linera query-balance "$ACCOUNT1@$CHAIN1" linera query-balance "$ACCOUNT2@$CHAIN2" ``` 更复杂的示例可以在我们的 [开发者手册](https://linera.dev) 以及本仓库的 [示例应用程序](./examples) 中找到。 ## 贡献 我们欢迎社区的贡献!如果您想为 Linera 协议做出贡献: 1. Fork 本仓库 2. 创建一个功能分支 (`git checkout -b feature/amazing-feature`) 3. 提交您的更改 (`git commit -m 'Add some amazing feature'`) 4. 推送到该分支 (`git push origin feature/amazing-feature`) 5. 发起一个 Pull Request 有关详细的指南,请参阅我们的 [贡献指南](./CONTRIBUTING.md)。
标签:AI工具, Layer1, Linera, Linera协议, Rust, Web3, 低延迟, 便携式工具, 分布式账本, 加密货币, 区块链, 区块链开发, 去中心化基础设施, 可视化界面, 子域名突变, 密码学, 微链, 手动系统调用, 拜占庭容错, 智能合约, 网络流量审计, 请求拦截, 通知系统, 高可扩展性