synor/docs/PLAN/PHASE1-NodeIntegration/01-Milestone-01-ServiceWiring.md
Gulshan Yadav 48949ebb3f Initial commit: Synor blockchain monorepo
A complete blockchain implementation featuring:
- synord: Full node with GHOSTDAG consensus
- explorer-web: Modern React blockchain explorer with 3D DAG visualization
- CLI wallet and tools
- Smart contract SDK and example contracts (DEX, NFT, token)
- WASM crypto library for browser/mobile
2026-01-08 05:22:17 +05:30

210 lines
4.7 KiB
Markdown

# Phase 1, Milestone 1: Service Wiring
> Complete synord service integration
**Status**: ✅ Complete
**Priority**: Critical
**Application**: `synord`
---
## Overview
Wire all core services in the synord node daemon: storage, consensus, network, sync, RPC, and mining.
---
## Tasks
### Task 1.1: Storage Service Integration
- [x] Initialize RocksDB with column families
- [x] Wire BlockStore from synor-storage
- [x] Wire HeaderStore from synor-storage
- [x] Wire UtxoStore from synor-storage
- [x] Implement actual get/put operations
- [x] Add block import/export commands
**Files:**
- `apps/synord/src/services/storage.rs`
- `apps/synord/src/services/mod.rs`
**Validation:**
```bash
cargo test -p synord --lib storage
```
### Task 1.2: Consensus Service Integration
- [x] Wire TransactionValidator from synor-consensus
- [x] Wire BlockValidator from synor-consensus
- [x] Implement block processing pipeline
- [x] Connect UTXO updates on block acceptance
- [x] Integrate GHOSTDAG ordering
**Files:**
- `apps/synord/src/services/consensus.rs`
**Validation:**
```bash
cargo test -p synord --lib consensus
```
### Task 1.3: Network Service Integration
- [x] Initialize libp2p swarm from synor-network
- [x] Start P2P listener on configured port
- [x] Connect to bootstrap/seed nodes
- [x] Wire GossipSub message handling
- [x] Implement peer discovery
**Files:**
- `apps/synord/src/services/network.rs`
**Validation:**
```bash
cargo test -p synord --lib network
```
### Task 1.4: Sync Service Implementation
- [x] Implement header-first sync strategy
- [x] Download headers from peers
- [x] Validate header chain
- [x] Download blocks in parallel
- [x] Handle chain reorganizations
**Files:**
- `apps/synord/src/services/sync.rs`
**Validation:**
```bash
cargo test -p synord --test sync_protocol
```
### Task 1.5: RPC Service Activation
- [x] Start jsonrpsee HTTP server
- [x] Start jsonrpsee WebSocket server
- [x] Wire handlers to actual service methods
- [x] Replace hardcoded values with real data
- [x] Add blue score block queries
**Files:**
- `apps/synord/src/services/rpc.rs`
**Validation:**
```bash
cargo test -p synord --lib rpc
curl -X POST http://localhost:16110 -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"synor_getInfo","params":[],"id":1}'
```
### Task 1.6: Miner Service Integration
- [x] Spawn mining threads with kHeavyHash
- [x] Wire block template generation
- [x] Handle found blocks submission
- [x] Implement difficulty adjustment
**Files:**
- `apps/synord/src/services/miner.rs`
**Validation:**
```bash
cargo test -p synord --lib miner
```
### Task 1.7: Mempool Service
- [x] Transaction pool management
- [x] Fee-based prioritization
- [x] Dependency tracking
- [x] Expiration and cleanup task
**Files:**
- `apps/synord/src/services/mempool.rs`
**Validation:**
```bash
cargo test -p synord --lib mempool
```
---
## Validation
### Validation Commands
```bash
# Run all synord tests
cargo test -p synord
# Run integration tests
cargo test -p synord --test '*'
# Start node and verify
./target/release/synord init --network devnet
./target/release/synord run --network devnet &
sleep 5
curl http://localhost:16110 -X POST -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"synor_getInfo","params":[],"id":1}'
```
### Validation Agents
| Agent | Purpose |
|-------|---------|
| `code-reviewer` | Review service implementations |
| `silent-failure-hunter` | Check error handling in services |
| `Explore` | Verify codebase structure |
### Integration Test Suite
```bash
# Node lifecycle
cargo test -p synord --test node_lifecycle
# Multi-node network
cargo test -p synord --test multi_node_network
# Sync protocol
cargo test -p synord --test sync_protocol
# Fork resolution
cargo test -p synord --test fork_resolution
```
### Security Checks
- [ ] RPC endpoints require authentication for sensitive operations
- [ ] Network service validates peer messages
- [ ] Storage service uses proper file permissions
- [ ] Mempool validates transactions before acceptance
- [ ] No SQL/command injection in RPC handlers
### Performance Criteria
| Metric | Target | Validation |
|--------|--------|------------|
| Block processing | <100ms | Benchmark suite |
| RPC latency | <10ms | Load testing |
| Sync speed | >100 blocks/s | Integration test |
| Memory usage | <2GB idle | Resource monitoring |
---
## Dependencies
- `rocksdb` - Storage backend
- `jsonrpsee` - RPC framework
- `libp2p` - P2P networking
- `tokio` - Async runtime
---
## Acceptance Criteria
1. Node starts without errors
2. All 9 unit tests pass
3. All integration tests pass
4. RPC responds to all documented methods
5. Sync completes with test peers
6. Mining produces valid blocks
---
*Completed: January 2025*