「Tezosソフトウェアアーキテクチャ」の版間の差分

提供: tezos-wiki
移動先: 案内検索
(ページの作成:「.. _software_architecture: = Tezos Software Architecture = This document contains two section. The first section, which should be readable by anyone, describes the main...」)
 
 
1行目: 1行目:
.. _software_architecture:
+
.. _software_architecture:
  
= Tezos Software Architecture =
+
= Tezosソフトウェアアーキテクチャ=
  
This document contains two section. The first section, which should be readable by anyone, describes the main elements of Tezos from a distance. It abstracts from all plumbing and both internal and system dependencies to give a simple view of the main components, their responsibilities and interactions. The second part is written for developers, and is at the level of OPAM packages.
+
この文書には2つのセクションがあります。誰にでも読めるはずの最初のセクションは、Tezosの主要な要素を遠くから説明しています。それは、すべての配管工事、および内部とシステムの両方の依存関係から抽象化して、主要コンポーネント、責任、および相互作用の簡単な表示を提供します。 2番目の部分は開発者向けに書かれたもので、OPAMパッケージのレベルにあります。
  
== The Big Picture ==
+
==大きな画像==
  
.. _the_big_picture:
+
.. _大きな絵:
  
The diagram below shows a very coarse grained architecture of Tezos.
+
下の図は、Tezosの非常に粗粒度のアーキテクチャを示しています。
  
|Tezos architecture diagram|
+
| Tezosアーキテクチャ図|
  
The characteristic that makes Tezos unique is its self-amending property. The part that amends itself is called the ''economic protocol'' (the green eye of the octopus), sometimes abbreviated by protocol or even proto in the source code. The rest of a Tezos node is what we call the ''shell'' (the blue octopus).
+
Tezosをユニークなものにする特徴は、自己修正の特性です。自分自身を補正する部分は、「経済的な議定書」(タコの緑色の目)と呼ばれ、プロトコルによって短縮されることもありますし、ソースコード内でプロトタイプさえもあります。 Tezosノードの残りの部分は、「シェル」(青いタコ)と呼ばれています。
  
The protocol is responsible for interpreting the transactions and other administrative operations. It also has the responsibility to detect erroneous blocks.
+
このプロトコルは、トランザクションおよびその他の管理操作の解釈を担当します。また、誤ったブロックを検出する責任もあります。
  
An important thing to notice is that the protocol always sees only one block chain. In other words, a linear sequence of blocks since the genesis. It does not know that it lives in an open network where nodes can propose alternative heads.
+
注意すべき重要なことは、プロトコルが常に1つのブロックチェーンだけを見ることです。言い換えれば、起源以来のブロックの線形シーケンス。ノードが代替ヘッドを提案できるオープンなネットワークに存在することは知られていません。
  
Only the shell knows about the multiple heads. It is responsible for choosing between the various chain proposals that come from the bakers (the programs that cook new blocks) of the network. The shell has the responsibility of selecting and downloading alternative chains, feed them to the protocol, which in turn has the responsibility to check them for errors, and give them an absolute score. The shell then simply selects the valid head of highest absolute score. This part of the shell is called :ref:<code>the validator&lt;validation&gt;</code>.
+
シェルだけが複数のヘッドについて知っています。それは、ネットワークのパン屋(新しいブロックを調理するプログラム)から来る様々なチェーンの提案の中から選択する責任があります。シェルは、代替チェーンを選択してダウンロードし、プロトコルにフィードし、エラーをチェックして絶対的なスコアを与える責任があります。シェルは単に、最高絶対スコアの有効な頭部を選択するだけです。シェルのこの部分は、ref:<code>バリデータ<validation> </code>と呼ばれます。
  
The rest of the shell includes the peer-to-peer layer, the disk storage of blocks, the operations to allow the node to transmit the chain data to new nodes and the versioned state of the ledger. Inbetween the validator, the peer-to-peer layer and the storage sits a component called the distributed database, that abstracts the fetching and replication of new chain data to the validator.
+
残りのシェルには、ピアツーピア層、ブロックのディスクストレージ、ノードがチェーンデータを新しいノードに送信するための操作、および元帳のバージョン管理された状態が含まれます。検証者の間で、ピアツーピア層とストレージは、新しいチェーンデータの取得と複製をバリデータに抽象化する分散データベースと呼ばれるコンポーネントを配置します。
  
Protocols are compiled using a tweaked OCaml compiler (green part on the left of the picture) that does two things. First, it checks that the protocol’s main module has the right type. A good analogy is to see protocol as plug-ins, and in this case, it means that it respects the common plugin interface. Then, it restricts the typing environment of the protocol’s code so that it only calls authorized modules and functions. Seeing protocols as plug-ins, it means that the code only called primitives from the plug-in API. It is a form of statically enforced sandboxing.
+
プロトコルは、2つのことをする微調整されたOCamlコンパイラ(画像の左側の緑色の部分)を使用してコンパイルされます。まず、プロトコルのメインモジュールが正しいタイプであることをチェックします。プロトコルをプラグインと見なすのが良いアナロジーです。この場合、共通のプラグインインターフェイスを尊重していることを意味します。次に、認可されたモジュールと関数だけを呼び出すように、プロトコルのコードの型定義環境を制限します。プロトコルをプラグインとして見ると、コードはプラグインAPIからのプリミティブのみを呼び出すことになります。これは、静的に強制されるサンドボックスの一種です。
  
Finally, the RPC layer (in yellow on the right in the picture) is an important part of the node. It is how the client, third party applications and daemons can interact with the node and introspect its state. This component uses the mainstream JSON format and HTTP protocol. It uses in-house libraries <code>ocplib-resto</code> and <code>ocplib-json-typed</code> (via the module :ref:<code>Data_encoding &lt;data_encoding&gt;</code>). It is fully inter-operable, and auto descriptive, using JSON schema.
+
最後に、RPCレイヤ(画像の右側の黄色)はノードの重要な部分です。これは、クライアント、サードパーティのアプリケーションとデーモンがノードとやり取りしてその状態を調べる方法です。このコンポーネントは、メインストリームのJSON形式とHTTPプロトコルを使用します。コード:ocplib-resto </code><code> ocplib-json-typed </code>を使用します(モジュール:ref:<code> Data_encoding&lt; data_encoding&gt; </code>)。これは、JSONスキーマを使用して、完全に相互運用可能で、自動記述的です。
  
.. |Tezos architecture diagram| image:: octopus.svg
+
.. | Tezosアーキテクチャ図| image :: octopus.svg
 +
==ソフトウェアアーキテクチャとパッケージrelashionships ==
  
== Software Architecture and Package Relashionships ==
+
..パッケージ:
  
.. _packages:
+
以下の図は、Tezosのソースコードに含まれる主なOPAMパッケージとその依存関係を示しています。分かりやすくするために、<code> tezos - </code>接頭辞を削除しました。
  
The diagram below shows the main OPAM packages present in the source code of Tezos, and their dependencies. The <code>tezos-</code> prefix has been dropped for clarity.
+
| Tezosソースパッケージ図|
  
|Tezos source packages diagram|
+
下の緑色にはバイナリがあります。黄色で伏せたのは、OPAMパッケージ(時には短縮名)です。黒い矢印は直接の依存関係を示しています。オレンジ色の矢印は、以下に説明する他の間接的な関係(コード生成、インターフェース共有)を示しています。青色で囲まれた部分には、Unixに依存しないモジュールが含まれているため、JavaScriptにコンパイルすることができます。この図には外部依存関係は示されていません。
  
In green at the bottom are binaries. Hilighted in yellow are the OPAM packages (sometimes with shortened names). Black arrows show direct dependencies. Orange arrows show other indirect relashionships (code generation, interface sharing), explained below. The part circled in blue, contains modules that bear no dependency to Unix, and can thus be compiled to JavaScript. External dependencies are not shown in this illustration.
+
ベースとそれ以下の<sub> <sub> <sub> <sub> <sub>?</sub> </sub> </sub> </sub> </sub>?
  
Base and below <sub><sub><sub><sub><sub><sub>~</sub></sub></sub></sub></sub></sub>~
+
その中心にある:package:<code> tezos-base </code>パッケージは、ブロックチェーン固有のコードが始まる場所です。これは基本的な操作のためにどこでも使用されるライブラリのセットです。
  
At the center, the :package:<code>tezos-base</code> package is where the blockchain specific code starts. Before it are the set of libraries that are used everywhere for basic operations.
+
*:package:<code> tezos-stdlib </code>には、OCaml標準ライブラリ(いくつかの文字列プリミティブ、<code> Option </code>モジュールなど)上にいくつかの拡張機能が含まれています。 </code>ユーティリティ、および単体比較演算子を実装する<code> Compare </code>モジュールがあります。
 +
*:package:<code> tezos-data-encoding </code>は社内のコミニュナーベースの直列化ライブラリです。単一の型記述<code> t encoding </code>から、コードはバイナリとJSONの両方の表現<code> t </code>型の値を読み書きできます。どちらの場合でも、図書館は、文書のコンビネータを使用して、機械可読文書と人間が書くことができる文書を提供します。 JSONの部分は、opam:<code> ocplib-json-typed </code>に依存します。 A:ref:<code>チュートリアル&lt; data_encoding&gt; </code>はこのライブラリで使用できます。
 +
*:package:<code> tezos-error-monad </code>はOCamlの<code>( 'a、' b)結果</code>型への社内モナドインタフェースであり、 b </code>を拡張可能なタイプの<code> error </code>(実際にはエラートレースを保持するリスト)に変換します。型を拡張する場合、プログラマは、きれいなプリンタと直列化のためのエンコーディングを登録する<code> register_error </code>関数も呼び出す必要があります。 A:ref:<code>チュートリアル&lt; error_monad&gt; </code>は、このライブラリで使用できます。
 +
*:package:<code> tezos-rpc </code>は、TezosのRPCサービスメカニズムの基本を提供します。 Ocsigen / Eliomのサービス階層を構築し、サービスを登録および呼び出しするためのコンビネータを提供します。このモジュールはopam:<code> ocplib-resto </code>に基づいています。これは、マシンの自動生成と人間が理解できるサービスの階層を可能にします:URLの構造と入出力本体<code> data_encoding </code>を使用します。
 +
*:package:<code> tezos-crypto </code>は、私たちが使用する外部暗号ライブラリをラップします。可能な限り薄いバインディングで最小限のリファレンス実装を使用しようとしています。可能な計画は、HACLプロジェットからのライブラリを使用することです。そのため、すべての暗号はFstarから、薄いCバインディングで、またはOCamlで直接抽出されます。
 +
*:package:<code> tezos-micheline </code>はスマート契約の言語であるマイケルソンが使用する具体的な構文です。ほとんどの場合、汎用の型なしAST、プリンタ、パーサが含まれています。
 +
*:package:<code> tezos-base </code>は、これらすべてのモジュールをTezosの他のすべてのコンポーネントの共通基盤にまとめ、ブロックチェーンのデータ構造を導入します(<code> Block_hash </code>シェル、経済プロトコル、クライアント、デーモン、および第三者間で共有される<code> Block_header </code>、<code> Block_locator </code>、<code> Fitness </code>、<code> P2pidentity </code> 。また、特定のタイプのオールインワンモジュールを構築するファンクタとして、<code> crypto </code>からいくつかのモジュールを再ラップします(たとえば、ブロックハッシュ用のモジュールには、すべてのコンバータ、コマンドラインとRPC引数ビルダー、プリンタ、オートコンプリータなど)。このパッケージには、一部の実行可能ファイルでコマンドライン解析を処理するために使用する<code> cli_entries </code>モジュールも含まれています。
  
* :package:<code>tezos-stdlib</code> contains a few extensions over the OCaml standard library (a few string primitives, an <code>Option</code> module, etc.), a few <code>Lwt</code> utilities, and a <code>Compare</code> module that implements monomorphic comparison operators.
+
シェル<sub>?<sub>?</sub> </sub>?
* :package:<code>tezos-data-encoding</code> is the in-house comibnator-based serialization library. From a single type description <code>t encoding</code>, the code can read to and write from values of type <code>t</code> both binary and JSON representations. For both, the library provides machine and human-redable documentations by the use of documentation combinators. The JSON part depends on :opam:<code>ocplib-json-typed</code>. A :ref:<code>tutorial&lt;data_encoding&gt;</code> is available for this library.
 
* :package:<code>tezos-error-monad</code> is an in-house monadic interface to the OCaml <code>('a, 'b) result</code> type, that fixes the <code>'b</code> to an extensible type <code>error</code> (actually a list, to hold an error trace). When extending the type, programmers must also call the <code>register_error</code> function that registers a pretty printer and an encoding for serialization. A :ref:<code>tutorial&lt;error_monad&gt;</code> is available for this library.
 
* :package:<code>tezos-rpc</code> provides the basics of Tezos' RPC service mechanism. It provides combinators for building service hierarchies a la Ocsigen/Eliom, registering and calling services. This module is based on :opam:<code>ocplib-resto</code>, that allows for automatic generation of a machine and human-readable of the hierarchy of services: the structure of URLs and the expected formats for input and output bodies, via the use of <code>data_encoding</code>.
 
* :package:<code>tezos-crypto</code> wraps the external cryptography libraries that we use. We try to use minimal references implementations, with as thin as possible bindings. A possible plan is to use libraries from the HACL projet, so that all of our crypto is extracted from Fstar, either with thin C bindings or directly in OCaml.
 
* :package:<code>tezos-micheline</code> is the concrete syntax used by Michelson, the language of smart contracts. It mostly contains the generic, untyped AST, a printer and a parser.
 
* :package:<code>tezos-base</code> wraps all these module in a common foundation for all the other components of Tezos, and introduces the data structures of the blockchain (e.g. <code>Block_hash</code>, <code>Block_header</code>, <code>Block_locator</code>, <code>Fitness</code>, <code>P2p_identity</code>) that are shared between the shell, economic protocol, client, daemons and third party software. It also rewraps some modules from <code>crypto</code> as functors that build all-in-one modules for a given type (for instance, the module for block hashes contains all possible converters, command line and RPC argument builders, pretty printers, an autocompleter, etc.). This package also contains the <code>cli_entries</code> module that we use to handle command line parsing in some executables.
 
  
The Shell <sub>~<sub>~</sub></sub>~
+
シェルは、すべての通信、ピアツーピアおよびRPCを担当するノードの一部であり、経済プロトコルの周りの繭として機能します。
 +
*:package:<code> tezos-shell-services </code>には、ノードのサービス階層の定義、およびクライアント(またはサードパーティのソフトウェア)で使用する関数の呼び出しが含まれます。このライブラリは、型安全な方法でサービスを呼び出すためにクライアントにリンクされているため、ここではサービスの記述のみが行われます。ハンドラの登録は、ノードの残りの実装で行われます。
 +
*:package:<code> tezos-rpc-http </code>は、opam:<code> cohttp </code>を使ってRPC over HTTPサーバとクライアントを実装し、以下を使用して宣言されたサービスを実際に使用できるようにします:package: <code> tezos-rpc </code>
 +
*:package:<code> tezos-p2p </code>は社内ピアツーピア層です。
 +
*:package:<code> tezos-storage </code>には、連鎖データに使用される生の単純なキー値ストアと、元帳のコンテキスト(ブロックごとに1つのバージョン)を格納するために使用される生バージョンキー付き値ストアが含まれます。これはopam:<code> irmin </code>と現在:opam:<code> leveldb </code>を使って実装されています。
 +
*:package:<code> tezos-protocol-updater </code>は、利用可能なプロトコルバージョンのテーブルを、埋め込みまたは動的にリンクしています。
 +
*:package:<code> tezos-shell </code>は、ブロック検証、mempool管理、および分散データベースのスケジューリングを実装します。説明は次のとおりです:ref:<code>このドキュメント<validation> </code>
  
The shell is the part of the node responsible for all communications, peer-to-peer and RPC, acting as a cocoon around the economic protocols.
+
経済プロトコル環境とコンパイラ<sub> <sub> <sub> <sub> <sub> <sub> <sub> <sub> <sub> <sub> <sub> <sub> <sub>?< / sub> </sub> </sub> </sub> </sub> </sub> </sub> </sub> </sub> >?<sub> <sub> <sub> <sub>?</sub> </sub> </sub>
  
* :package:<code>tezos-shell-services</code> contains the definition of the node's service hierarchy, and calling functions to use in the client (or any third party software). As this library is linked into the client to call the services in a type-safe way, only the description of services is done here. The registration of handlers is done in the rest of the node's implementation.
+
経済プロトコルは、OCamlコンパイラの特定のバージョンによってコンパイルされます。このコンパイラは、静的なサンドボックス化の一形式として、経済的プロトコルに利用可能なモジュールのセットを制限します。また、代替環境でプロトコルの実行を可能にするために、プロトコルのファンクション化されたバージョンを生成します。
* :package:<code>tezos-rpc-http</code> uses :opam:<code>cohttp</code> to implement the RPC over HTTP server and client, allowing to make actual use of services declared using :package:<code>tezos-rpc</code>.
 
* :package:<code>tezos-p2p</code> is the in-house peer-to-peer layer.
 
* :package:<code>tezos-storage</code> contains the raw simple key-value store used for the chain data, and the raw versioned key-value store used for storing the ledger's context (one version per block). This is implemented using :opam:<code>irmin</code> and currently :opam:<code>leveldb</code>.
 
* :package:<code>tezos-protocol-updater</code> maintains the table of available protocol versions, embedded or dynamically linked.
 
* :package:<code>tezos-shell</code> implements the scheduling of block validations, the mempool management, and the distributed database. A description is available in :ref:<code>this document&lt;validation&gt;</code>.
 
  
The Economic Protocol Environment and Compiler <sub><sub><sub><sub><sub><sub><sub><sub><sub><sub><sub><sub><sub><sub>~</sub></sub></sub></sub></sub></sub></sub></sub></sub></sub></sub></sub></sub>~<sub><sub><sub><sub><sub>~</sub></sub></sub></sub></sub></sub>~
+
*:package:<code> tezos-protocol-environment-sigs </code>には、経済的プロトコルで利用可能なモジュールが含まれています。このサンドボックスのレビューは、ref:<code> here&lt; protocol_environment&gt; </code>で利用できます。このモジュールには、標準ライブラリを削除し、暗号API、RPC定義、およびキー値ストアへのインタフェースが含まれています。
 +
*:package:<code> tezos-protocol-compiler </code>は、経済的なプロトコルのコンパイラです。OCamlの代替ドライバ:プロトコル環境内の型チェックを行うopam:<code> ocaml-compiler-libs </code>プロトコルコードについてさらに検査を行う。
 +
* <code> tezos-protocol-xxx </code>は、プロトコルコンパイラによって生成され、その標準ライブラリをパラメータとして持つプロトコル<code> xxx </code>のファントレイ化バージョンを含んでいます。このパラメータは、以下の2つの実装で実装できます。
 +
*:package:<code> tezos-protocol-environment-shell </code>はRPCサービスの登録とストレージアクセスがノードのものである環境のインスタンスです。これは、新しいプロトコルをロードするときにノードによって供給される環境です。
 +
*:package:<code> tezos-protocol-environment </code>には、プロトコル環境の3つの代替インスタンスが含まれています。コンテキストアクセス機能は、プロトコルのタイプおよび非コンテキスト機能のみが必要な場合に使用できるダミーのものですテスト用にメモリ内のキー値ストアをシミュレートするもの、およびいくつかのコンテキストアクセサから環境を構築できるようにするファンクタです。
 +
* <code> tezos-embedded-protocol-xxx </code>には、標準ライブラリがシェルの実装にプリインスタンス化されているプロトコル<code> xxx </code>のバージョンが含まれています。 。それには、ノードのプロトコルテーブルにプロトコルを登録するモジュールが含まれています。
  
Economic protocols are compiled by a specific version of the OCaml compiler. This compiler restricts the set of modules available to the economic protocol, as a form of static sandboxing. It also generates a functorized version of the protocol, to make the execution of the protocol in alternative environment possible.
+
組込み経済議定書<sub> <sub> <sub> <sub> <sub> <sub> <sub> <sub> <sub> <sub> <sub> <sub> <sub> <sub>? </sub> </sub> </sub> </sub> </sub> </sub> </sub> sub> </sub> </sub>
  
* :package:<code>tezos-protocol-environment-sigs</code> contains the modules that are available to the economic protocol. A review of this sandbox is available :ref:<code>here&lt;protocol_environment&gt;</code>. This modules include a stripped down standard library, and interfaces to the crypto APIs, RPC definitions, and key-value store.
+
主なTezosリポジトリには、3つの経済的なプロトコルが含まれています。
* :package:<code>tezos-protocol-compiler</code> is the compiler for economic protocols: an alternative driver to the OCaml :opam:<code>ocaml-compiler-libs</code> that typechecks within the protocol environment, and performs some more checks on the protocol code.
 
* <code>tezos-protocol-xxx</code> is produced by the protocol compiler and contains a functorized version of protocol <code>xxx</code> that takes its standard library as parameter. This parameter can be filled with any of the implementations described in the two points below.
 
* :package:<code>tezos-protocol-environment-shell</code> is the instance of the environment whose RPC service registration and storage access are the ones of the node. This is the environment that is fed by the node when loading new protocols.
 
* :package:<code>tezos-protocol-environment</code> contains three alternative instances of the protocol environment: one whose context access function are dummy ones which can be used when only the types and non contextual functions of the protocol are needed, another that simulates the key-value store in memory for testing, and a functor that let you build an environment from a few context accessors.
 
* <code>tezos-embedded-protocol-xxx</code> contains a version of protocol <code>xxx</code> whose standard library is pre-instanciated to the shell's implementation, these are the ones that are linked into the node. It alse contains a module that registers the protocol in the node's protocol table.
 
  
The Embedded Economic Protocols <sub><sub><sub><sub><sub><sub><sub><sub><sub><sub><sub><sub><sub><sub><sub>~</sub></sub></sub></sub></sub></sub></sub></sub></sub></sub></sub></sub></sub></sub></sub>
+
*:パッケージ:起源ブロックのプロトコルは、<code> tezos-protocol-genesis </code>(パッケージ:<code> tezos-embedded-protocol-genesis </code>)です。これは、公開鍵がハードコードされている独裁者によって署名された単一のブロックを受け入れ、その単一のアクションは独裁者によって選択された新しいプロトコルに切り替えることである。
 +
*:パッケージ:Tezos-protocol-alpha(:package:<code> tezos-embedded-protocol-alpha </code>)はTezosの最初の実プロトコルです。 A:ref:<code>チュートリアル&lt; enter_alpha&gt; </code>を使用して、プロトコルのコードを読むことができます。
 +
*:package:<code> tezos-protocol-demo </code>(パッケージ:<code> tezos-embedded-protocol-demo </code>)は、面白いことはしませんが、正しい形をしたデモプロトコルです。
  
Three economic protocols are included in the main Tezos repository.
+
クライアントライブラリ<sub>?</sub> <sub> <sub> <sub> <sub>?</sub> </sub> </sub> </sub> ~~
  
* :package:<code>tezos-protocol-genesis</code> (:package:<code>tezos-embedded-protocol-genesis</code>) is the protocol of the genesis block. It accepts a single block, signed by a dictator whose public key is hardcoded, that single action is to switch to a new protocol chosen by the dictator.
+
クライアントは多くのパッケージに分割されており、シェルと経済プロトコル、Unix依存とJavascript互換、ライブラリ対コマンドラインインタフェースの3つの分離線を適用しています。
* :package:<code>tezos-protocol-alpha</code> (:package:<code>tezos-embedded-protocol-alpha</code>) is the first real protocol of Tezos. A :ref:<code>tutorial&lt;entering_alpha&gt;</code> is available to start reading the protocol's code.
 
* :package:<code>tezos-protocol-demo</code> (:package:<code>tezos-embedded-protocol-demo</code>) is just a demo protocol that does nothing interesting but has the right shape.
 
  
The Client Library <sub><sub>~</sub><sub><sub><sub><sub>~</sub></sub></sub></sub></sub>~~
+
*:package:<code> tezos-client-base </code>はクライアントコンテキストを定義します。クライアントコンテキストはメソッドがキーのウォレットへのアクセス、ユーザー経由の対話、RPC呼び出し、署名者によるデータ署名を可能にするオブジェクトですプラグイン。パッケージ:<code> tezos-shell-services </code>と:package:<code> tezos-protocol-alpha </code>のRPC呼び出し関数を含むほとんどのものは、このオブジェクト型で抽象化されています。そうすれば、ツールキットのさまざまなプラットフォームに同じコードを使用することができます。
 +
*:package:<code> tezos-client-alpha </code>は、クライアントコンテキストからウォレットと署名者を使用してプロトコルアルファの操作を実行するためのいくつかの関数を提供します。
 +
*:package:<code> tezos-client-commands </code>は、<code> tezos-client-commands </code>コマンドのハンドラとしてパッケージ:<code> tezos-client-base </code>クライアント</code>コマンドラインウォレットを使用します。
 +
*:パッケージ:<code> tezos-client-alpha-commands </code>は、<code> tezosのアルファ固有のコマンドのためのハンドラとしてパッケージ:<code> tezos-client-alpha </code> -client </code>コマンドラインウォレット。
 +
*:package:<code> tezos-client-genesis </code>には、起源プロトコルで利用可能な基本的な独裁者のコマンドが含まれています。
 +
*:package:<code> tezos-client-base-unix </code>は、Unixファイルに設定ファイルとウォレットストレージ、Unixコンソールを介したユーザ対話、ターミナルベースの署名者プラグインを実装しています。
 +
テストパッケージ<sub> <sub> <sub> <sub> <sub> <sub>?</sub> </sub> </sub> </sub> </sub>?
  
The client is split into many packages, to enforce three separation lines: shell vs economic protocol, Unix dependent vs Javascript compatible, and library vs command line interface.
+
テストはさまざまなパッケージに分割され、依存関係のチェーンに沿って、ますます多くの要素がテストされます。実行するには<code> make test </code>を使用します。
  
* :package:<code>tezos-client-base</code> define the client context, which is an object whose methods allow for: accessing a wallet of keys, interacting via the user, making RPC calls, and signing data using signer plug-ins. Most of the, including RPC calling functions from :package:<code>tezos-shell-services</code> and :package:<code>tezos-protocol-alpha</code>, are abstracted over this object type. That way, it is possible to use the same code for different platforms ot toolkits.
+
*:package-name:<code> tezos-client </code>(ディレクトリ内:src:<code> src / bin_client / test / </code>):シェルスクリプトとしてのエンドツーエンドテスト。サンドボックス化されたノードであり、クライアントを使用してさまざまなタスクを実行します
* :package:<code>tezos-client-alpha</code> provides some functions to perform the operations of protocol alpha using the wallet and signers from the client context.
+
*:package-name:<code> tezos-p2p </code>(ディレクトリ:src:<code> src / lib_p2p / test / </code>):ピアツーピア層のテスト。 Tezosのゴシッププロトコル(接続の確立、ピアの伝播など)
* :package:<code>tezos-client-commands</code> plugs the basic context access functions from :package:<code>tezos-client-base</code> as handlers for the commands of the <code>tezos-client</code> command line wallet.
+
*:パッケージ名:<code> tezos-protocol-environment </code>(ディレクトリ:src:<code> src / lib_protocol_environment / test / </code>):メモリ内コンテキストの実装をテストします。
* :package:<code>tezos-client-alpha-commands</code> plugs the functions from :package:<code>tezos-client-alpha</code> as handlers for the alpha specific commands of the <code>tezos-client</code> command line wallet.
+
*:package-name:<code> tezos-shell </code>(ディレクトリ:src:<code> src / lib_shell / test / </code>):チェーンデータストレージをテストします。
* :package:<code>tezos-client-genesis</code> contains the basic dictator commands available on the genesis protocol.
+
*:package-name:<code> tezos-stdlib </code>(ディレクトリ:src:<code> src / lib_stdlib / test / </code>):基本的なデータ構造をテストします。
* :package:<code>tezos-client-base-unix</code> implements configuration file and wallet storage in Unix files, user interaction via the Unix console, and terminal based signer plug-ins.
+
*:package-name:<code> tezos-storage </code>(ディレクトリ:src:<code> src / lib_storage / test / <code>):バージョン管理されたKey-Valueコンテキストをテストします。
 +
*:パッケージ名:<code> tezos-client-alpha </code>、パッケージ名:<code> tezos-baking-alpha </code>(ディレクトリ:src:<code> src / proto_alpha / lib_baking / test / </code>):OCamlクライアントライブラリのテスト。RPCを介してサンドボックス化されたノードへのさまざまな短いシナリオを実行します。
 +
*:パッケージ名:<code> tezos-protocol-alpha </code>(ディレクトリ:src:<code> src / proto_alpha / lib_protocol / test / </code>):アルファプロトコルのテストノード)。
 +
*:package-name:<code> tezos-crypto </code>(ディレクトリ:src:<code> src / lib_crypto / test / </code>):社内のMerkleツリーをテストします。
 +
*:package-name:<code> tezos-data-encoding </code>(ディレクトリ:src:<code> src / lib_data_encoding / test / </code>):JSONとバイナリのシリアル化とデシリアライズをテストします。
  
Tests Packages <sub><sub><sub><sub><sub><sub>~</sub></sub></sub></sub></sub></sub>~
+
最終実行可能ファイル<sub> <sub> <sub> <sub>?</sub> </sub> </sub>?<sub>?</sub>?</sub> ~~
  
The tests are splitted into various packages, testing more and more elements while following the dependency chain. Use <code>make test</code> to run them.
+
*:package:<code> tezos-node </code>は、ノードランチャーのバイナリ<code> tezos-node </code>を提供します。すべてのアルゴリズムがシェルに実装されていますが、このパッケージはノードのCLIのみを実装しています。また、サンドボックス化されたノードシェルスクリプトランチャーも提供します(主なreadmeを参照してください)。
 +
*:package:<code> tezos-client </code>は、<code> tezos-client </code>および<code> tezos-admin-client </code>バイナリを提供します。前者には小文字のwalletが、後者にはノード用の管理ツールが含まれています。また、サンドボックス化されたノードと対話するシェル環境を構成するシェルスクリプトも提供します。
 +
*:package:<code> tezos-baker-alpha </code>は、<code> tezos-alpha-baker </code>バイナリを提供します。
 +
*:package:<code> tezos-protocol-compiler </code>は、新しいプロトコルをオンザフライでコンパイルするためにノードによって使用される<code> tezos-protocol-compiler </code>バイナリを提供し、新しいプロトコルを開発するためのものです。
  
* :package-name:<code>tezos-client</code> (in directory :src:<code>src/bin_client/test/</code>): end-to-end tests as shell scripts that launch a local sandboxed node and performs various tasks using the client
+
.. | Tezosソースパッケージ図| image :: packages.svg
* :package-name:<code>tezos-p2p</code> (in directory :src:<code>src/lib_p2p/test/</code>): tests of the peer-to-peer layer, independently of the Tezos gossip protocol (establishing connections, propagating peers, etc.)
 
* :package-name:<code>tezos-protocol-environment</code> (in directory :src:<code>src/lib_protocol_environment/test/</code>): tests for the in-memory context implementation.
 
* :package-name:<code>tezos-shell</code> (in directory :src:<code>src/lib_shell/test/</code>): tests for the chain data storage.
 
* :package-name:<code>tezos-stdlib</code> (in directory :src:<code>src/lib_stdlib/test/</code>): tests for the basic data structures.
 
* :package-name:<code>tezos-storage</code> (in directory :src:<code>src/lib_storage/test/</code>): tests for the versioned key-value context.
 
* :package-name:<code>tezos-client-alpha</code>, :package-name:<code>tezos-baking-alpha</code> (in directory :src:<code>src/proto_alpha/lib_baking/test/</code>): tests of the OCaml client library, performing various short scenarios via RPCs to a sandboxed node.
 
* :package-name:<code>tezos-protocol-alpha</code> (in directory :src:<code>src/proto_alpha/lib_protocol/test/</code>): tests of the alpha protocol (without launching a node).
 
* :package-name:<code>tezos-crypto</code> (in directory :src:<code>src/lib_crypto/test/</code>): tests for the in-house merkle trees.
 
* :package-name:<code>tezos-data-encoding</code> (in directory :src:<code>src/lib_data_encoding/test/</code>): tests for the JSON and binary serialization and deserialization.
 
 
 
The Final Executables <sub><sub><sub><sub><sub>~</sub></sub></sub></sub><sub>~</sub>~</sub>~~
 
 
 
* :package:<code>tezos-node</code> provides the node launcher binary <code>tezos-node</code>. All the algorithmic being implemented in the shell, this package only implements the node's CLI. It also provides the sandboxed node shell script launcher (see the main readme).
 
* :package:<code>tezos-client</code> provides the <code>tezos-client</code> and <code>tezos-admin-client</code> binaries. The former contains a small comand line wallet, the latter an administration tool for the node. It also provides a shell script that configures a shell environment to interact with a sandboxed node.
 
* :package:<code>tezos-baker-alpha</code> provides the <code>tezos-alpha-baker</code> binary.
 
* :package:<code>tezos-protocol-compiler</code> provides the <code>tezos-protocol-compiler</code> binary that is used by the node to compile new protocols on the fly, and that can be used for developping new protocols.
 
 
 
.. |Tezos source packages diagram| image:: packages.svg
 

2018年5月31日 (木) 00:07時点における最新版

.. _software_architecture:

Tezosソフトウェアアーキテクチャ[編集]

この文書には2つのセクションがあります。誰にでも読めるはずの最初のセクションは、Tezosの主要な要素を遠くから説明しています。それは、すべての配管工事、および内部とシステムの両方の依存関係から抽象化して、主要コンポーネント、責任、および相互作用の簡単な表示を提供します。 2番目の部分は開発者向けに書かれたもので、OPAMパッケージのレベルにあります。

大きな画像[編集]

.. _大きな絵:

下の図は、Tezosの非常に粗粒度のアーキテクチャを示しています。

| Tezosアーキテクチャ図|

Tezosをユニークなものにする特徴は、自己修正の特性です。自分自身を補正する部分は、「経済的な議定書」(タコの緑色の目)と呼ばれ、プロトコルによって短縮されることもありますし、ソースコード内でプロトタイプさえもあります。 Tezosノードの残りの部分は、「シェル」(青いタコ)と呼ばれています。

このプロトコルは、トランザクションおよびその他の管理操作の解釈を担当します。また、誤ったブロックを検出する責任もあります。

注意すべき重要なことは、プロトコルが常に1つのブロックチェーンだけを見ることです。言い換えれば、起源以来のブロックの線形シーケンス。ノードが代替ヘッドを提案できるオープンなネットワークに存在することは知られていません。

シェルだけが複数のヘッドについて知っています。それは、ネットワークのパン屋(新しいブロックを調理するプログラム)から来る様々なチェーンの提案の中から選択する責任があります。シェルは、代替チェーンを選択してダウンロードし、プロトコルにフィードし、エラーをチェックして絶対的なスコアを与える責任があります。シェルは単に、最高絶対スコアの有効な頭部を選択するだけです。シェルのこの部分は、ref:バリデータ<validation> と呼ばれます。

残りのシェルには、ピアツーピア層、ブロックのディスクストレージ、ノードがチェーンデータを新しいノードに送信するための操作、および元帳のバージョン管理された状態が含まれます。検証者の間で、ピアツーピア層とストレージは、新しいチェーンデータの取得と複製をバリデータに抽象化する分散データベースと呼ばれるコンポーネントを配置します。

プロトコルは、2つのことをする微調整されたOCamlコンパイラ(画像の左側の緑色の部分)を使用してコンパイルされます。まず、プロトコルのメインモジュールが正しいタイプであることをチェックします。プロトコルをプラグインと見なすのが良いアナロジーです。この場合、共通のプラグインインターフェイスを尊重していることを意味します。次に、認可されたモジュールと関数だけを呼び出すように、プロトコルのコードの型定義環境を制限します。プロトコルをプラグインとして見ると、コードはプラグインAPIからのプリミティブのみを呼び出すことになります。これは、静的に強制されるサンドボックスの一種です。

最後に、RPCレイヤ(画像の右側の黄色)はノードの重要な部分です。これは、クライアント、サードパーティのアプリケーションとデーモンがノードとやり取りしてその状態を調べる方法です。このコンポーネントは、メインストリームのJSON形式とHTTPプロトコルを使用します。コード:ocplib-resto </code>と ocplib-json-typed を使用します(モジュール:ref: Data_encoding&lt; data_encoding&gt; )。これは、JSONスキーマを使用して、完全に相互運用可能で、自動記述的です。

.. | Tezosアーキテクチャ図| image :: octopus.svg

ソフトウェアアーキテクチャとパッケージrelashionships[編集]

..パッケージ:

以下の図は、Tezosのソースコードに含まれる主なOPAMパッケージとその依存関係を示しています。分かりやすくするために、 tezos - 接頭辞を削除しました。

| Tezosソースパッケージ図|

下の緑色にはバイナリがあります。黄色で伏せたのは、OPAMパッケージ(時には短縮名)です。黒い矢印は直接の依存関係を示しています。オレンジ色の矢印は、以下に説明する他の間接的な関係(コード生成、インターフェース共有)を示しています。青色で囲まれた部分には、Unixに依存しないモジュールが含まれているため、JavaScriptにコンパイルすることができます。この図には外部依存関係は示されていません。

ベースとそれ以下の ? ?

その中心にある:package: tezos-base パッケージは、ブロックチェーン固有のコードが始まる場所です。これは基本的な操作のためにどこでも使用されるライブラリのセットです。

  • :package: tezos-stdlib には、OCaml標準ライブラリ(いくつかの文字列プリミティブ、 Option モジュールなど)上にいくつかの拡張機能が含まれています。 </code>ユーティリティ、および単体比較演算子を実装する Compare モジュールがあります。
  • :package: tezos-data-encoding は社内のコミニュナーベースの直列化ライブラリです。単一の型記述 t encoding から、コードはバイナリとJSONの両方の表現 t 型の値を読み書きできます。どちらの場合でも、図書館は、文書のコンビネータを使用して、機械可読文書と人間が書くことができる文書を提供します。 JSONの部分は、opam: ocplib-json-typed に依存します。 A:ref:チュートリアル&lt; data_encoding&gt; はこのライブラリで使用できます。
  • :package: tezos-error-monad はOCamlの( 'a、' b)結果型への社内モナドインタフェースであり、 b </code>を拡張可能なタイプの error (実際にはエラートレースを保持するリスト)に変換します。型を拡張する場合、プログラマは、きれいなプリンタと直列化のためのエンコーディングを登録する register_error 関数も呼び出す必要があります。 A:ref:チュートリアル&lt; error_monad&gt; は、このライブラリで使用できます。
  • :package: tezos-rpc は、TezosのRPCサービスメカニズムの基本を提供します。 Ocsigen / Eliomのサービス階層を構築し、サービスを登録および呼び出しするためのコンビネータを提供します。このモジュールはopam: ocplib-resto に基づいています。これは、マシンの自動生成と人間が理解できるサービスの階層を可能にします:URLの構造と入出力本体 data_encoding を使用します。
  • :package: tezos-crypto は、私たちが使用する外部暗号ライブラリをラップします。可能な限り薄いバインディングで最小限のリファレンス実装を使用しようとしています。可能な計画は、HACLプロジェットからのライブラリを使用することです。そのため、すべての暗号はFstarから、薄いCバインディングで、またはOCamlで直接抽出されます。
  • :package: tezos-micheline はスマート契約の言語であるマイケルソンが使用する具体的な構文です。ほとんどの場合、汎用の型なしAST、プリンタ、パーサが含まれています。
  • :package: tezos-base は、これらすべてのモジュールをTezosの他のすべてのコンポーネントの共通基盤にまとめ、ブロックチェーンのデータ構造を導入します( Block_hash シェル、経済プロトコル、クライアント、デーモン、および第三者間で共有される Block_header Block_locator Fitness P2pidentity 。また、特定のタイプのオールインワンモジュールを構築するファンクタとして、 crypto からいくつかのモジュールを再ラップします(たとえば、ブロックハッシュ用のモジュールには、すべてのコンバータ、コマンドラインとRPC引数ビルダー、プリンタ、オートコンプリータなど)。このパッケージには、一部の実行可能ファイルでコマンドライン解析を処理するために使用する cli_entries モジュールも含まれています。

シェル?? ?

シェルは、すべての通信、ピアツーピアおよびRPCを担当するノードの一部であり、経済プロトコルの周りの繭として機能します。

  • :package: tezos-shell-services には、ノードのサービス階層の定義、およびクライアント(またはサードパーティのソフトウェア)で使用する関数の呼び出しが含まれます。このライブラリは、型安全な方法でサービスを呼び出すためにクライアントにリンクされているため、ここではサービスの記述のみが行われます。ハンドラの登録は、ノードの残りの実装で行われます。
  • :package: tezos-rpc-http は、opam: cohttp を使ってRPC over HTTPサーバとクライアントを実装し、以下を使用して宣言されたサービスを実際に使用できるようにします:package: tezos-rpc
  • :package: tezos-p2p は社内ピアツーピア層です。
  • :package: tezos-storage には、連鎖データに使用される生の単純なキー値ストアと、元帳のコンテキスト(ブロックごとに1つのバージョン)を格納するために使用される生バージョンキー付き値ストアが含まれます。これはopam: irmin と現在:opam: leveldb を使って実装されています。
  • :package: tezos-protocol-updater は、利用可能なプロトコルバージョンのテーブルを、埋め込みまたは動的にリンクしています。
  • :package: tezos-shell は、ブロック検証、mempool管理、および分散データベースのスケジューリングを実装します。説明は次のとおりです:ref:このドキュメント<validation>

経済プロトコル環境とコンパイラ ?< / sub> >? ?

経済プロトコルは、OCamlコンパイラの特定のバージョンによってコンパイルされます。このコンパイラは、静的なサンドボックス化の一形式として、経済的プロトコルに利用可能なモジュールのセットを制限します。また、代替環境でプロトコルの実行を可能にするために、プロトコルのファンクション化されたバージョンを生成します。

  • :package: tezos-protocol-environment-sigs には、経済的プロトコルで利用可能なモジュールが含まれています。このサンドボックスのレビューは、ref: here&lt; protocol_environment&gt; で利用できます。このモジュールには、標準ライブラリを削除し、暗号API、RPC定義、およびキー値ストアへのインタフェースが含まれています。
  • :package: tezos-protocol-compiler は、経済的なプロトコルのコンパイラです。OCamlの代替ドライバ:プロトコル環境内の型チェックを行うopam: ocaml-compiler-libs プロトコルコードについてさらに検査を行う。
  • tezos-protocol-xxx は、プロトコルコンパイラによって生成され、その標準ライブラリをパラメータとして持つプロトコル xxx のファントレイ化バージョンを含んでいます。このパラメータは、以下の2つの実装で実装できます。
  • :package: tezos-protocol-environment-shell はRPCサービスの登録とストレージアクセスがノードのものである環境のインスタンスです。これは、新しいプロトコルをロードするときにノードによって供給される環境です。
  • :package: tezos-protocol-environment には、プロトコル環境の3つの代替インスタンスが含まれています。コンテキストアクセス機能は、プロトコルのタイプおよび非コンテキスト機能のみが必要な場合に使用できるダミーのものですテスト用にメモリ内のキー値ストアをシミュレートするもの、およびいくつかのコンテキストアクセサから環境を構築できるようにするファンクタです。
  • tezos-embedded-protocol-xxx には、標準ライブラリがシェルの実装にプリインスタンス化されているプロトコル xxx のバージョンが含まれています。 。それには、ノードのプロトコルテーブルにプロトコルを登録するモジュールが含まれています。

組込み経済議定書 ? sub>

主なTezosリポジトリには、3つの経済的なプロトコルが含まれています。

  • :パッケージ:起源ブロックのプロトコルは、 tezos-protocol-genesis (パッケージ: tezos-embedded-protocol-genesis )です。これは、公開鍵がハードコードされている独裁者によって署名された単一のブロックを受け入れ、その単一のアクションは独裁者によって選択された新しいプロトコルに切り替えることである。
  • :パッケージ:Tezos-protocol-alpha(:package: tezos-embedded-protocol-alpha )はTezosの最初の実プロトコルです。 A:ref:チュートリアル&lt; enter_alpha&gt; を使用して、プロトコルのコードを読むことができます。
  • :package: tezos-protocol-demo (パッケージ: tezos-embedded-protocol-demo )は、面白いことはしませんが、正しい形をしたデモプロトコルです。

クライアントライブラリ? ? ~~

クライアントは多くのパッケージに分割されており、シェルと経済プロトコル、Unix依存とJavascript互換、ライブラリ対コマンドラインインタフェースの3つの分離線を適用しています。

  • :package: tezos-client-base はクライアントコンテキストを定義します。クライアントコンテキストはメソッドがキーのウォレットへのアクセス、ユーザー経由の対話、RPC呼び出し、署名者によるデータ署名を可能にするオブジェクトですプラグイン。パッケージ: tezos-shell-services と:package: tezos-protocol-alpha のRPC呼び出し関数を含むほとんどのものは、このオブジェクト型で抽象化されています。そうすれば、ツールキットのさまざまなプラットフォームに同じコードを使用することができます。
  • :package: tezos-client-alpha は、クライアントコンテキストからウォレットと署名者を使用してプロトコルアルファの操作を実行するためのいくつかの関数を提供します。
  • :package: tezos-client-commands は、 tezos-client-commands コマンドのハンドラとしてパッケージ: tezos-client-base クライアント</code>コマンドラインウォレットを使用します。
  • :パッケージ: tezos-client-alpha-commands は、 tezosのアルファ固有のコマンドのためのハンドラとしてパッケージ:<code> tezos-client-alpha -client </code>コマンドラインウォレット。
  • :package: tezos-client-genesis には、起源プロトコルで利用可能な基本的な独裁者のコマンドが含まれています。
  • :package: tezos-client-base-unix は、Unixファイルに設定ファイルとウォレットストレージ、Unixコンソールを介したユーザ対話、ターミナルベースの署名者プラグインを実装しています。

テストパッケージ ? ?

テストはさまざまなパッケージに分割され、依存関係のチェーンに沿って、ますます多くの要素がテストされます。実行するには make test を使用します。

  • :package-name: tezos-client (ディレクトリ内:src: src / bin_client / test / ):シェルスクリプトとしてのエンドツーエンドテスト。サンドボックス化されたノードであり、クライアントを使用してさまざまなタスクを実行します
  • :package-name: tezos-p2p (ディレクトリ:src: src / lib_p2p / test / ):ピアツーピア層のテスト。 Tezosのゴシッププロトコル(接続の確立、ピアの伝播など)
  • :パッケージ名: tezos-protocol-environment (ディレクトリ:src: src / lib_protocol_environment / test / ):メモリ内コンテキストの実装をテストします。
  • :package-name: tezos-shell (ディレクトリ:src: src / lib_shell / test / ):チェーンデータストレージをテストします。
  • :package-name: tezos-stdlib (ディレクトリ:src: src / lib_stdlib / test / ):基本的なデータ構造をテストします。
  • :package-name: tezos-storage (ディレクトリ:src: src / lib_storage / test / <code>):バージョン管理されたKey-Valueコンテキストをテストします。
  • :パッケージ名:<code> tezos-client-alpha 、パッケージ名: tezos-baking-alpha (ディレクトリ:src: src / proto_alpha / lib_baking / test / ):OCamlクライアントライブラリのテスト。RPCを介してサンドボックス化されたノードへのさまざまな短いシナリオを実行します。
  • :パッケージ名: tezos-protocol-alpha (ディレクトリ:src: src / proto_alpha / lib_protocol / test / ):アルファプロトコルのテストノード)。
  • :package-name: tezos-crypto (ディレクトリ:src: src / lib_crypto / test / ):社内のMerkleツリーをテストします。
  • :package-name: tezos-data-encoding (ディレクトリ:src: src / lib_data_encoding / test / ):JSONとバイナリのシリアル化とデシリアライズをテストします。

最終実行可能ファイル ? ??? ~~

  • :package: tezos-node は、ノードランチャーのバイナリ tezos-node を提供します。すべてのアルゴリズムがシェルに実装されていますが、このパッケージはノードのCLIのみを実装しています。また、サンドボックス化されたノードシェルスクリプトランチャーも提供します(主なreadmeを参照してください)。
  • :package: tezos-client は、 tezos-client および tezos-admin-client バイナリを提供します。前者には小文字のwalletが、後者にはノード用の管理ツールが含まれています。また、サンドボックス化されたノードと対話するシェル環境を構成するシェルスクリプトも提供します。
  • :package: tezos-baker-alpha は、 tezos-alpha-baker バイナリを提供します。
  • :package: tezos-protocol-compiler は、新しいプロトコルをオンザフライでコンパイルするためにノードによって使用される tezos-protocol-compiler バイナリを提供し、新しいプロトコルを開発するためのものです。

.. | Tezosソースパッケージ図| image :: packages.svg