Skip to content

Commit 4dd5b71

Browse files
author
EchoBT
committed
Initial commit: Platform - Distributed validator network for Bittensor
Features: - P2P network with libp2p (gossipsub, state sync) - PBFT consensus with configurable threshold - Docker challenge orchestration - Distributed database with Merkle Patricia Trie - Bittensor integration (block sync, weight submission) - JSON-RPC 2.0 API - Auto-update via Watchtower Binaries: - validator-node: Full network participant - csudo: Administrative CLI for subnet owners
0 parents  commit 4dd5b71

File tree

149 files changed

+56174
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+56174
-0
lines changed

.env.example

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Platform Chain Validator Configuration
2+
# Copy this file to .env and fill in your values
3+
4+
# REQUIRED: Your validator secret key (hex encoded 32 bytes or BIP39 mnemonic)
5+
VALIDATOR_SECRET_KEY=your_secret_key_here
6+
7+
# Optional: Slack webhook for Watchtower notifications
8+
# SLACK_WEBHOOK_URL=https://hooks.slack.com/services/xxx/xxx/xxx

.github/workflows/ci.yml

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
tags: ['v*']
7+
pull_request:
8+
branches: [main, master]
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
RUST_BACKTRACE: 1
13+
REGISTRY: ghcr.io
14+
IMAGE_NAME: ${{ github.repository }}
15+
16+
jobs:
17+
build:
18+
name: Build
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Rust toolchain
25+
uses: dtolnay/rust-toolchain@stable
26+
27+
- name: Cache cargo
28+
uses: actions/cache@v4
29+
with:
30+
path: |
31+
~/.cargo/registry
32+
~/.cargo/git
33+
target
34+
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
35+
restore-keys: |
36+
${{ runner.os }}-cargo-build-
37+
38+
- name: Build
39+
run: cargo build --release --verbose
40+
41+
test:
42+
name: Test
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: Checkout code
46+
uses: actions/checkout@v4
47+
48+
- name: Setup Rust toolchain
49+
uses: dtolnay/rust-toolchain@stable
50+
51+
- name: Cache cargo
52+
uses: actions/cache@v4
53+
with:
54+
path: |
55+
~/.cargo/registry
56+
~/.cargo/git
57+
target
58+
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
59+
restore-keys: |
60+
${{ runner.os }}-cargo-test-
61+
62+
- name: Run tests
63+
run: cargo test --verbose --workspace
64+
65+
clippy:
66+
name: Clippy
67+
runs-on: ubuntu-latest
68+
steps:
69+
- name: Checkout code
70+
uses: actions/checkout@v4
71+
72+
- name: Setup Rust toolchain
73+
uses: dtolnay/rust-toolchain@stable
74+
with:
75+
components: clippy
76+
77+
- name: Cache cargo
78+
uses: actions/cache@v4
79+
with:
80+
path: |
81+
~/.cargo/registry
82+
~/.cargo/git
83+
target
84+
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
85+
restore-keys: |
86+
${{ runner.os }}-cargo-clippy-
87+
88+
- name: Run clippy
89+
run: cargo clippy --all-targets --workspace -- -W clippy::all
90+
91+
docker:
92+
name: Build & Push Docker
93+
runs-on: ubuntu-latest
94+
needs: [build, test]
95+
permissions:
96+
contents: read
97+
packages: write
98+
steps:
99+
- name: Checkout code
100+
uses: actions/checkout@v4
101+
102+
- name: Set up QEMU
103+
uses: docker/setup-qemu-action@v3
104+
105+
- name: Set up Docker Buildx
106+
uses: docker/setup-buildx-action@v3
107+
108+
- name: Log in to Container Registry
109+
if: github.event_name != 'pull_request'
110+
uses: docker/login-action@v3
111+
with:
112+
registry: ${{ env.REGISTRY }}
113+
username: ${{ github.actor }}
114+
password: ${{ secrets.GITHUB_TOKEN }}
115+
116+
- name: Extract metadata
117+
id: meta
118+
uses: docker/metadata-action@v5
119+
with:
120+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
121+
tags: |
122+
type=ref,event=branch
123+
type=ref,event=pr
124+
type=semver,pattern={{version}}
125+
type=semver,pattern={{major}}.{{minor}}
126+
type=sha,prefix=
127+
type=raw,value=latest,enable={{is_default_branch}}
128+
129+
- name: Build and push Docker image
130+
uses: docker/build-push-action@v6
131+
with:
132+
context: .
133+
platforms: linux/amd64
134+
push: ${{ github.event_name != 'pull_request' }}
135+
tags: ${{ steps.meta.outputs.tags }}
136+
labels: ${{ steps.meta.outputs.labels }}
137+
cache-from: type=gha
138+
cache-to: type=gha,mode=max
139+
140+
release:
141+
name: Release
142+
runs-on: ubuntu-latest
143+
needs: [build, test, docker]
144+
if: startsWith(github.ref, 'refs/tags/v')
145+
permissions:
146+
contents: write
147+
steps:
148+
- name: Checkout code
149+
uses: actions/checkout@v4
150+
151+
- name: Setup Rust toolchain
152+
uses: dtolnay/rust-toolchain@stable
153+
154+
- name: Build release binaries
155+
run: cargo build --release
156+
157+
- name: Create release archive
158+
run: |
159+
mkdir -p release
160+
cp target/release/validator-node release/
161+
cp target/release/csudo release/
162+
tar -czvf platform-${{ github.ref_name }}-linux-x86_64.tar.gz -C release .
163+
164+
- name: Upload release assets
165+
uses: softprops/action-gh-release@v2
166+
with:
167+
files: |
168+
platform-${{ github.ref_name }}-linux-x86_64.tar.gz
169+
generate_release_notes: true

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Build artifacts
2+
/target/
3+
**/*.rs.bk
4+
5+
# IDE
6+
.idea/
7+
.vscode/
8+
*.swp
9+
*.swo
10+
*~
11+
12+
# OS
13+
.DS_Store
14+
Thumbs.db
15+
16+
# Logs
17+
*.log
18+
19+
# Environment
20+
.env
21+
.env.local
22+
23+
# Debug
24+
*.pdb
25+
26+
# Data directories (runtime data)
27+
/data/

0 commit comments

Comments
 (0)