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