Professional training course for developers in which participants build a blockchain from scratch in Rust. The project grows with each module: from the first signed transactions to a network of nodes that exchange blocks, synchronize the chain, and verify payment inclusion.
Participants implement the UTXO model, a mempool, on-disk persistence, and two consensus algorithms: Proof of Authority and Proof of Work. The course also covers validation of data received from peers, attacks on transactions and blocks, fork handling, and inclusion proofs with Merkle trees.
The course is available in Italian or English, in person in Turin or remotely. The full course consists of 20 half-day modules (4 hours each), for a total of 80 hours.
Participants need excellent programming skills in at least one other language and a computer running Linux, macOS, or Windows with WSL2. No prior knowledge of Rust or blockchains is required.
The syllabus is as follows:
- Introduction to Rust
- Installation, Cargo, and project structure;
- Variables, data types, and functions;
- Expressions and control flow;
- The
Stringtype;
- Ownership and borrowing
- Ownership and borrowing;
- Slices;
- Structs;
- Enums, modules, and collections
- Enums and pattern matching;
- Packages and modules;
- Vectors and hash maps;
- Errors, generics, traits, and lifetimes
- Error handling;
- Generics;
- Traits;
- Lifetimes;
- Cryptography and transactions
- Components of a blockchain;
- An interchangeable hash algorithm;
- Keys, signatures, and addresses;
- State management models;
- Transaction inputs, outputs, and signatures;
- Blocks and the chain
- Block structure and hash;
- The chain and out-of-order blocks;
- Unspent outputs and state updates;
- The mempool;
- Concurrency and asynchronous programming
- Threads, channels, and shared state;
- Async Rust and Tokio;
- Consensus
- Byzantine faults, safety, and liveness;
- The main families of algorithms and finality;
- A trait for consensus algorithms;
- The block production cycle and thread;
- The node
- Library, binary, and workspace;
- Command-line commands;
- Node configuration and identity;
- Genesis and Proof of Authority
- A deterministic genesis and the genesis file;
- Starting the node;
- Validators, determinism, and assigning turns;
- Building and verifying blocks;
- Block interval and empty blocks;
- Spending funds
- The UTXO model;
- Balance, change, and fees;
- The node console;
- Sending a transaction
- The
sendcommand; - Double spending in the mempool;
- Validator rewards and the coinbase;
- The
- Persistence
- Block serialization;
- The on-disk archive and recovery;
- Tampered archives, missing blocks, and interrupted writes;
- Networking: libp2p, connections, and transactions
- Addressing, protocols, transport, and security;
- The libp2p node and the Swarm;
- Configuration and the event loop;
- Broadcasting transactions with gossipsub;
- Blocks on the network
- Announcing blocks;
- Synchronization between nodes;
- A validator without an archive;
- A network of strangers
- Ownership of outputs;
- Overspending and overflow;
- The declared hash and input signatures;
- Received blocks
- Forged blocks;
- Consensus rules on received blocks;
- The absent validator;
- Proof of Work
- The puzzle and the nonce search;
- Mining and the block reward;
- Difficulty adjustment;
- Forks
- Choosing the chain with the most work;
- Reorganization;
- Probabilistic finality and the 51% attack;
- Merkle trees and the light client
- The Merkle tree and its root in the block;
- Inclusion proofs;
- Headers and payment verification;
- The limits of the light client;
Each module includes exercises on the project. In the final exercise, participants connect their nodes to a shared network, make transfers, and verify their inclusion in blocks. They also test node restarts, network partitions and reconnection, and the attacks studied during the course.