shawntabrizi / rust-state-machine

A tutorial for building a Polkadot SDK-like state machine written from scratch in Rust.
https://www.shawntabrizi.com/rust-state-machine/
MIT License
59 stars 21 forks source link
blockchain polkadot rust state-machine substrate tutorial

Rust State Machine

This repository is the basis for a tutorial teaching how to develop a simple state machine using Rust.

Goal

The goal of this tutorial is to teach by experience various entry level concepts around Rust and blockchain development.

This tutorial is opinionated, and heavily influenced by the Polkadot SDK, Substrate, and FRAME. However, everything in this tutorial is written from scratch and built without using these libraries.

The tutorial is designed with the hope that readers who complete it will have a better understanding of what is happening behind FRAME and will feel more capable of using the Polkadot-SDK successfully.

This tutorial will teach and review many Rust concepts, however it is not a replacement for a primary Rust education course. It is recommended, before you even start this tutorial, that you are already familiar with the concepts taught in the first 11 chapters of the Rust Book.

How To Use

This repository is not meant to be used directly, but as the source for generating an interactive tutorial using the source code and readme files included at each commit.

This repository manages 3 branches, each with its own history and purpose:

If you have small changes that need to be made to a single step, feel free to open an issue or make a PR against the master branch. However, for more complex changes which may affect multiple steps, consider learning more about the gitorial format.

More about Gitorial

The heart of this tutorial is the Gitorial format.

If you browse the commit history of the gitorial branch, you will see that each commit is designed to be a single step in the tutorial.

All commits are prefixed with one of:

You can use Git to make changes to the history of the repo, and then use git merge to propagate those changes cleanly into the rest of your repo.

Maintenance

Maintaining the repo means keeping all three of the main branches in sync.

For this, you can use the gitorial-cli.

Once you have made changes to the appropriate branch, you can use these commands to get all branches in order: