Skip to content

A comprehensive testing and analysis tool for the Rubix blockchain network that simulates real blockchain transactions, measures performance metrics, and generates detailed reports.

Notifications You must be signed in to change notification settings

rubixchain/rubix-simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

26 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Rubix Network Simulator

A comprehensive testing and analysis tool for the Rubix blockchain network that simulates real blockchain transactions, measures performance metrics, and generates detailed reports.

๐Ÿš€ Quick Start

One-Command Start (Recommended)

Windows

start-all.bat

Linux/Mac

chmod +x start-all.sh
./start-all.sh

This will automatically:

  • Start the Go backend server on port 8080
  • Start the Vite development server (React + TypeScript) on port 5173
  • Open your browser to http://localhost:5173

To stop all services, press Ctrl+C in the terminal or close the command windows.

๐Ÿ“‹ Prerequisites

  • Node.js (v18 or higher) - Download
  • Go (v1.21 or higher) - Download
  • Git - Download
  • Build tools:
    • Windows: MinGW or Visual Studio Build Tools
    • Linux: gcc, make
    • Mac: Xcode Command Line Tools

System Requirements

  • OS: Windows 10/11, Ubuntu 20.04+, macOS 11+
  • RAM: Minimum 8GB (16GB recommended for 20+ nodes)
  • Storage: 5GB free space
  • Ports: 8080, 5173, 20000-20030, 10500-10530 must be available

๐Ÿ› ๏ธ Manual Installation

If you prefer to set up manually or the start-all script doesn't work:

1. Clone the Repository

git clone <your-repository-url>
cd rubix-simulator

2. Install Frontend Dependencies

npm install

3. Install Backend Dependencies

cd backend
go mod download
cd ..

4. Start Services Separately

Terminal 1 - Backend:

# Option 1: Use helper script
./run-backend.sh      # Linux/Mac
run-backend.bat       # Windows

# Option 2: Manual start
cd backend
go run cmd/server/main.go

Terminal 2 - Frontend:

# Option 1: Use helper script
./run-frontend.sh     # Linux/Mac
run-frontend.bat      # Windows

# Option 2: Manual start
npm run dev

๐ŸŽฎ Using the Simulator

Understanding the Network

The simulator creates a Rubix blockchain network with two types of nodes:

  • Quorum Nodes (7): Fixed consensus nodes that validate all transactions
  • Transaction Nodes (2-20): Variable nodes that perform RBT token transfers

Running Simulations

  1. Open the Application

  2. Configure Simulation Parameters

    • Transaction Nodes: Enter 2-20 (these are added to the 7 quorum nodes)
    • Number of Transactions: Enter 1-500
    • Example: 3 transaction nodes = 10 total nodes (7 quorum + 3 transaction)
  3. Start Simulation

    • Click "Start Simulation" button
    • First run takes 5-10 minutes (downloads and builds Rubix platform)
    • Subsequent runs are faster (nodes remain running)
  4. Monitor Progress

    • Real-time progress bar shows completed transactions
    • Live metrics update as transactions complete
    • Transaction details display with status and timing
  5. View Results

    • Success/failure counts with percentage
    • Transaction timing (min/avg/max)
    • Total tokens transferred
    • Per-node performance breakdown
  6. Download Report

    • Click "Download PDF Report" for comprehensive analysis
    • Includes charts, graphs, and detailed transaction logs

Node Management

Important: Nodes remain running between simulations for faster testing.

  • Shutdown Nodes: Click "Shutdown All Nodes" button when finished testing
  • Script Shutdown: Use ./shutdown-nodes.sh (Linux/Mac) or shutdown-nodes.bat (Windows)
  • Auto-cleanup: Nodes automatically shut down when backend stops (Ctrl+C)
  • Fresh Start: Shutdown nodes โ†’ Start new simulation

๐Ÿ“Š Understanding Results

Transaction Flow

  1. Pairing: Nodes are paired (sender/receiver) to prevent conflicts
  2. Token Generation: Each sender creates 10 RBT tokens
  3. Transfer: Tokens sent via Rubix blockchain protocol
  4. Validation: Quorum nodes reach consensus
  5. Confirmation: Blockchain confirms transaction completion

Performance Metrics

  • Fast: < 1 minute (small amounts, optimal conditions)
  • Normal: 1-3 minutes (typical transactions)
  • Slow: 3-6+ minutes (large amounts or network congestion)

PDF Report Contents

  • Executive summary with key metrics
  • Transaction timeline visualization
  • Success/failure distribution charts
  • Token amount vs. time correlation
  • Node performance comparison
  • Complete transaction logs with IDs

๐Ÿ› Troubleshooting

Backend Connection Issues

Symptom: "Backend Offline" badge in UI

Solutions:

  • Ensure backend is running (go run cmd/server/main.go)
  • Check port 8080 is not in use: netstat -an | findstr 8080
  • Verify firewall settings allow localhost connections

Node Startup Failures

Error: "Failed to start Rubix nodes"

Solutions:

  • Check disk space (need ~500MB per node)
  • Ensure required ports are free (20000-20030, 10500-10530)
  • Delete backend/rubix-data folder and retry
  • Run with administrator/sudo privileges if needed

Transaction Failures

Symptom: High transaction failure rate

Solutions:

  • Ensure minimum 2 transaction nodes configured
  • Check backend logs for specific errors
  • Shutdown and restart nodes if running for extended period
  • Verify network connectivity

๐Ÿ“ Project Structure

rubix-simulator/
โ”œโ”€โ”€ backend/                 # Go backend server
โ”‚   โ”œโ”€โ”€ cmd/
โ”‚   โ”‚   โ”œโ”€โ”€ server/          # Server entry point
โ”‚   โ”‚   โ””โ”€โ”€ test_rubix/      # Test utilities
โ”‚   โ”œโ”€โ”€ config/             # Configuration files
โ”‚   โ”œโ”€โ”€ internal/            # Core business logic
โ”‚   โ”‚   โ”œโ”€โ”€ config/         # Config management
โ”‚   โ”‚   โ”œโ”€โ”€ handlers/       # HTTP request handlers
โ”‚   โ”‚   โ”œโ”€โ”€ middleware/     # HTTP middleware
โ”‚   โ”‚   โ”œโ”€โ”€ models/         # Data structures
โ”‚   โ”‚   โ”œโ”€โ”€ rubix/          # Rubix blockchain integration
โ”‚   โ”‚   โ””โ”€โ”€ services/       # Node, transaction, report services
โ”‚   โ”œโ”€โ”€ reports/            # Generated PDF reports
โ”‚   โ”œโ”€โ”€ rubix-data/         # Runtime node data (git-ignored)
โ”‚   โ”œโ”€โ”€ go.mod              # Go dependencies
โ”‚   โ””โ”€โ”€ README.md           # Backend documentation
โ”œโ”€โ”€ src/                     # React frontend (Vite + TypeScript)
โ”‚   โ”œโ”€โ”€ components/         # UI components
โ”‚   โ”‚   โ””โ”€โ”€ ui/             # Shadcn/ui components (Radix UI)
โ”‚   โ”œโ”€โ”€ hooks/              # React hooks
โ”‚   โ”œโ”€โ”€ lib/                # Utilities
โ”‚   โ””โ”€โ”€ pages/              # Application pages
โ”œโ”€โ”€ public/                  # Static assets
โ”œโ”€โ”€ package.json            # Frontend dependencies
โ”œโ”€โ”€ vite.config.ts          # Vite configuration
โ”œโ”€โ”€ tailwind.config.ts      # Tailwind CSS config
โ”œโ”€โ”€ start-all.bat           # Windows quick-start script
โ”œโ”€โ”€ start-all.sh            # Linux/Mac quick-start script
โ”œโ”€โ”€ run-backend.*           # Backend start scripts
โ”œโ”€โ”€ run-frontend.*          # Frontend start scripts
โ”œโ”€โ”€ shutdown-nodes.*        # Node shutdown scripts
โ””โ”€โ”€ README.md               # This file

๐Ÿ”ง Development

Running Tests

# Backend tests
cd backend
go test ./...

# Frontend linting
npm run lint

Code Format

# Backend formatting
cd backend
go fmt ./...

# Frontend linting and formatting
npm run lint

Adding Features

  1. Backend changes: Modify services in backend/internal/
  2. Frontend changes: Update components in src/components/
  3. API changes: Update handlers in backend/internal/handlers/

๐Ÿ“ˆ Performance Optimization

Recommended Settings

  • Quick Test: 2 nodes, 10 transactions
  • Standard Test: 5 nodes, 50 transactions
  • Stress Test: 15-20 nodes, 200-500 transactions

Resource Usage

  • Each node: ~100-200MB RAM
  • Backend server: ~50MB RAM
  • Frontend dev server: ~100MB RAM
  • Disk: ~50MB per node for blockchain data

๐Ÿ“ API Documentation

Key Endpoints

  • POST /simulate - Start new simulation
  • GET /report/{id} - Get simulation status
  • GET /reports/{id}/download - Download PDF report
  • POST /nodes/stop - Shutdown all nodes
  • GET /health - Backend health check

Simulation Request

{
  "nodes": 5,        // Transaction nodes (2-20)
  "transactions": 50  // Number of transactions (1-500)
}

๐Ÿค Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see LICENSE file for details.

๐Ÿ†˜ Support

For issues or questions:

  1. Check the troubleshooting section above
  2. Review backend logs in terminal
  3. Check node logs in backend/rubix-data/node*/log.txt
  4. Open an issue on GitHub with:
    • Error messages
    • Steps to reproduce
    • System information

๐Ÿƒ Quick Commands Reference

# Start everything
./start-all.sh          # Linux/Mac
start-all.bat           # Windows

# Manual start
cd backend && go run cmd/server/main.go  # Terminal 1
npm run dev                               # Terminal 2

# Build for production
cd backend && go build -o rubix-simulator cmd/server/main.go
npm run build

# Alternative build scripts
./build.sh             # Linux/Mac
build.bat              # Windows

About

A comprehensive testing and analysis tool for the Rubix blockchain network that simulates real blockchain transactions, measures performance metrics, and generates detailed reports.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published