Skip to content

Commit 51479e1

Browse files
authored
[QoS][EVM][Observability] QoS EVM: set request error on protocol error (#447)
## Summary Fix: QoS EVM: set request error on protocol error
1 parent f207e35 commit 51479e1

6 files changed

Lines changed: 85 additions & 38 deletions

File tree

metrics/qos/evm/metrics.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,14 @@ func PublishMetrics(logger polylog.Logger, observations *qos.EVMRequestObservati
199199
errorType = requestError.String()
200200
}
201201

202+
// TODO_TECHDEBT(@adshmh): Move this to the EVM interpreter logic:
203+
// - Drop structs not generated from proto files: e.g. observation.EVMRequestError
204+
// - Update the EVM interpreter to return an HTTP status code and an error_type string instead.
205+
if requestErr := observations.GetRequestError(); requestErr != nil {
206+
statusCode = int(requestErr.GetHttpStatusCode())
207+
errorType = requestErr.GetErrorKind().String()
208+
}
209+
202210
// Count each method as a separate request.
203211
// This is required for batch requests.
204212
for _, method := range methods {

observation/protocol/shannon.pb.go

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

observation/qos/evm.pb.go

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

observation/qos/evm_interpreter.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ func (i *EVMObservationInterpreter) GetRequestOrigin() string {
123123
return i.Observations.GetRequestOrigin().String()
124124
}
125125

126+
// TODO_TECHDEBT(@adshmh): Check for any request-level errors.
127+
// - Example: no responses received from any endpoints.
128+
// - Drop EVMRequestError struct, and use RequestError directly.
129+
//
126130
// GetRequestStatus interprets the observations to determine request status information:
127131
// - httpStatusCode: the suggested HTTP status code to return to the client
128132
// - requestError: error details (nil if successful)

proto/path/qos/evm.proto

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ option go_package = "github.com/buildwithgrove/path/observation/qos";
1919
import "path/qos/jsonrpc.proto";
2020
import "path/qos/request_origin.proto";
2121
import "path/qos/endpoint_selection_metadata.proto";
22+
import "path/qos/request_error.proto";
2223
import "path/metadata/metadata.proto";
2324

2425
// EVMRequestValidationError enumerates possible causes for EVM request rejection:
@@ -64,7 +65,7 @@ enum EVMResponseValidationError {
6465

6566
// EVMRequestObservations captures all observations made while serving a single EVM blockchain service request.
6667
message EVMRequestObservations {
67-
// Next ID: 11
68+
// Next ID: 12
6869

6970
// JsonRpcRequest and endpoint_observations are no longer supported.
7071
// They are replaced by EVMRequestObservation.
@@ -109,6 +110,12 @@ message EVMRequestObservations {
109110

110111
// endpoint_selection_metadata contains metadata about the endpoint selection process.
111112
EndpointSelectionMetadata endpoint_selection_metadata = 9;
113+
114+
// Internal error encountered processing the request, if any.
115+
// Example: no endpoint responses received.
116+
// On single JSONRPC request: applies to the single request.
117+
// On batch JSONRPC requests: only set if the entire batch failed (e.g. no endpoint responses for any of the requests of the batch)
118+
optional RequestError request_error = 11;
112119
}
113120

114121
// EVMRequestObservation stores a single observation from an endpoint servicing the protocol response.
@@ -283,4 +290,4 @@ message EVMNoResponse {
283290

284291
// Always set to NO_RESPONSE for this scenario
285292
EVMResponseValidationError response_validation_error = 2 [(metadata.semantic_meaning) = "Validity failure type"];
286-
}
293+
}

qos/evm/context.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
pathhttp "github.com/buildwithgrove/path/network/http"
1111
qosobservations "github.com/buildwithgrove/path/observation/qos"
1212
"github.com/buildwithgrove/path/protocol"
13+
"github.com/buildwithgrove/path/qos"
1314
"github.com/buildwithgrove/path/qos/jsonrpc"
1415
)
1516

@@ -218,13 +219,20 @@ func (rc requestContext) GetObservations() qosobservations.Observations {
218219
// Convert endpoint selection validation results to proto format
219220
validationResults := rc.convertValidationResults()
220221

222+
var requestError *qosobservations.RequestError
223+
// Set request error as protocol-level error if no endpoint responses were received.
224+
if len(rc.endpointResponses) == 0 {
225+
requestError = qos.GetRequestErrorForProtocolError()
226+
}
227+
221228
return qosobservations.Observations{
222229
ServiceObservations: &qosobservations.Observations_Evm{
223230
Evm: &qosobservations.EVMRequestObservations{
224231
ChainId: rc.chainID,
225232
ServiceId: string(rc.serviceID),
226233
RequestPayloadLength: uint32(rc.requestPayloadLength),
227234
RequestOrigin: rc.requestOrigin,
235+
RequestError: requestError,
228236
RequestObservations: requestObservations,
229237
EndpointSelectionMetadata: &qosobservations.EndpointSelectionMetadata{
230238
RandomEndpointFallback: rc.endpointSelectionMetadata.RandomEndpointFallback,
@@ -260,9 +268,11 @@ func (rc requestContext) createNoResponseObservations() []*qosobservations.EVMRe
260268
responseNoneObs := responseNoneObj.GetObservation()
261269

262270
return []*qosobservations.EVMRequestObservation{
263-
{EndpointObservations: []*qosobservations.EVMEndpointObservation{
264-
&responseNoneObs,
265-
}},
271+
{
272+
EndpointObservations: []*qosobservations.EVMEndpointObservation{
273+
&responseNoneObs,
274+
},
275+
},
266276
}
267277
}
268278

0 commit comments

Comments
 (0)