go-basic-blockchain

Educational Blockchain Implementation in Go with Advanced Consensus & Comprehensive Learning Course
Welcome to go-basic-blockchain, an educational project designed to demystify blockchain technology through a hands-on, from-scratch implementation in Go. This project serves as both a comprehensive learning tool and a fully functional blockchain implementation for developers, students, and blockchain enthusiasts.
π― Built Completely From Scratch: This blockchain implementation uses no third-party blockchain libraries (no go-ethereum, Bitcoin, Tendermint/Cosmos, etc.) and includes our custom Helios consensus algorithm - all created from the ground up to fully teach Go programming and blockchain development.
π NEW: Complete Learning Course - This project now includes a comprehensive 19-section course covering everything from Go fundamentals to production deployment!
π― NEW: Fully Functional Blockchain Node - Complete, operational blockchain with continuous mining, proper data persistence, and smooth progress monitoring.
π Learning Course
This repository includes a comprehensive learning course with 19 sections organized into 4 phases:
Course Structure
- Phase 1: Foundation (Sections 1-5) - Go fundamentals and basic blockchain
- Phase 2: Advanced Features (Sections 6-10) - Advanced consensus and APIs
- Phase 3: User Experience (Sections 11-15) - Web and mobile applications
- Phase 4: Production Quality (Sections 16-19) - Testing and deployment
What You'll Learn
- Go Programming: Master Go fundamentals, concurrency, and advanced patterns
- Blockchain Development: Build complete blockchain systems from scratch
- Advanced Consensus: Implement sophisticated consensus algorithms (Helios)
- API Development: Create professional RESTful APIs with authentication
- Web Development: Build responsive web applications with React
- Mobile Development: Create cross-platform mobile apps with React Native
- Testing: Implement comprehensive testing strategies
- Deployment: Deploy production-ready applications
Course Features
- 80-109 hours of comprehensive content
- 19 sections with hands-on exercises
- 19 quizzes with detailed answer keys
- 4 major milestones with working deliverables
- Production-ready portfolio project
Start Learning β | Complete Course Overview β
π§ Blockchain Implementation
Key Features
- Built from Scratch: Every component implemented from the ground up
- Advanced Consensus: Implements the Helios consensus algorithm with three-stage validation
- Go Programming Language: Utilizing Go's simplicity and efficiency for complex systems
- Readable JSON Format: Human-readable JSON for data structures and storage
- No Third-Party Dependencies: Encourages deep understanding of core blockchain concepts
- Educational Focus: Thoroughly commented and documented with design explanations
- Optimized Test Suite: Fast, reliable tests with smart scrypt configuration
- Sidechain Routing: Advanced transaction routing through specialized protocols
- Continuous Mining: Automatic block creation and mining with proper state management
- Professional Build System: Organized binary output with cross-compilation support
Current Status
- Test Coverage: 39.8%
- Test Suite Performance: ~9.5 seconds (30x faster than before)
- Implementation Status: ~95% complete
- Helios Consensus: β
Fully integrated and tested
- Blockchain Functionality: β
Fully operational with continuous mining
π Quick Start
For Learning
- Start with the Learning Course
- Follow the structured progression through all 19 sections
- Build your blockchain step by step with hands-on exercises
For Blockchain Implementation
-
Clone the repository:
git clone https://github.com/yourusername/go-basic-blockchain.git
cd go-basic-blockchain
-
Install dependencies:
go mod tidy
-
Run tests to verify everything works:
make test
-
Start the blockchain node:
make run
Or run the binary directly:
./bin/release/gbbd
-
Access the web interface at http://localhost:8200
ποΈ Architecture Overview
Helios Consensus Algorithm
The project implements the Helios consensus algorithm, a sophisticated three-stage consensus mechanism:
- Stage 1 - Proof Generation: Miners create cryptographic proofs for transaction validation
- Stage 2 - Sidechain Routing: Transactions are routed through specialized protocols (BANK, MESSAGE, etc.)
- Stage 3 - Block Finalization: Validated blocks are finalized with proof verification
Key Components
- Blockchain Core: Main blockchain implementation with Helios integration and continuous mining
- Wallet System: Encrypted wallet management with key derivation
- API Layer: RESTful endpoints with authentication middleware
- P2P Network: Peer-to-peer communication framework
- Sidechain Router: Transaction routing through specialized protocols
- Test Suite: Comprehensive testing with optimized performance
- Progress Indicator: Real-time status monitoring with smooth updates
- Build System: Professional Makefile with cross-compilation and organized output
π Project Structure
go-basic-blockchain/
βββ learn/ # Comprehensive learning course (19 sections)
β βββ README.md # Course overview and navigation
β βββ COURSE_OVERVIEW.md # Detailed course guide
β βββ phase1/ # Foundation (Sections 1-5)
β βββ phase2/ # Advanced Features (Sections 6-10)
β βββ phase3/ # User Experience (Sections 11-15)
β βββ phase4/ # Production Quality (Sections 16-19)
βββ cmd/ # Application entry points
β βββ gbb-cli/ # Command-line interface
β βββ chaind/ # Blockchain daemon
β βββ demo/ # Demo applications
βββ internal/ # Core blockchain implementation
β βββ helios/ # Helios consensus algorithm
β βββ menu/ # User interface components
β βββ progress/ # Progress tracking
βββ docs/ # Technical documentation
βββ test/ # Test files and examples
βββ bin/ # Compiled binaries
βββ data/ # Blockchain data storage
βββ scripts/ # Build and deployment scripts
βββ postman/ # API testing collections
π Documentation
Learning Resources
Technical Documentation
π§ͺ Testing
The project includes a comprehensive test suite with optimized performance:
- Test Coverage: 39.8%
- Test Execution Time: ~9.5 seconds (30x faster than before)
- Smart Scrypt Configuration: Automatic switching between test and production security levels
- Timeout Protection: All tests have 60-second timeouts to prevent hanging
- Helios Tests: Comprehensive testing of the consensus algorithm
- Blockchain Tests: All blockchain functionality tests passing
Run tests with:
make test
π§ Development
Building
make build # Build release binary
make debug # Build debug binary with debugging symbols
make build-all # Build for all platforms (Linux, Windows, macOS, ARM64, AMD64)
Running
make run # Build and run release binary
make run-bin # Run existing release binary
make debug # Build and run debug binary with delve debugger
./bin/release/gbbd # Run release binary directly
./bin/debug/gbbd # Run debug binary directly
Testing
make test # Run all tests
make test-short # Run short tests
make test-unit # Run unit tests only
make test-coverage # Run with coverage
Development
make setup # Setup dependencies
make fmt # Format code
make lint # Run linter
make clean # Clean build artifacts
make clean-data # Clean blockchain data
make clean-all # Clean everything
Release
make release # Build all cross-compiled binaries
Documentation Generation
make docs
- Test Suite: 30x faster execution (9.5 seconds vs 5+ minutes)
- Scrypt Optimization: Smart configuration for development vs production
- Memory Usage: Optimized for educational use
- Network Latency: Minimal overhead in P2P communication
- Blockchain Operation: Continuous mining with proper state management
- Progress Display: Smooth, non-flickering status updates
ποΈ Build System
The project features a professional build system with:
- Cross-Compilation: Build for Linux, Windows, macOS (ARM64, AMD64)
- Binary Organization: Separate
bin/debug/
and bin/release/
directories
- Go 1.22 Compatibility: Latest Go version with toolchain specification
- Dependency Management: Proper
go.mod
and go.sum
handling
- Clean Targets: Organized cleanup with dependency preservation
π― Learning Paths
For Complete Beginners
- Start with Phase 1: Foundation
- Complete all sections in order
- Build your first blockchain in Section 5
- Progress through each phase sequentially
For Experienced Developers
- Review Phase 1 for Go/blockchain basics
- Jump to Phase 2 for advanced features
- Focus on Phase 3 for user interfaces
- Complete Phase 4 for production deployment
For Specific Skills
π€ Contributing
We welcome contributions! Please see our Contributing Guide for details.
π License
This project is licensed under the MIT License - see the LICENSE file for details.
Ready to explore the future of blockchain technology? Choose your path:
π Start Learning β - Begin the comprehensive 19-section course
π§ Explore Implementation β - Dive into the technical documentation
π Quick Start β - Get the blockchain running immediately
Transform from beginner to production-ready blockchain developer with our complete learning experience!