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

Juraj Selep
Mar 26, 2019 · 5 min read

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.

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.

  1. 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.

curl https://sh.rustup.rs -sSf | sh

2. Rust version

Rust nightly is required to build this project.

rustup install nightly-2019–03–14rustup 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

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

4. Building node

On linux systems:

export SODIUM_USE_PKG_CONFIG=1cargo build

On Windows systems with vcpkg:

set SODIUM_USE_PKG_CONFIG=1set VCPKGRS_DYNAMIC=1cargo build

5. Run node

cargo run

RPC API

/network/points

Returns connected peers, after successful authentication.

curl http://127.0.0.1:18732/network/points

/chains/main/blocks/head

Returns current head of chain.

curl http://127.0.0.1:18732/chains/main/blocks/head

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.


Follow us on Twitter, InvestFeed, Facebook, Instagram, LinkedIn, and join our Discord and Telegram.

Read about our upcoming Altcoin Magazine Mastermind Event here.

The Capital

The Capital (former Altcoin Magazine) is a social financial news aggregator powered by Bitcoin

Juraj Selep

Written by

The Capital

The Capital (former Altcoin Magazine) is a social financial news aggregator powered by Bitcoin

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade