Skip to content

Substrate blockchain for federated learning marketplace

License

Notifications You must be signed in to change notification settings

glin-ai/glin-chain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GLIN Chain - Substrate Blockchain for Federated Learning

License Substrate Discord Twitter Follow

🌐 Overview

GLIN Chain is the blockchain infrastructure powering the GLIN federated learning marketplace. Built with Substrate, it provides trustless task management, provider staking, and reward distribution for decentralized AI training.

Key Features

  • πŸ”’ Trustless Task Escrow: Secure bounty locking for ML training tasks
  • πŸ’° Provider Staking: Economic security through stake-based participation
  • 🎯 Batch Rewards: Efficient merkle-tree based reward distribution
  • πŸ›‘οΈ Slashing Mechanism: Automated penalties for malicious behavior
  • πŸ” ZKP Validation: On-chain verification for high-value computations

πŸš€ Quick Start

Prerequisites

# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Install Substrate dependencies
sudo apt update && sudo apt install -y git clang curl libssl-dev llvm libudev-dev make protobuf-compiler

# Clone the repository
git clone https://github.com/glin-ai/glin-chain.git
cd glin-chain

Build & Run

# Build the node
cargo build --release

# Run development node
./target/release/glin-node --dev

# Run with custom chain spec
./target/release/glin-node --chain=local

Docker

# Build Docker image
docker build -t glin-chain .

# Run container
docker run -p 9944:9944 -p 9933:9933 glin-chain

πŸ—οΈ Architecture

Pallets

Pallet Purpose Key Functions
task-registry Task lifecycle management create_task, cancel_task, complete_task
provider-staking Provider registration & staking register_provider, slash_provider, withdraw_stake
reward-distribution Batch reward processing create_batch, submit_rewards, settle_batch
validation-zkp Zero-knowledge proof verification submit_proof, verify_gradient
reputation Provider reputation tracking update_score, get_reputation

Economic Model

  • Token: GLIN
  • Total Supply: 1,000,000,000 GLIN
  • Minimum Provider Stake: 1,000 GLIN
  • Minimum Task Bounty: 10 GLIN
  • Platform Fee: 2% of rewards
  • Slashing Rate: 10% for violations

πŸ”§ Configuration

Chain Specification

# Generate chain spec
./target/release/glin-node build-spec --chain=local > customSpec.json

# Generate raw chain spec
./target/release/glin-node build-spec --chain=customSpec.json --raw > customSpecRaw.json

Network Ports

  • P2P: 30333
  • RPC: 9933
  • WebSocket: 9944
  • Prometheus: 9615

πŸ§ͺ Testing

# Run all tests
cargo test

# Run pallet tests
cargo test -p pallet-task-registry
cargo test -p pallet-provider-staking
cargo test -p pallet-reward-distribution

# Run integration tests
cargo test --test '*'

# Run benchmarks
cargo test --features runtime-benchmarks

πŸ”— Integration

JavaScript/TypeScript

import { ApiPromise, WsProvider } from '@polkadot/api';

const provider = new WsProvider('ws://localhost:9944');
const api = await ApiPromise.create({ provider });

// Create a task
const tx = api.tx.taskRegistry.createTask(
  'Image Classification',
  'ResNet',
  1000000000000, // 1 GLIN bounty
  3, // min providers
  10, // max providers
  'QmHash...', // IPFS hash
  { minVramGb: 8, minComputeCapability: 75, minBandwidthMbps: 100 }
);

await tx.signAndSend(alice);

Python

from substrateinterface import SubstrateInterface

substrate = SubstrateInterface(
    url="ws://localhost:9944",
    type_registry_preset='substrate-node'
)

# Query provider info
result = substrate.query(
    module='ProviderStaking',
    storage_function='Providers',
    params=['5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY']
)

πŸ“Š Monitoring

Prometheus Metrics

# prometheus.yml
scrape_configs:
  - job_name: 'glin-node'
    static_configs:
      - targets: ['localhost:9615']

Grafana Dashboard

Import our Grafana dashboard for real-time metrics.

πŸ› οΈ Development

Adding a New Pallet

# Generate pallet template
substrate-node-new-pallet my-pallet

# Add to runtime
# Edit runtime/src/lib.rs

Upgrading Runtime

# Build new runtime
cargo build --release -p glin-runtime

# Submit upgrade transaction
# Via polkadot.js or CLI

🀝 Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Development Setup

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

Code Style

# Format code
cargo fmt

# Run clippy
cargo clippy -- -D warnings

πŸ“š Documentation

πŸ” Security

Audits

  • Pallet logic audit (Planned Q1 2025)
  • Runtime audit (Planned Q2 2025)

Bug Bounty

Report security vulnerabilities to [email protected]. See SECURITY.md for our bug bounty program.

πŸ“œ License

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

πŸ”— Links

πŸ™ Acknowledgments

Built with Substrate by Parity Technologies


Made with ❀️ by the GLIN AI team

About

Substrate blockchain for federated learning marketplace

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published