Trinity Storage Network v1.7 Report
Auto-Repair, Reputation Decay, Incentive Slashing, Prometheus Metrics, 30-Node Scale
Build on v1.6 (Shard Scrubbing, Node Reputation, Graceful Shutdown, Network Stats)
Key Metrics
| Metric | Value | Status |
|---|---|---|
| Total Tests | ~1,913+ (168 integration alone) | PASS |
| v1.7 Integration Tests | 5 new (30-node slashing, decay, metrics, auto-repair, full pipeline) | PASS |
| v1.7 Unit Tests | ~30 new across 3 modules + extensions | PASS |
| New Zig Modules | 3 (auto_repair, incentive_slashing, prometheus_metrics) | Complete |
| Modified Modules | 5 (protocol, node_reputation, network, main, integration_test) | Complete |
| Protocol Messages | 3 new (0x30-0x32) | Backward-compatible |
| 30-Node Scale Test | 20 shards, auto-repair 5 corruptions, slashing + decay + metrics | PASS |
| Auto-Repair | 5 corrupted shards repaired from healthy peers | PASS |
| Incentive Slashing | Bad nodes (score < 0.5) get up to 80% reward reduction | PASS |
| Reputation Decay | Stale nodes lose ranking after configurable half-life | PASS |
| Prometheus Metrics | 18 metrics exported in standard exposition format | PASS |
What This Means
For Users
- Self-healing storage: When the scrubber detects corruption, the Auto-Repair Engine automatically recovers data from healthy peer replicas. No manual intervention needed.
- Fair rewards: Incentive Slashing reduces rewards for nodes with poor Proof-of-Storage pass rates. Reliable nodes earn full rewards; unreliable nodes get up to 80% less.
- Fresh reputation: Reputation Decay ensures that stale performance data doesn't permanently benefit inactive nodes. Scores decay exponentially based on a configurable half-life.
For Operators
- CLI flags:
--auto-repairenables automatic shard recovery,--slashingenables incentive penalties,--metricsgenerates Prometheus-format output. - Prometheus integration:
trinity-node --metricsoutputs standard exposition format that Prometheus/Grafana/VictoriaMetrics can scrape directly. - 30-node proven: The integration test suite validates all v1.7 subsystems running concurrently at 30-node scale.
For the Network
- Action and incentive: v1.7 transforms the network from "detection and observation" (v1.6) to self-healing storage with economic penalties. Corruption is detected AND repaired automatically. Bad actors are penalized economically.
- Backward compatible: New message types 0x30-0x32 fall into
elsewildcard on older nodes.
Technical Details
Architecture
v1.7 Module Dependency Graph:
protocol.zig ─────────────────────────────────────────────────
| ShardRepairRequestMsg (0x30, 64B) |
| ShardRepairResponseMsg (0x31, 67B) |
| SlashEventMsg (0x32, 60B) |
└───────────────────────────────────────────────────────────┘
| | |
┌────▼─────┐ ┌──────▼──────────┐ ┌─────▼──────────────┐
| auto_ | | incentive_ | | prometheus_ |
| repair | | slashing | | metrics |
| .zig | | .zig | | .zig |
| | | | | |
| Repair | | Slashing | | Prometheus |
| Engine | | Engine | | Exporter |
| Stats | | SlashResult | | 18 metric types |
└──────────┘ | SlashConfig | └────────────────────┘
| └─────────────────┘ |
| | |
┌────▼────────────────▼─────────────────────▼─────────────┐
| node_reputation.zig (MODIFIED v1.7) |
| + enableDecay(half_life_secs) |
| + disableDecay() |
| + getScoreAtTime(node_id, timestamp) |
| + last_activity_ts tracking |
└─────────────────────────────────────────────────────────┘
|
┌─────────────────────────▼───────────────────────────────┐
| network.zig |
| 3 new imports, 3 nullable fields, 3 message handlers |
| poll(): auto-repair trigger, reputation decay |
└─────────────────────────────────────────────────────────┘
|
┌─────▼─────┐
| main.zig |
| --auto- |
| repair |
| --slash |
| --metrics |
└───────────┘
New Modules
1. Auto-Repair Engine (auto_repair.zig)
Automatic shard recovery when scrubber detects corruption. Iterates corrupted shard list, finds healthy replicas on peer nodes, replaces corrupted data.
repairFromScrub(scrubber, local_peer_idx, peers)-- scan corrupted list, copy from healthy peer, re-store locallygetStats()-- returns{ repairs_attempted, repairs_succeeded, repairs_failed, shards_replaced }- SHA256 verification of healthy copy before replacement
- Removes corrupted shard via
fetchRemove(), stores verified copy viastoreShard()
2. Incentive Slashing (incentive_slashing.zig)
Reputation-based reward reduction for underperforming nodes.
- Threshold: Score >= 0.5 = full reward (no slash)
- Slash rate: Linear interpolation from
min_slash_rate(0.1) at threshold tomax_slash_rate(0.8) at score=0 evaluateReward(node_id, base_reward_wei, reputation)-- returnsSlashResult { was_slashed, slashed_reward_wei, slash_rate }evaluateBatch(node_ids, rewards, reputation)-- batch evaluationcalculateSlashRate(reputation_score)-- pure function, returns 0.0 to 0.8- Configurable via
SlashingConfig { threshold, max_slash_rate, min_slash_rate }
3. Prometheus Metrics (prometheus_metrics.zig)
Machine-consumable metrics in Prometheus exposition format.
exportMetrics(health_report)-- generates text output with# HELP,# TYPE, and metric value lines- 18 metrics exported: node_count, shards_total, storage_bytes_used/available, shards_tracked, shards_rebalanced_total, replication_target, pos_challenges (issued/passed/failed), bandwidth (upload/download), scrub (rounds/corruptions), reputation (avg/min/max), report_generated_timestamp_seconds
- Counters are monotonic, gauges can vary
- Standard format compatible with Prometheus, Grafana, VictoriaMetrics
Reputation Decay (node_reputation.zig extension)
enableDecay(half_life_secs)-- activate exponential decaydisableDecay()-- return to static scoringgetScoreAtTime(node_id, at_timestamp)-- read-only projection with decay applied- Decay formula:
score * exp(-0.693147 * elapsed / half_life)(ln(2) = 0.693147) last_activity_tstracked on everyrecordPosResult,recordUptime,recordBandwidth- Default half-life: 86400s (24 hours)
- At 1 half-life: score = 50%. At 2 half-lives: score = 25%
Protocol Extensions
| Message | Opcode | Size | Purpose |
|---|---|---|---|
ShardRepairRequestMsg | 0x30 | 64B | Request healthy shard copy from peer |
ShardRepairResponseMsg | 0x31 | 67B | Response with shard availability + data length |
SlashEventMsg | 0x32 | 60B | Announce slashing event to network |
Modified Modules
| Module | Changes |
|---|---|
node_reputation.zig | Added last_activity_ts, decay_enabled, decay_half_life_secs, enableDecay(), disableDecay(), getScoreAtTime(), 4 decay tests |
protocol.zig | 3 new MessageType values (0x30-0x32), 3 message structs with serialize/deserialize, 4 new tests |
network.zig | 3 imports, 3 nullable fields, 3 message handlers, poll() auto-repair + decay |
main.zig | 3 imports, 3 CLI flags (--auto-repair, --slashing, --metrics), 3 initialization blocks, metrics one-shot handler |
integration_test.zig | 5 new v1.7 tests (30-node scale) |
Integration Tests
| Test | Nodes | What It Validates |
|---|---|---|
| 30-node auto-repair with churn + slashing | 30 | 20 shards, 5 corrupted, auto-repair from healthy peers, slashing evaluates all nodes |
| 30-node reputation decay | 30 | Fresh vs stale nodes ranked correctly after decay |
| 30-node Prometheus metrics export | 30 | Full subsystem report, Prometheus format validation |
| Full pipeline: scrub + repair + slash + decay + metrics | 30 | End-to-end v1.7 lifecycle with 20 shards and 5 corruptions |
| 30-node incentive slashing with reputation tiers | 30 | Bad (2/10 PoS), medium (6/10), good (10/10) nodes evaluated correctly |
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 |
| v1.7 | Auto-Repair, Incentive Slashing, Reputation Decay, Prometheus Metrics, 30-node test | ~1,913+ |
Conclusion
Trinity Storage Network v1.7 completes the action-and-incentive layer:
- Self-healing -- Auto-Repair Engine detects corruption via scrubber and automatically recovers from healthy peer replicas. Zero manual intervention.
- Economic penalties -- Incentive Slashing reduces rewards for nodes with low reputation scores (PoS pass rate < 50%). Maximum 80% reduction at score=0.
- Temporal fairness -- Reputation Decay with exponential half-life ensures stale nodes don't ride on past performance. Active participation is rewarded.
- Observability -- Prometheus Metrics Exporter provides 18 standard-format metrics for external monitoring systems.
- 30-node scale -- Full pipeline integration tests validate all subsystems running concurrently: scrub, repair, slash, decay, metrics.
Next Steps (v1.8 Candidates)
- Multi-region topology awareness: Prefer cross-region replication for geographic redundancy
- Erasure-coded repair: When peer copy isn't available, reconstruct from RS parity shards
- Prometheus HTTP endpoint: Serve metrics via HTTP
/metricsendpoint for live scraping - Reputation consensus: Cross-node reputation verification to prevent self-reporting fraud
- Slashing escrow: Hold slashed rewards in escrow with appeal window before burning