Trinity Storage Network v1.5 Report
Proof-of-Storage, Shard Rebalancing, Bandwidth Aggregation, Auto-Discovery
Build on v1.4 (Reed-Solomon, Connection Pooling, Manifest DHT, 12-node test)
Key Metricsβ
| Metric | Value | Status |
|---|---|---|
| Total Tests | 1,382 | PASS (1,381 pass, 1 pre-existing flaky) |
| v1.5 Integration Tests | 3 new (node churn, PoS, bandwidth) | PASS |
| v1.5 Unit Tests | 16 new across 3 modules | PASS |
| New Zig Modules | 3 (proof_of_storage, shard_rebalancer, bandwidth_aggregator) | Complete |
| Modified Modules | 6 (protocol, storage_discovery, discovery, network, main, integration_test) | Complete |
| Protocol Messages | 4 new (0x28-0x2B) | Backward-compatible |
| Node Churn Test | 10 nodes, 3 killed, rebalanced to target=3 | PASS |
| PoS Challenge Round | 8 nodes, 7 honest + 1 tampered | Detected |
| Bandwidth Aggregation | 10 nodes, proportional reward shares | Verified |
What This Meansβ
For Usersβ
- Data survives node failures: Shard rebalancer automatically redistributes under-replicated data when nodes go offline, maintaining target replication factor.
- Honest storage verified: Proof-of-Storage challenges cryptographically verify that peers actually store the data they claim to host. Cheaters are flagged as unreliable.
- Fair rewards: Bandwidth aggregation tracks per-node contribution (upload, download, hosting) and computes proportional reward shares.
For Operatorsβ
- CLI flags:
--posenables Proof-of-Storage challenges,--rebalanceenables shard auto-redistribution,--network-statsshows network-wide bandwidth summary. - UDP auto-discovery: Storage capacity is now broadcast alongside peer discovery, enabling automatic peer-to-peer storage awareness on LAN.
- Zero-config replication: Rebalancer targets 3 replicas per shard by default.
For the Networkβ
- Production hardening: v1.5 closes the gap between "demo network" and "production network" with cryptographic verification, automatic fault recovery, and fair resource accounting.
- Backward compatible: Old v1.4 nodes silently ignore new message types (0x28-0x2B fall into the
elsewildcard).
Technical Detailsβ
Architectureβ
v1.5 Module Dependency Graph:
protocol.zig ββββββββββββββββββββββββββββββββββββββ
β StorageChallengeMsg (0x28, 144B) β
β StorageProofMsg (0x29, 104B) β
β BandwidthReportMsg (0x2A, 72B) β
β BandwidthSummaryMsg (0x2B, 28B) β
βββββββββββββββββββββββββββββββββββββββββββββββββ
β β β
ββββββΌβββββ βββββββββββΌβββββββ ββββββββΌββββββββ
β proof_ β β shard_ β β bandwidth_ β
β of_ β β rebalancer.zig β β aggregator. β
β storage β β β β zig β
β .zig β β ShardRebalancerβ β β
β β β ShardLocation β β BandwidthAgg β
β PoS β β UnderReplicatedβ β BandwidthRpt β
β Engine β β β β RewardShare β
ββββββ¬βββββ βββββββββ¬βββββββββ ββββββββ¬ββββββββ
β β β
ββββββΌββββββββββββββββββΌβββββββββββββββββββββΌβββββββ
β network.zig (NetworkNode) β
β handleConnection() switch on msg_type β
β poll() periodic PoS/rebalance/bandwidth β
βββββββββββββββββββββββ¬βββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββΌβββββββββββββββββββββββββββββ
β discovery.zig (DiscoveryService) β
β broadcastAnnounce() + StorageAnnounce UDP β
β receiveLoop() dispatches 60B vs 106B packets β
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
Proof-of-Storage (Challenge-Response Protocol)β
- Challenge: Challenger selects random shard + random byte range (up to 64B), sends
StorageChallengeMsgto target node - Response: Target reads byte range from local storage, computes SHA256, returns
StorageProofMsg - Verification: Challenger computes same hash from own copy, compares. Mismatch increments failure count.
- Eviction: After
max_failures(default: 3), node is marked unreliable inStoragePeerRegistry
Shard Rebalancerβ
- Tracks shard locations via
AutoHashMap([32]u8, ShardLocationEntry) findUnderReplicated()scans for shards belowtarget_replicationrebalance()copies shard data from existing holder to new peerremoveNode()cleans up when a node goes offline- Thread-safe via
std.Thread.Mutex
Bandwidth Aggregatorβ
- Collects
BandwidthReportper node (upload, download, shards hosted, time period) aggregate()computes network-wide totalsgetRewardShare(node_id)returns proportional share:node_bandwidth / total_bandwidth- Integrates with existing
RewardTrackerviagenerateLocalReport()
UDP Storage Auto-Discoveryβ
DiscoveryService.setStorageInfo()caches serializedStorageAnnounce(60B)broadcastAnnounce()now sends bothPeerAnnounce(106B) andStorageAnnounce(60B)receiveLoop()dispatches by packet length: >= 106 = PeerAnnounce, == 60 = StorageAnnounce
Test Resultsβ
v1.5 Integration Tests (3 new)β
| Test | Nodes | Description | Result |
|---|---|---|---|
| Node Churn | 10 | Kill 3 nodes, rebalance 3 shards to target=3 | 6 copies made, all restored |
| PoS Challenge | 8 | 7 honest passes, 1 tampered detected | 7 pass, 1 fail, failure counted |
| Bandwidth Agg | 10 | Proportional shares sum to 1.0, totals correct | Verified within 0.001 tolerance |
v1.5 Unit Tests (16 new)β
| Module | Tests | All Pass |
|---|---|---|
| proof_of_storage.zig | 6 (challenge creation, proof response, honest verify, tampered detect, unreliable flagging, timing) | Yes |
| shard_rebalancer.zig | 5 (register/track, removeNode, findUnderReplicated, rebalance, no-op) | Yes |
| bandwidth_aggregator.zig | 5 (aggregate, reward share, local report, empty, timing) | Yes |
Full Suiteβ
zig build test: 1,381/1,382 passed, 1 pre-existing flaky (LRU eviction timing)
New CLI Flagsβ
--pos Enable Proof-of-Storage challenges (v1.5)
--rebalance Enable shard rebalancing (v1.5)
--network-stats Show network-wide bandwidth stats (v1.5)
Files Changedβ
Createdβ
specs/tri/storage_network_v1_5.vibee- VIBEE specificationsrc/trinity_node/proof_of_storage.zig- PoS engine (~380 lines)src/trinity_node/shard_rebalancer.zig- Rebalancer (~395 lines)src/trinity_node/bandwidth_aggregator.zig- Aggregator (~270 lines)
Modifiedβ
src/trinity_node/protocol.zig- 4 new message types + structs + testssrc/trinity_node/storage_discovery.zig- reliability flag, 3 new methods, 2 testssrc/trinity_node/discovery.zig- StorageAnnounce broadcast + receive, 1 testsrc/trinity_node/network.zig- 3 new module imports, message handlers, poll() extensionssrc/trinity_node/main.zig- 3 CLI flags, module initialization, HKDF path fixsrc/trinity_node/integration_test.zig- 3 v1.5 integration testsbuild.zig- 3 new test targets
Conclusionβ
v1.5 transforms the Trinity Storage Network from a "store and retrieve" system into a production-grade decentralized storage network with:
- Cryptographic verification (Proof-of-Storage)
- Automatic fault recovery (Shard Rebalancing)
- Fair resource accounting (Bandwidth Aggregation)
- Zero-config peer discovery (UDP StorageAnnounce)
Next Stepsβ
- Network Admin Panel UI (dashboard for monitoring PoS challenges, rebalancer activity, bandwidth)
- Erasure coding integration with rebalancer (RS-aware rebalancing)
- Economic model: convert bandwidth shares to $TRI rewards on-chain
- Real network deployment with 20+ physical nodes