Commit 53fd03f
feat: implement tiered endpoint selection with reputation signals (#495)
## Summary
- Implement tiered endpoint selection based on reputation scores:
- Tier 1 (score >70): Best endpoints, used first if any exist
- Tier 2 (score 50-70): Used when Tier 1 is empty
- Tier 3 (score 30-50): Last resort fallback
- Add comprehensive reputation signal recording across all relay
dispatch points:
- Success signals for successful relays with latency tracking
- Minor error signals for JSON-RPC errors in responses
- Major error signals for timeouts and HTTP errors
- Critical error signals for websocket connection failures
- Record signals for fallback endpoints during Shannon session rollover
- Add websocket message success/error reputation tracking
- Add tier distribution Prometheus metrics
(`path_reputation_tier_endpoints_total`)
- Add `make path_dev` target for local development testing
## Configuration Options
New configuration options added to
`shannon_config.gateway_config.reputation_config`:
```yaml
reputation_config:
# Enable/disable the reputation system (default: false)
enabled: true
# Storage backend: "memory" or "redis" (default: "memory")
storage_type: "memory"
# Starting score for new endpoints (default: 80)
initial_score: 80
# Minimum score for endpoint selection (default: 30)
min_threshold: 30
# Time for inactive endpoint score recovery (default: 5m)
recovery_timeout: 5m
# Tiered selection configuration
tiered_selection:
# Enable tiered selection (default: true when reputation enabled)
enabled: true
# Tier 1 threshold - Premium tier (default: 70)
tier1_threshold: 70
# Tier 2 threshold - Good tier (default: 50)
tier2_threshold: 50
# Tier 3 uses min_threshold (30) as its minimum
```
## Reputation Signal Types
| Signal Type | Score Impact | Triggers |
|-------------|-------------|----------|
| Success | +1 | Successful relay with valid response |
| MinorError | -3 | JSON-RPC errors in response |
| MajorError | -10 | Timeouts, HTTP errors, websocket validation
failures |
| CriticalError | -25 | HTTP 5xx, service errors, validation/signature
errors |
| FatalError | -50 | Permanent sanctions (service misconfiguration) |
## Test plan
- [x] Unit tests pass (`make test_unit`)
- [x] E2E tests pass for eth service (`make e2e_test eth` - 99% success
rate)
- [x] Lint passes (`make go_lint` - 0 issues)
- [x] Format applied (`make go_fmt`)
- [x] Manual verification: tier distribution metrics showing correct
distribution
- [x] Manual verification: JSON-RPC errors affecting reputation and
causing tier movement
---------
Co-authored-by: Otto V <[email protected]>1 parent d516bfb commit 53fd03f
File tree
13 files changed
+1192
-10
lines changed- config
- examples
- metrics/reputation
- protocol/shannon
- reputation
13 files changed
+1192
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | | - | |
| 188 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
97 | 102 | | |
98 | 103 | | |
99 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
124 | 142 | | |
125 | 143 | | |
126 | 144 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
23 | 29 | | |
24 | 30 | | |
25 | 31 | | |
26 | 32 | | |
27 | 33 | | |
28 | 34 | | |
29 | 35 | | |
| 36 | + | |
| 37 | + | |
30 | 38 | | |
31 | 39 | | |
32 | 40 | | |
| |||
36 | 44 | | |
37 | 45 | | |
38 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
39 | 51 | | |
40 | 52 | | |
41 | 53 | | |
| |||
109 | 121 | | |
110 | 122 | | |
111 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
112 | 160 | | |
113 | 161 | | |
114 | 162 | | |
| |||
152 | 200 | | |
153 | 201 | | |
154 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
0 commit comments