A Polkadot SDK-like state machine written from scratch in Rust.

Overview

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.

We designed this tutorial 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.

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

Some commits are prefixed with template, and you will see these commits leave TODO comments throughout the code for what the reader should do to advance to the next step of the tutorial. Immediately following a template commit is a solution commit that completes all of the TODOs. The solution should always compile and run successfully (but there might be some compiler warnings).

Some commits do not have a template or solution step, in which case the user is not expected to write any code for that step, but instead do other actions like import new crates, or review code provided by the tutorial.

Each commit includes changes to the top level README.md file, which includes documentation and background information relevant for that step.

Exporting the Tutorial

Included with this repo is an export_tutorial.sh script.

This will generate an output folder where each commit is placed in an independent folder with the step number. For example:

output/
├─ 1/
│  ├─ src/
│  │  ├─ main.rs
│  ├─ Cargo.toml
│  ├─ README.md
├─ 2/
│  ├─ src/
│  │  ├─ main.rs
│  │  ├─ balances.rs
│  ├─ Cargo.toml
│  ├─ README.md
├─ 3/
│  ├─ ...

This should provide a very basic example of how to turn this repository into step by step documentation.

More specific tooling can be created to customize this process further for your specific needs and output.

Maintenance

This tutorial depends on having structured git history. To accomplish this, we use git in ways it was not intended. I apologize in advance to those offended by what they are going to read below.

This tutorial is updated and maintained by modifying its git history and force pushing changes back to master.

This allows us to maintain all the different snapshots of code needed by the reader, without having to individually maintain many copies of the same file. Making breaking changes to a step simply requires you to fix merge conflicts as you rebase those changes.

As a result, you should expect that the entire git history of this tutorial could change at any time.

You might also like...
Detect if code is running inside a virtual machine (x86 and x86-64 only).

inside-vm Detect if code is running inside a virtual machine. Only works on x86 and x86-64. How does it work Measure average cpu cycles when calling c

Code for connecting an RP2040 to a Bosch BNO055 IMU and having the realtime orientation data be sent to the host machine via serial USB

Code for connecting an RP2040 (via Raspberry Pi Pico) to a Bosch BNO055 IMU (via an Adafruit breakout board) and having the realtime orientation data be sent to the host machine via serial USB.

A simple interpreter for the mathematical random-access machine
A simple interpreter for the mathematical random-access machine

Random-access machine runner A simple Rust RAM program runner. Lexer/Parser Program executor Code formatter Web Compiled to WASM to run in the browser

Golang like WaitGroup implementation for sync/async Rust.

wg Golang like WaitGroup implementation for sync/async Rust.

Stopwatch lib for rust. Start, pause, reset and lap like any stopwatch.

Chronometer Stopwatch lib for rust. Start, pause, reset and lap like any stopwatch. Nothing special I'm just learning rust. Getting Started Add this l

hado-rshado — A little macro for writing haskell-like do expressions without too much ceremony

hado Monadic haskell-like expressions brought to rust via the hado! macro What? A little macro for writing haskell-like do expressions without too muc

Like jq, but for HTML. Uses CSS selectors to extract bits content from HTML files.

Like jq, but for HTML. Uses CSS selectors to extract bits content from HTML files. Mozilla's MDN has a good reference for CSS selector syntax.

Freebsd-embedded-hal - Like linux-embedded-hal but FreeBSD

freebsd-embedded-hal Implementation of embedded-hal traits for FreeBSD devices: gpio: using libgpio, with stateful and toggleable support, with suppor

Convert number like 42 to forty-two

num2words Convert number like 42 to forty-two Usage This crate can be either used as a library or a binary. Library Example usage: use num2words::Num2

Owner
Shawn Tabrizi
Discovery through experience. 12hAtDZJGt4of3m2GqZcUCVAjZPALfvPwvtUTFZPQUbdX1Ud
Shawn Tabrizi
Rust SDK wrapper for the Mystic Light SDK

mystic_light_sdk Rust SDK wrapper for the Mystic Light SDK Requirements Any MSI device with RGB support Only Windows 7+ Dragon Center or Msi Center in

null 4 May 3, 2022
Director is a simple, versatile, ergonomic state machine in Rust-lang.

Director Director is a simple, versatile, ergonomic state machine in Rust-lang. (no-std) | Examples | Docs | Latest Note | director = "0.5.0" Why? Bec

Doha Lee 2 Sep 19, 2022
Component-based state machine plugin for Bevy

seldom_state is a component-based state machine plugin for Bevy. It's useful for AI, player state, and other entities that occupy various states. It allows for greater reusability of state logic between entities, compared to managing mutually-exclusive components directly in your systems.

Seldom 43 Jan 2, 2023
Rust experiments involving Haskell-esque do notation, state, failure and Nom parsers!

Introduction As a long time Haskell developer recently delving into Rust, something I've really missed is monads and do notation. One thing monadic do

Kerfuffle 23 Feb 28, 2022
Rusoto is an AWS SDK for Rust

Rusoto is an AWS SDK for Rust You may be looking for: An overview of Rusoto AWS services supported by Rusoto API documentation Getting help with Rusot

null 2.6k Jan 3, 2023
High-performance, Reliable ChatGLM SDK natural language processing in Rust-Lang

RustGLM for ChatGLM Rust SDK - 中文文档 High-performance, high-quality Experience and Reliable ChatGLM SDK natural language processing in Rust-Language 1.

Blueokanna 3 Feb 29, 2024
💫 Small microservice to handle state changes of Kubernetes pods and post them to Instatus or Statuspages

?? Kanata Small microservice to handle state changes of Kubernetes pods and post to Instatus ?? Why? I don't really want to implement and repeat code

Noel ʕ •ᴥ•ʔ 4 Mar 4, 2022
A lightning fast state management module for Yew.

yewv A lightning fast state management module for Yew built with performance and simplicity as a first priority. Who is this for? If you wish to use a

null 7 Dec 8, 2022
A lightning fast version of tmux-fingers written in Rust, copy/pasting tmux like vimium/vimperator

tmux-thumbs A lightning fast version of tmux-fingers written in Rust for copy pasting with vimium/vimperator like hints. Usage Press ( prefix + Space

Ferran Basora 598 Jan 2, 2023
The tool like Browserslist, but written in Rust.

browserslist-rs The tool like Browserslist, but written in Rust. Try it out Before trying this crate, you're required to get Rust installed. Then, clo

Pig Fang 76 Nov 29, 2022