Skip to content

Commit eb32887

Browse files
committed
feat: enhance error classification for RelayMiner errors
Add comprehensive error classification for RelayMiner errors from poktroll/pkg/relayer/proxy/errors.go. This enables proper handling of all RelayMiner error types, including making timeouts retryable. Changes: - Add 10 new error types in shannon.proto for RelayMiner-specific errors - Update classifyMalformedEndpointPayload to detect RelayMiner error messages - Make RAW_PAYLOAD_RELAY_MINER_TIMEOUT retryable (timeout errors should retry) - Add comprehensive unit tests for error classification RelayMiner Error Mapping: - Code 1: invalid session -> RELAY_MINER_INVALID_SESSION - Code 2: configs undefined -> RELAY_MINER_SERVICE_CONFIG_UNDEFINED - Code 4: unsupported transport -> RELAY_MINER_UNSUPPORTED_TRANSPORT - Code 5: internal error -> RELAY_MINER_INTERNAL_ERROR - Code 6: unknown session -> RELAY_MINER_UNKNOWN_SESSION - Code 7: rate limited -> RELAY_MINER_RATE_LIMITED - Code 8: relay cost calc -> RELAY_MINER_RELAY_COST_CALCULATION - Code 10: timeout -> RELAY_MINER_TIMEOUT (RETRYABLE!) - Code 13: request limit -> RELAY_MINER_REQUEST_LIMIT_EXCEEDED - Code 14: unmarshal request -> RELAY_MINER_UNMARSHAL_REQUEST
1 parent 4d7e893 commit eb32887

File tree

6 files changed

+381
-48
lines changed

6 files changed

+381
-48
lines changed

observation/protocol/shannon.pb.go

Lines changed: 96 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/path/protocol/shannon.proto

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,39 @@ enum ShannonEndpointErrorType {
130130

131131
// RelayMiner returned a 5XX HTTP status code
132132
SHANNON_ENDPOINT_ERROR_RELAY_MINER_HTTP_5XX = 43;
133+
134+
// RelayMiner-specific error types (from poktroll/pkg/relayer/proxy/errors.go)
135+
// These errors are returned by the RelayMiner in the raw payload
136+
137+
// RelayMiner request timed out (code 10) - RETRYABLE
138+
SHANNON_ENDPOINT_ERROR_RAW_PAYLOAD_RELAY_MINER_TIMEOUT = 44;
139+
140+
// RelayMiner invalid session error (code 1)
141+
SHANNON_ENDPOINT_ERROR_RAW_PAYLOAD_RELAY_MINER_INVALID_SESSION = 45;
142+
143+
// RelayMiner services configs undefined (code 2)
144+
SHANNON_ENDPOINT_ERROR_RAW_PAYLOAD_RELAY_MINER_SERVICE_CONFIG_UNDEFINED = 46;
145+
146+
// RelayMiner unsupported transport type (code 4)
147+
SHANNON_ENDPOINT_ERROR_RAW_PAYLOAD_RELAY_MINER_UNSUPPORTED_TRANSPORT = 47;
148+
149+
// RelayMiner internal error (code 5)
150+
SHANNON_ENDPOINT_ERROR_RAW_PAYLOAD_RELAY_MINER_INTERNAL_ERROR = 48;
151+
152+
// RelayMiner unknown session (code 6)
153+
SHANNON_ENDPOINT_ERROR_RAW_PAYLOAD_RELAY_MINER_UNKNOWN_SESSION = 49;
154+
155+
// RelayMiner rate limited (code 7)
156+
SHANNON_ENDPOINT_ERROR_RAW_PAYLOAD_RELAY_MINER_RATE_LIMITED = 50;
157+
158+
// RelayMiner failed to calculate relay cost (code 8)
159+
SHANNON_ENDPOINT_ERROR_RAW_PAYLOAD_RELAY_MINER_RELAY_COST_CALCULATION = 51;
160+
161+
// RelayMiner request limit exceeded (code 13)
162+
SHANNON_ENDPOINT_ERROR_RAW_PAYLOAD_RELAY_MINER_REQUEST_LIMIT_EXCEEDED = 52;
163+
164+
// RelayMiner failed to unmarshal relay request (code 14)
165+
SHANNON_ENDPOINT_ERROR_RAW_PAYLOAD_RELAY_MINER_UNMARSHAL_REQUEST = 53;
133166
}
134167

135168
// ShannonSanctionType specifies the duration type for endpoint sanctions

protocol/shannon/retry.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,12 @@ func isRetryableErrorType(errorType protocolobservations.ShannonEndpointErrorTyp
101101
}
102102

103103
switch errorType {
104-
// Timeout errors
104+
// Timeout errors (including RelayMiner timeout from poktroll)
105105
case protocolobservations.ShannonEndpointErrorType_SHANNON_ENDPOINT_ERROR_TIMEOUT,
106106
protocolobservations.ShannonEndpointErrorType_SHANNON_ENDPOINT_ERROR_HTTP_IO_TIMEOUT,
107107
protocolobservations.ShannonEndpointErrorType_SHANNON_ENDPOINT_ERROR_HTTP_CONTEXT_DEADLINE_EXCEEDED,
108-
protocolobservations.ShannonEndpointErrorType_SHANNON_ENDPOINT_ERROR_HTTP_CONNECTION_TIMEOUT:
108+
protocolobservations.ShannonEndpointErrorType_SHANNON_ENDPOINT_ERROR_HTTP_CONNECTION_TIMEOUT,
109+
protocolobservations.ShannonEndpointErrorType_SHANNON_ENDPOINT_ERROR_RAW_PAYLOAD_RELAY_MINER_TIMEOUT:
109110
return config.RetryOnTimeout
110111

111112
// Connection errors

protocol/shannon/retry_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ func TestIsRetryableErrorType_TimeoutErrors(t *testing.T) {
162162
protocolobservations.ShannonEndpointErrorType_SHANNON_ENDPOINT_ERROR_HTTP_IO_TIMEOUT,
163163
protocolobservations.ShannonEndpointErrorType_SHANNON_ENDPOINT_ERROR_HTTP_CONTEXT_DEADLINE_EXCEEDED,
164164
protocolobservations.ShannonEndpointErrorType_SHANNON_ENDPOINT_ERROR_HTTP_CONNECTION_TIMEOUT,
165+
// RelayMiner timeout from poktroll (code 10)
166+
protocolobservations.ShannonEndpointErrorType_SHANNON_ENDPOINT_ERROR_RAW_PAYLOAD_RELAY_MINER_TIMEOUT,
165167
}
166168

167169
// With timeout retry enabled

protocol/shannon/sanctions.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,62 @@ func classifyMalformedEndpointPayload(logger polylog.Logger, payloadContent stri
292292
return protocolobservations.ShannonEndpointErrorType_SHANNON_ENDPOINT_ERROR_RAW_PAYLOAD_HTTP_TRANSPORT, protocolobservations.ShannonSanctionType_SHANNON_SANCTION_SESSION
293293
}
294294

295+
// ============================================================================
296+
// RelayMiner-specific errors (from poktroll/pkg/relayer/proxy/errors.go)
297+
// These match the exact error messages returned by the RelayMiner
298+
// ============================================================================
299+
300+
// RelayMiner timeout (code 10) - RETRYABLE: transient error, may succeed on different endpoint
301+
if strings.Contains(payloadContent, "relayer proxy request timed out") {
302+
return protocolobservations.ShannonEndpointErrorType_SHANNON_ENDPOINT_ERROR_RAW_PAYLOAD_RELAY_MINER_TIMEOUT, protocolobservations.ShannonSanctionType_SHANNON_SANCTION_SESSION
303+
}
304+
305+
// RelayMiner invalid session (code 1) - session validation failed
306+
if strings.Contains(payloadContent, "invalid session in relayer request") {
307+
return protocolobservations.ShannonEndpointErrorType_SHANNON_ENDPOINT_ERROR_RAW_PAYLOAD_RELAY_MINER_INVALID_SESSION, protocolobservations.ShannonSanctionType_SHANNON_SANCTION_SESSION
308+
}
309+
310+
// RelayMiner services configs undefined (code 2) - configuration error
311+
if strings.Contains(payloadContent, "services configurations are undefined") {
312+
return protocolobservations.ShannonEndpointErrorType_SHANNON_ENDPOINT_ERROR_RAW_PAYLOAD_RELAY_MINER_SERVICE_CONFIG_UNDEFINED, protocolobservations.ShannonSanctionType_SHANNON_SANCTION_PERMANENT
313+
}
314+
315+
// RelayMiner unsupported transport type (code 4) - configuration error
316+
if strings.Contains(payloadContent, "unsupported proxy transport type") {
317+
return protocolobservations.ShannonEndpointErrorType_SHANNON_ENDPOINT_ERROR_RAW_PAYLOAD_RELAY_MINER_UNSUPPORTED_TRANSPORT, protocolobservations.ShannonSanctionType_SHANNON_SANCTION_PERMANENT
318+
}
319+
320+
// RelayMiner internal error (code 5) - internal relay miner error
321+
// Note: Match exact phrase to avoid false positives with generic "internal error" strings
322+
if strings.Contains(payloadContent, "internal error") && strings.Contains(payloadContent, "relayer") {
323+
return protocolobservations.ShannonEndpointErrorType_SHANNON_ENDPOINT_ERROR_RAW_PAYLOAD_RELAY_MINER_INTERNAL_ERROR, protocolobservations.ShannonSanctionType_SHANNON_SANCTION_SESSION
324+
}
325+
326+
// RelayMiner unknown session (code 6) - session not found
327+
if strings.Contains(payloadContent, "relayer proxy encountered unknown session") {
328+
return protocolobservations.ShannonEndpointErrorType_SHANNON_ENDPOINT_ERROR_RAW_PAYLOAD_RELAY_MINER_UNKNOWN_SESSION, protocolobservations.ShannonSanctionType_SHANNON_SANCTION_SESSION
329+
}
330+
331+
// RelayMiner rate limited (code 7) - offchain rate limit hit
332+
if strings.Contains(payloadContent, "offchain rate limit hit by relayer proxy") {
333+
return protocolobservations.ShannonEndpointErrorType_SHANNON_ENDPOINT_ERROR_RAW_PAYLOAD_RELAY_MINER_RATE_LIMITED, protocolobservations.ShannonSanctionType_SHANNON_SANCTION_SESSION
334+
}
335+
336+
// RelayMiner relay cost calculation failed (code 8)
337+
if strings.Contains(payloadContent, "failed to calculate relay cost") {
338+
return protocolobservations.ShannonEndpointErrorType_SHANNON_ENDPOINT_ERROR_RAW_PAYLOAD_RELAY_MINER_RELAY_COST_CALCULATION, protocolobservations.ShannonSanctionType_SHANNON_SANCTION_SESSION
339+
}
340+
341+
// RelayMiner request limit exceeded (code 13)
342+
if strings.Contains(payloadContent, "request limit exceed") {
343+
return protocolobservations.ShannonEndpointErrorType_SHANNON_ENDPOINT_ERROR_RAW_PAYLOAD_RELAY_MINER_REQUEST_LIMIT_EXCEEDED, protocolobservations.ShannonSanctionType_SHANNON_SANCTION_DO_NOT_SANCTION
344+
}
345+
346+
// RelayMiner unmarshal relay request failed (code 14)
347+
if strings.Contains(payloadContent, "failed to unmarshal relay request") {
348+
return protocolobservations.ShannonEndpointErrorType_SHANNON_ENDPOINT_ERROR_RAW_PAYLOAD_RELAY_MINER_UNMARSHAL_REQUEST, protocolobservations.ShannonSanctionType_SHANNON_SANCTION_SESSION
349+
}
350+
295351
// If we can't classify the malformed payload, it's an internal error
296352
logger.With(
297353
"endpoint_payload_preview", payloadContent[:min(100, len(payloadContent))],

0 commit comments

Comments
 (0)