A quick overview
Above, you can see a graphical representation of Tezos' architecture and the relation between its individual elements.
To understand the architecture of the Tezos platform, one needs to comprehend the function of:
- the endorser,
- the baker,
- the accuser,
- the node, and
- the client.
A Tezos node is the local component of the system. It manages the context, which is the local knowledge of the Tezos blockchain state, and the connection to the gossip network and other nodes.
The gossip network is how Tezos nodes communicate to exchange blocks and operations with each other. The admin client, as well as the local endorser, baker, accuser, and client connect to the Tezos network through the node. The admin client can monitor peer-to-peer (P2P) connections.
As well as listening for updates to the context, the node can send operations to peers when instructed to by the client or emit new blocks when instructed by the baker. Furthermore, the node can endorse blocks when instructed by the endorser or report bad blocks when instructed by the accuser.
State changing operations propagate through the network via gossip between peers until a baker includes the operation in a block. An operation can propagate across several peers before it is included in a block. New blocks are currently produced about once per minute, but this could change in the future via the Tezos governance mechanism.
After initialisation, the node will sync up with the Tezos network. As the node processes blocks, it runs the operations in the blocks against the local copy of the context to create a new context. The latest block received is known as the head of the chain. Nodes advertise the latest chain head they have to other nodes in the network.
The node also gathers metadata about peers and multiple chains that may exist so it can select the best one based on its fitness. “Fitness” determines the quality of the chain leading up to that block.
The Tezos client is the main interface to the node. The client can read the context and inspect the state (get) and it can instruct the node to perform work such as broadcasting an operation to the network.
In Tezos, block creators are referred to as bakers. As the name suggests, the baker is responsible for baking (producing) new blocks. Bakers are connected to implicit accounts (more on implicit (tz1…) vs. originated (KT1…) accounts later) and compute baking rights on a per account basis based on a baker’s total stake (i.e. tokens participating in consensus). The baker is unique in that it needs direct access to the node data directory for performance reasons.
When the baker is selected to bake a block, it draws transactions from the mempool, which is the pool of operations that are known about (via gossip) but have not yet been included in a block.
Like the baker, the endorser is connected to an implicit account and computes endorsing rights on a per account basis based on a baker’s total stake. On receipt of new blocks it verifies the validity of the block. If the block is valid it will broadcast an endorsement operation.
The accuser is a daemon that monitors all blocks received. It looks for two indications of invalid blocks:
- When a baker has signed two blocks at the same block height (blocks at the same level);
- When an endorser injects more than one endorsement operation for the same baking slot.
Such irregularities trigger double-baking and double-endorsing operations that cause the offender to lose a portion of its stake (i.e. a security deposit).
Tezos itself is implemented in OCaml. OCaml is a functional programming language used in mission-critical industries that require formal proofs of properties of programs. There also is Michelson, a domain-specific language used to write smart contracts on Tezos. It is stack-based, strongly typed, and designed to facilitate formal verification so developers can more easily prove smart contract properties.
There are several other Tezos smart contracts languages. SmartPy is an intuitive and effective smart contracts language and development platform that will allow Python developers to write smart contracts on Tezos. LIGO is a statically typed high-level language that compiles down to Michelson. The syntaxes that are currently supported are PascaLIGO (pascal-like syntax), CameLIGO (caml-like syntax), and ReasonLIGO (reason-like syntax). Additionally, Morley/Lorentz is a library to write Michelson contracts in Haskell. The Juvix smart contract language supports Michelson and includes a standard library with Michelson primitive types and operations.
Watch Arthur Breitman talk about Tezos.