Trinity Storage Network v1.6 Report
20-Node Scale, Shard Scrubbing, Node Reputation, Graceful Shutdown, Network Stats
Build on v1.5 (Proof-of-Storage, Shard Rebalancing, Bandwidth Aggregation)
Key Metrics
| Metric | Value | Status |
|---|---|---|
| Total Tests | ~1,415+ (140 integration alone) | PASS |
| v1.6 Integration Tests | 5 new (20-node scale, scrubbing, reputation, shutdown, stats) | PASS |
| v1.6 Unit Tests | ~27 new across 4 modules + extensions | PASS |
| New Zig Modules | 4 (shard_scrubber, node_reputation, graceful_shutdown, network_stats) | Complete |
| Modified Modules | 7 (protocol, shard_rebalancer, storage_discovery, network, main, integration_test, build.zig) | Complete |
| Protocol Messages | 4 new (0x2C-0x2F) | Backward-compatible |
| 20-Node Scale Test | 5 files, 4-node churn, PoS + bandwidth + RS | PASS |
| Shard Scrubbing | 20 nodes, 2 corruptions detected | PASS |
| Node Reputation | 20 nodes ranked, top-5 selection with exclusion | PASS |
| Graceful Shutdown | 10 nodes, 1 departs, 0 data loss | PASS |
| Network Stats | 20 nodes, text + JSON report generation | PASS |
What This Means
For Users
- Bit-rot protection: Shard Scrubber periodically re-verifies SHA256 hashes of all locally stored shards. Detects silent data corruption before Proof-of-Storage catches it.
- Smarter peer selection: Node Reputation scores combine PoS pass rate (40%), uptime (30%), and bandwidth contribution (30%) into a composite 0.0-1.0 score. Data is preferentially placed on higher-reputation nodes.
- Zero-downtime departures: Graceful Shutdown proactively redistributes a departing node's shards before it leaves, avoiding reactive rebalancing delays.
For Operators
- CLI flags:
--scrubenables periodic shard scrubbing,--reputationenables reputation scoring,--reportgenerates a one-shot network health report (text output). - Health monitoring: Network Stats Reporter aggregates data from all subsystems (storage, replication, PoS, bandwidth, scrubber, reputation) into a single report.
- 20-node proven: The integration test suite now validates at 20-node scale with multi-file RS storage, 4-node churn, and all v1.5+v1.6 subsystems running concurrently.
For the Network
- Production hardening: v1.6 adds the defensive layers needed for long-running deployments: data integrity checking, reputation-based trust, graceful node lifecycle management, and observability.
- Backward compatible: New message types 0x2C-0x2F fall into the
elsewildcard on older nodes. Reputation scores are transmitted asscore * 1,000,000(u64) to avoid float serialization issues.
Technical Details
Architecture
v1.6 Module Dependency Graph:
protocol.zig ───────────────────────────────────────────
│ ShardScrubReportMsg (0x2C, 48B) │
│ ReputationQueryMsg (0x2D, 64B) │
│ ReputationResponseMsg (0x2E, 64B) │
│ GracefulShutdownMsg (0x2F, 44B) │
└─────────────────────────────────────────────────────┘
│ │ │ │
┌────▼─────┐ ┌──────▼──────┐ ┌─────▼─────┐ ┌───▼──────────┐
│ shard_ │ │ node_ │ │ graceful_ │ │ network_ │
│ scrubber │ │ reputation │ │ shutdown │ │ stats │
│ .zig │ │ .zig │ │ .zig │ │ .zig │
│ │ │ │ │ │ │ │
│ Scrubber │ │ Reputation │ │ Shutdown │ │ Stats │
│ ScrubRes │ │ System │ │ Manager │ │ Reporter │
│ ScrubStat│ │ Weights │ │ Plan │ │ HealthReport │
└──────────┘ │ Score │ └────────────┘ └──────────────┘
│ └─────────────┘ │ │
│ │ │ │
┌────▼───────────────▼───────────────▼───────────────▼──┐
│ network.zig │
│ Wires all 4 modules: poll() triggers scrub/reputation│
│ handleConnection dispatches 0x2C-0x2F messages │
└───────────────────────────────────────────────────────┘
│
┌─────▼─────┐
│ main.zig │
│ --scrub │
│ --reputat │
│ --report │
└───────────┘
New Modules
1. Shard Scrubber (shard_scrubber.zig)
Background SHA256 re-verification of locally-held shards. Detects bit-rot, disk corruption, and tampering between PoS challenge rounds.
scrubNode(provider)— iterates all shards in a StorageProvider, re-computes SHA256, flags mismatchesisCorrupted(hash)/getCorruptedShards()— query corruption stateshouldScrub()— respects configurable interval (default 600s)getStats()— returnsScrubStats { shards_checked, corruptions_found, last_scrub_time }
2. Node Reputation (node_reputation.zig)
Composite reputation scoring for smarter peer selection.
- Weights: PoS pass rate (40%) + uptime (30%) + bandwidth contribution (30%)
recordPosResult(node_id, passed)— increments PoS pass/total countersrecordUptime(node_id, uptime_secs, window_secs)— stores uptime fractionrecordBandwidth(node_id, bytes)— tracks cumulative bandwidth; normalized againstmax_bandwidth_bytesgetScore(node_id)— returns weighted composite 0.0-1.0rankNodes()— returns all nodes sorted by score descendingselectBestPeers(count, exclude, alloc)— picks top-N peers excluding one (for rebalancing/replication)
3. Graceful Shutdown (graceful_shutdown.zig)
Pre-departure shard redistribution — proactive vs. reactive rebalancing.
initiateShutdown(node_id, rebalancer)— scans rebalancer for all shards held by node, creates planexecuteShutdown(node_id, rebalancer, peers, peer_ids)— callsrebalancer.removeNode()thenrebalancer.rebalance()isShuttingDown(node_id)— check if shutdown in progress- Tracks
completed_plansandtotal_shards_movedstatistics
4. Network Stats (network_stats.zig)
Aggregated health report from all subsystems.
generateReport(peers, rebalancer, pos, bw_agg, registry, scrubber?, reputation?)— collects metrics from all subsystemsformatText(report)— human-readable text outputformatJson(report)— machine-readable JSON outputNetworkHealthReportfields: node_count, total_shards, storage bytes, replication stats, PoS stats, bandwidth, scrub results, reputation avg/min/max
Protocol Extensions
| Message | Opcode | Size | Purpose |
|---|---|---|---|
ShardScrubReportMsg | 0x2C | 48B | Report scrub results to network |
ReputationQueryMsg | 0x2D | 64B | Request reputation score for a node |
ReputationResponseMsg | 0x2E | 64B | Reply with reputation score (millionths) |
GracefulShutdownMsg | 0x2F | 44B | Announce impending departure |
Modified Modules
| Module | Changes |
|---|---|
shard_rebalancer.zig | Added getShardLocationsForNode() for shutdown planning |
storage_discovery.zig | Added reputation_score field, updateReputation()/getReputation() methods |
network.zig | 4 imports, 4 nullable module fields, 3 message handlers, poll() scrub/reputation |
main.zig | 4 imports, --scrub/--reputation/--report flags, initialization, report handler |
protocol.zig | 4 new MessageType values, 4 message structs with serialize/deserialize |
build.zig | 4 new test targets (shard_scrubber, node_reputation, graceful_shutdown, network_stats) |
Integration Tests
| Test | Nodes | What It Validates |
|---|---|---|
| 20-node multi-file RS with churn + PoS + bandwidth | 20 | 5 files stored, 4 nodes killed, rebalance, PoS challenge, bandwidth aggregate |
| Shard scrubbing — detect corruption | 20 | 20 shards stored, 2 tampered, scrubber finds both |
| Node reputation ranking | 20 | Proportional PoS/uptime/bandwidth, sorted ranking, top-5 selection |
| Graceful shutdown redistribution | 10 | 5 shards, 1 node departs gracefully, 0 data loss |
| Network stats report | 20 | Full report generation, text format, JSON format |
Cumulative Version History
| Version | Features | Test Count |
|---|---|---|
| v1.0 | Storage, Sharding, Encryption | ~200 |
| v1.1 | Disk Persistence, LRU Eviction | ~400 |
| v1.2 | Protocol, Networking, Discovery | ~600 |
| v1.3 | Rewards, Bandwidth Metering | ~800 |
| v1.4 | Reed-Solomon, Connection Pool, DHT, 12-node test | ~1,100 |
| v1.5 | Proof-of-Storage, Rebalancer, Bandwidth Aggregation | ~1,382 |
| v1.6 | Shard Scrubbing, Reputation, Graceful Shutdown, Network Stats, 20-node test | ~1,415+ |
Conclusion
Trinity Storage Network v1.6 completes the production-hardening layer:
- Data integrity — Shard Scrubber provides a second line of defense against data corruption, complementing PoS challenges with periodic local re-verification.
- Trust management — Node Reputation enables data-driven peer selection, incentivizing reliability and contribution.
- Lifecycle management — Graceful Shutdown eliminates the "pull the plug" failure mode, allowing orderly node departures.
- Observability — Network Stats Reporter provides a unified view of network health across all subsystems.
- Scale validation — 20-node integration tests with multi-file RS, churn, PoS, bandwidth, scrubbing, and reputation running concurrently.
Next Steps (v1.7 Candidates)
- Erasure-coded repair from scrub results: When scrubber detects corruption, automatically trigger RS recovery from healthy replicas
- Reputation decay: Time-weighted scoring so stale reputation data fades
- Multi-region topology awareness: Prefer cross-region replication for geographic redundancy
- Incentive slashing: Reduce rewards for nodes with low reputation scores
- Prometheus/Grafana export: Machine-consumable metrics endpoint for external monitoring