Why we are writing a Tezos node/shell in Rust (with demo)

The Tezos ecosystem will benefit from an increase in the diversity of its nodes (multiple implementations across a range of different programing languages & operating systems). It allows us to verify that the protocol is unambiguous. It keeps the door open for innovation and secures the honesty of all participants.

Encouraging a range of teams to build and implement software in a variety of nodes creates an environment where bugs and logical oversights will emerge before they can affect the ecosystem.

Since no single implementation has complete responsibility for validating the chain, bugs are more likely to stay localized to a subset of nodes and less likely to affect the blockchain as a whole.

Expanding the number of nodes will draw more people towards the Tezos protocol. By increasing the number of Tezos users, more individuals will consistently review the baking process and the Tezos protocol as a whole. This reduces the chance of consensus issues arising when it’s too late.

Even if there is an attack vector or bug in any of the Tezos implementations, the network will remain intact as there is a diverse range of nodes available.

Programming languages each have their own advantages, so users can decide between different nodes based on the needs of specific applications on a case-by-case basis.

Security is our main goal. We chose Rust because it enforces memory safety and supports concurrency while avoiding race conditions.

By programming a Tezos node in Rust, we will attract a broad range of developers. For the 3rd year in a row, Rust has maintained its position as the most loved programming language among 62,596 respondents polled by Stack Overflow in its annual developer survey.

The current state of node (PoC)

The purpose of this project is to implement a secure, trustworthy, open-source Tezos node in Rust. In addition to implementing a new node, the project seeks to maintain and improve the Tezos node wherever possible.

The project can be considered as a proof of concept. This PoC demonstrates the viability of a node build that uses Rust.

The current PoC of the Tezos node consists of multiple components which are yet to be fully implemented:

p2p/client : This is the p2p component responsible for receiving and sending messages within Tezos network. Internally, p2p allocates a component, called a p2p-peer, for each node within the reachable network. The p2p-peer listens to incoming messages from peers and routes requests to individual peers. The p2p/client uses separate components for serialization/deserialization of messages between Tezos message format and Rust structures.

: This is the p2p component responsible for receiving and sending messages within Tezos network. Internally, p2p allocates a component, called a p2p-peer, for each node within the reachable network. The p2p-peer listens to incoming messages from peers and routes requests to individual peers. The p2p/client uses separate components for serialization/deserialization of messages between Tezos message format and Rust structures. data_encoding/de : All incoming messages are transformed into standard Rust structures for easy manipulation using de component. This component implements serialization and deserialization of all data types used in Tezos messages.

: All incoming messages are transformed into standard Rust structures for easy manipulation using de component. This component implements serialization and deserialization of all data types used in Tezos messages. crypto/box : Component contains cryptographic algorithms for encryption and decryption of messages

: Component contains cryptographic algorithms for encryption and decryption of messages storage/db : In the current phase (PoC), this is a very simplistic in memory DB for storing information about the current state of the blockchain. We will replace the component with a key-value database.

: In the current phase (PoC), this is a very simplistic in memory DB for storing information about the current state of the blockchain. We will replace the component with a key-value database. We use a rpc/server: the component used for the implementation of node-rs REST API. Using the nodes REST api, the user is able to get insights about the current state of the node as well as execute commands on the node

The relations between individual components are described in the diagram depicted below.

What node can currently do

The two diagrams shown below depict the interaction between objects in a sequential order. The sequence of actions is described in a short sentence written above each diagram.

Connect to the Tezos p2p network and listen for incoming connections

2. Return the current head.

How to run node (demo)

1. Install Rust

We recommend installing Rust through rustup.

Run the following in your terminal, then follow the onscreen instructions.

2. Rust version

Rust nightly is required to build this project.

rustup install nightly-2019–03–14 rustup default nightly-2019–03–14

The application has been tested to compile with `rustc 1.35.0-nightly (bc44841ad 2019–03–14)`.

3. Get repository



cd ./tezos-rs git clone https://github.com/simplestaking/tezos-rs.git cd ./tezos-rs

4. Building node

On linux systems:

export SODIUM_USE_PKG_CONFIG=1 cargo build

On Windows systems with vcpkg:

set SODIUM_USE_PKG_CONFIG=1 set VCPKGRS_DYNAMIC=1 cargo build

5. Run node

cargo run

RPC API

/network/points

Returns connected peers, after successful authentication.

/chains/main/blocks/head

Returns current head of chain.

Please note that this is a proof of concept. We advise you to not use this for anything else than testing purposes.

I appreciate all of your messages. If you have any trouble following these instructions or you want to leave any comments, please contact me at jurajselep@simplestaking.com.