|
79 | 79 | </blockquote>
|
80 | 80 | <p>Substrate 采用了模块化的区块链开发模式,并定义了一组丰富的基础类型,使开发者不仅能有效利用它的强大开发能力,又感觉它和自己熟悉的编程语言差别不大。</p>
|
81 | 81 | <h2><a class="anchor" aria-hidden="true" id="架构"></a><a href="#架构" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>架构</h2>
|
82 |
| -<p><img src="/docs/assets/substrate-arch.png" alt="Substrate Client Architecture"></p> |
| 82 | +<p><img src="/docs/assets/substrate-arch.png" alt="Substrate客户端架构"></p> |
83 | 83 | <p>Substrate 客户端是一个用于运行 Substrate 区块链节点的应用程序 - 它由几个组件组成,包括但不限于:</p>
|
84 | 84 | <ul>
|
85 | 85 | <li><strong>存储</strong> 是用来维持区块链这个去中心化系统所呈现的状态演变的一贯性。 区块链网络可以让所有参与者在无需信任的条件下,而对区块链存储状态达成<a href="knowledgebase/advanced/consensus">共识</a>。 Substrate 提供了一种简单而高效的<a href="knowledgebase/advanced/storage"> 键值对存储机制</a>.</li>
|
86 | 86 | <li><strong>Runtime</strong> 逻辑定义了区块的处理方式,其中包括了状态转换的逻辑。 在 Substrate中,Runtime 代码最后会编译为 <a href="knowledgebase/getting-started/glossary#webassembly-wasm">Wasm</a>的格式,并成为区块链存储状态的一部分。这就定义了Substrate 区块链与其它区块链的显著差别:可进行<a href="knowledgebase/advanced/executor#forkless-runtime-upgrades">无分叉的 Runtime 升级</a>。 另外,Substrate客户端也可以拥有一个非wasm格式的"native runtime" ,它的编译语言应与客户端的编写语言一致。 客户端中向 runtime 发送可调用函数的组件被称为<a href="knowledgebase/advanced/executor">执行器</a> ,是由它来负责在native代码和编译后的Wasm之间进行选择。 尽管native runtime 可提供性能优势,但如果 Wasm Runtime 实现了较新的<a href="knowledgebase/advanced/executor#runtime-versioning">版本</a>,执行器将会选择按wasm版本来执行。</li>
|
87 |
| -<li><strong>点对点网络</strong> 允许客户端与其他网络参与者进行通信。 Substrate uses <a href="https://libp2p.io/">the <code>libp2p</code> network stack</a>.</li> |
| 87 | +<li><strong>点对点网络</strong> 允许客户端与其他网络参与者进行通信。 Substrate 使用 <a href="https://libp2p.io/"><code>libp2p</code> 网络栈</a>。</li> |
88 | 88 | <li><strong>共识</strong> 引擎提供了一种逻辑,能使网络参与者就区块链的状态达成一致。 Substrate 支持提供自定义的共识引擎,同时也提供了几个建立在 <a href="https://w3f-research.readthedocs.io/en/latest/index.html">Web3 基金会研究</a>之上的共识机制。</li>
|
89 | 89 | <li><strong>RPC</strong>(远程过程调用) 功能使用户能与区块链网络进行交互。 Substrate 提供了 HTTP 和 WebSocket RPC 两种服务器。</li>
|
90 | 90 | <li><strong>遥测</strong> 度量通过嵌入式 <a href="https://prometheus.io/">Prometheus</a> 服务器的方式对外展示。</li>
|
91 | 91 | </ul>
|
92 | 92 | <h2><a class="anchor" aria-hidden="true" id="使用方法"></a><a href="#使用方法" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>使用方法</h2>
|
93 |
| -<p><img src="/docs/assets/technical-freedom.png" alt="Technical Freedom vs Development Ease"></p> |
| 93 | +<p><img src="/docs/assets/technical-freedom.png" alt="技术自由相 vs 开发自由"></p> |
94 | 94 | <p>可以通过以下三种方式来使用Substrate:</p>
|
95 | 95 | <ol>
|
96 | 96 | <li><p><strong>通过 Substrate 节点</strong>: 你可以运行预先设计好的 <a href="https://github.com/paritytech/substrate/tree/master/bin/node">Substrate Node</a> 并<a href="https://github.com/paritytech/substrate/blob/master/bin/node/cli/src/chain_spec.rs">配置</a>它的创世区块。 在这种情况下,你只需要提供一个 JSON 文件来启动你自己的区块链。 该JSON 文件允许你配置 Substrate 节点的runtime 组成模块的初始状态,如:Balances,Staking,和 Sudo等模块。 你可以在<a href="tutorials/create-your-first-substrate-chain">创建你的第一条 Substrate 区块链</a>和<a href="/docs/zh-CN/tutorials/start-a-private-network/">启动一个私有网络</a>教程中了解更多关于运行 Substrate 节点的信息。</p></li>
|
97 |
| -<li><p><strong>通过 Substrate FRAME 框架</strong>:你可以使用 <a href="/docs/zh-CN/knowledgebase/runtime/frame">FRAME</a>(Framework for Runtime Aggregation of Modularized Entities,模块化实体 Runtime 聚合框架)轻松创建自定义 Rumtime,这同样也是 Substrate 节点构建时使用的方法。 这就为你的区块链逻辑开发提供了巨大的自由度,允许你配置数据类型,从模块库(称为 "pallets") 中挑选,甚至添加自定义模块。 如果要运用FRAME开发项目,<a href="https://github.com/substrate-developer-hub/substrate-node-template">Substrate Developer Hub Node Template</a> 模板可作为一个很好的起点。 要了解更多信息,请参见教程<a href="tutorials/build-a-dapp">构建一个 dApp</a> 和添加一个<a href="tutorials/add-a-pallet">添加一个Pallet</a>.。</p></li> |
98 |
| -<li><p><strong>With Substrate Core</strong>: The entire FRAME system can be ignored, and the runtime can be designed and implemented from scratch. This could be done in <em>any language</em> that can target <a href="https://webassembly.org/">WebAssembly</a>. If the runtime can be made to be compatible with the abstract block authoring logic of the Substrate node, then you can simply construct a new genesis block from your Wasm blob and launch your chain with the existing Rust-based Substrate client. If not, then you will need to alter the client's block authoring logic, and potentially even alter the header and block serialization formats. In terms of development effort, this is by far the most difficult way to use Substrate, but also gives you the most freedom to innovate.</p></li> |
| 97 | +<li><p><strong>通过 Substrate FRAME 框架</strong>:你可以使用 <a href="/docs/zh-CN/knowledgebase/runtime/frame">FRAME</a>(Framework for Runtime Aggregation of Modularized Entities,模块化实体 Runtime 聚合框架)轻松创建自定义 Rumtime,这同样也是 Substrate 节点构建时使用的方法。 这就为你的区块链逻辑开发提供了巨大的自由度,允许你配置数据类型,从模块库(称为 "pallets") 中挑选,甚至添加自定义模块。 如果要使用FRAME开发项目,<a href="https://github.com/substrate-developer-hub/substrate-node-template">Substrate Developer Hub Node Template</a> 模板可作为一个很好的起点。 要了解更多信息,请参见教程<a href="tutorials/build-a-dapp">构建一个 dApp</a> 和<a href="tutorials/add-a-pallet">添加一个Pallet</a>.。</p></li> |
| 98 | +<li><p><strong>使用 Substrate Core</strong>:可跳过整个 FRAME,并且可以从头开始设计和实现整个 Runtime。 <em>任何</em>能编译成 <a href="https://webassembly.org/">WebAssembly</a>的语言 ,均能用来实现这个方案。 只要 runtime 兼容 Substrate 节点的抽象区块创建逻辑,那么你就可以简单地从 Wasm 二进制代码块中构造一个新的创世区块,然后用现有的、基于 Rust 的 Substrate 客户端启动你的区块链。 若不兼容,那么你需要改变客户端的区块创建逻辑,甚至可能需要改变区块头和区块序列化格式。 就开发强度而言,这是迄今为止使用 Substrate 最困难的方式,但也给了你最大的自由度。</p></li> |
99 | 99 | </ol>
|
100 | 100 | <h2><a class="anchor" aria-hidden="true" id="下一步"></a><a href="#下一步" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>下一步</h2>
|
101 | 101 | <h3><a class="anchor" aria-hidden="true" id="进一步学习"></a><a href="#进一步学习" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>进一步学习</h3>
|
102 | 102 | <ul>
|
103 |
| -<li>Refer to the developer documentation for the <a href="knowledgebase/runtime">FRAME system for runtime development</a>.</li> |
104 |
| -<li>Learn how to create rich client applications for any Substrate-based chain by using the <a href="knowledgebase/integrate/polkadot-js">Polkadot-JS</a> family of libraries.</li> |
105 |
| -<li>Dive deep into advanced topics, like Substrate's <a href="knowledgebase/advanced/codec">SCALE encoding</a>, <a href="knowledgebase/advanced/consensus">consensus mechanisms</a>, <a href="knowledgebase/advanced/cryptography">cryptography</a>, and <a href="knowledgebase/advanced/storage">storage implementation</a>.</li> |
| 103 | +<li>参考 <a href="knowledgebase/runtime">Runtime FRAME 系统的开发</a>的开发者文档。</li> |
| 104 | +<li>了解如何使用 <a href="knowledgebase/integrate/polkadot-js">Polkadot-JS</a> 系列库来为基于 Substrate 的链创建客户端富应用程序。</li> |
| 105 | +<li>深入了解进阶主题,如Substrate的 <a href="knowledgebase/advanced/codec">SCALE 编码</a>、<a href="knowledgebase/advanced/consensus">共识机制</a>、<a href="knowledgebase/advanced/cryptography">密码学</a>和<a href="knowledgebase/advanced/storage">存储实现</a>等。</li> |
106 | 106 | </ul>
|
107 | 107 | <h3><a class="anchor" aria-hidden="true" id="例子"></a><a href="#例子" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>例子</h3>
|
108 | 108 | <ul>
|
109 |
| -<li>Follow our <a href="../../tutorials">tutorials</a> to learn about building and running blockchains with Substrate and FRAME.</li> |
110 |
| -<li>Refer to the <a href="https://substrate.dev/recipes/">Substrate Recipes</a> to find complete working examples that demonstrate solutions to common problems.</li> |
| 109 | +<li>请跟随我们的<a href="../../tutorials">教程</a>学习如何使用 Substrate 和 FRAME 构建和运行区块链。</li> |
| 110 | +<li>参考 <a href="https://substrate.dev/recipes/">Substrate Recipes</a>, 查看用于解决常见问题的完整可运行示例。</li> |
111 | 111 | </ul>
|
112 | 112 | <h3><a class="anchor" aria-hidden="true" id="参考文档"></a><a href="#参考文档" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>参考文档</h3>
|
113 | 113 | <ul>
|
114 |
| -<li>Check out the <a href="https://substrate.dev/rustdocs">Rust reference documentation</a> that ships with the Substrate code base.</li> |
| 114 | +<li>查看 Substrate 代码库随附的 <a href="https://substrate.dev/rustdocs">Rust 参考文档</a>。</li> |
115 | 115 | </ul>
|
116 | 116 | </span></div></article></div><div class="docs-prevnext"><a class="docs-next button" href="/docs/zh-CN/knowledgebase/getting-started/index"><span>安装</span><span class="arrow-next"> →</span></a></div></div></div><nav class="onPageNav"><ul class="toc-headings"><li><a href="#架构">架构</a></li><li><a href="#使用方法">使用方法</a></li><li><a href="#下一步">下一步</a><ul class="toc-headings"><li><a href="#进一步学习">进一步学习</a></li><li><a href="#例子">例子</a></li><li><a href="#参考文档">参考文档</a></li></ul></li></ul></nav></div><footer class="nav-footer" id="footer"><section class="sitemap"><a href="/" class="nav-home"><img src="/img/Substrate-logo.svg" alt="Substrate Developer Hub" width="66" height="58"/></a><div><h5>开发者中心</h5><a href="/zh-CN/tutorials">教程</a><a href="/docs/zh-CN/">知识库</a><a href="https://substrate.dev/recipes/">进阶菜谱</a><a href="https://substrate.dev/rustdocs">API 文档</a></div><div><h5>社区</h5><a href="/zh-CN/community">社区主页</a><a href="/zh-CN/newsletter">通讯</a><a href="https://app.element.io/#/room/!HzySYSaIhtyWrwiwEV:matrix.org">Substrate 技术聊天室</a><a href="/zh-CN/seminar">Substrate 研讨会</a><a href="http://stackoverflow.com/questions/tagged/substrate" target="_blank" rel="noreferrer noopener">Stack Overflow</a><a href="https://twitter.com/ParityTech" target="_blank" rel="noreferrer noopener">推特</a><a href="https://www.meetup.com/parity/" target="_blank" rel="noreferrer noopener">Events</a></div><div><h5>更多</h5><a href="https://www.substrate.io/builders-program/">Substrate Builders 计划</a><a href="https://www.parity.io/blog/">Blog</a><a href="https://github.com/paritytech/substrate">Substrate GitHub</a><a href="https://github.com/substrate-developer-hub/">开发者中心 GitHub</a><a href="https://www.parity.io/privacy/">隐私政策</a><a href="/terms">使用条款</a><a href="#" id="cookie-settings">Cookie 设置<script>
|
117 | 117 | var cookieSettings = document.getElementById('cookie-settings');
|
|
0 commit comments