Note: if you find this guide useful, please, share the guide with your friends, so they take the same advantage as you do by learning the fundamental blockchain concepts and practicing how to build a blockchain in Go from scratch
A foundational and practical guide for effectively learning the fundamental blockchain concepts and progressively building a blockchain from scratch in Go with gRPC. An interesting and challenging adventure that takes you from the foundational concepts and purpose through the technical design and implementation to the practical testing and usage of the proposed blockchain
- Simple, yet non-trivial
- The guide introduces the blockchain concepts that are simple to understand and the technical design solutions that are simple to implement. However, the proposed blockchain is not trivial. The blockchain has all the key components of a modern blockchain: the state initialization and synchronization, the peer discovery, the transaction relay, the block proposer with the block validators being part of the Proof of Authority (PoA) simple consensus, the block relay, the event stream of domain events, the gRPC server, and the graceful node shutdown
- Concise, yet detailed
- The guide describes the fundamental blockchain concepts and the technical design solutions in the concise and clear form, focusing on the purpose what and the reasons why behind the key blockchain components. Enough details behind the technical design solutions are provided to support deeper understanding of the internal working of the components of the proposed blockchain
- Practical, yet well-grounded
- The guide emphasizes the learn by doing approach to effectively learning the fundamental blockchain concepts and progressively building the blockchain components from scratch. Practical experience of developing, testing, and using the proposed blockchain is a great motivator to get deeper understanding of the fundamental blockchain concepts and the technical design solutions. Once the key mechanics of the blockchain components are understood, the more abstract theoretical concepts naturally fill the gaps in the knowledge acquired through practical experiments
Prerequisites, dependencies, installation, testing, directory structure
Blockchain account, account address, account balance, create account, persist account, re-create account, Secp256k1 account, Keccak256 account address, Secp256k1 key pair, Keccak256 hash function, AES-GCM encryption with Argon2 KDF
Blockchain transaction, transaction nonce, double spending problem, transaction replay attack, sign transaction, verify transaction, search transactions, Keccak256 hash function, ECDSA Secp256k1 digital signature, ECDSA Secp256k1 transaction verification, gRPC server streaming, Go iterators
Blockchain genesis, blockchain block, chain of blocks, block store, create genesis, persist genesis, re-create genesis, persist block, re-create block, search blocks, Keccak256 hash function, ECDSA Secp256k1 digital signature, ECDSA Secp256k1 block verification, gRPC server streaming, Go iterators
Blockchain state, confirmed state, pending state, apply transaction, transaction life cycle, create block, apply block, block life cycle, concurrency safe application of transactions and blocks, Go mutex concurrency
Merkle tree, Merkle proof, transaction inclusion verification, create Merkle tree, derive Merkle proof, verify Merkle proof, array representation of Merkle tree, combination of hashes, Go generics
Blockchain initialization, state synchronization algorithm, initialize bootstrap node, synchronize out-of-sync node, create genesis, synchronize genesis, read blocks, synchronize blocks, Go iterators
Peer discovery, bootstrap node, seed node, concurrency safe peer discovery, peer discovery algorithm, node graceful shutdown mechanism, Go mutex concurrency, Go context, Go channel composition
Transaction relay, concurrency safe peers monitoring, concurrent generic message relay, gRPC client streaming, Go channel concurrency, Go channel composition, Go channel multiplexing, Go generics
Proof of Authority consensus, block proposer algorithm, block relay, gRPC client streaming, Go channel concurrency, Go channel composition, Go channel multiplexing, Go generics
Node event stream, event publisher, concurrency safe event streaming, domain event multiplexing, gRPC server streaming, Go mutex concurrency, Go channel concurrency, Go channel composition, Go channel multiplexing
Blockchain node, peer-to-peer network of nodes, peer discovery, state sync, confirmed state, pending state, transaction relay, Proof of Authority consensus, block proposer, block relay, block application, block confirmation, event stream, node graceful shutdown mechanism, node gRPC server, node CLI, start node, blockchain peer-to-peer network with two nodes