From a8ba1751a34ed53ea0ad0b8a479eb6d10297c8cc Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Tue, 10 Oct 2023 21:19:42 -0400 Subject: [PATCH] First iteration --- proto/pocket/service/relay.proto | 76 ++++++-------------------------- 1 file changed, 13 insertions(+), 63 deletions(-) diff --git a/proto/pocket/service/relay.proto b/proto/pocket/service/relay.proto index 4bfaee55a..5c7aa707a 100644 --- a/proto/pocket/service/relay.proto +++ b/proto/pocket/service/relay.proto @@ -27,53 +27,46 @@ message RelayRequestMetadata { // RelayResponse is used to hold the response from a RelayRequest. message RelayRequest { RelayRequestMetadata meta = 1; - // Every different chain/service may have its own custom payload (e.g. HTTP, JSON, GRPC, non-chain services) - oneof relay_payload { + // TODO: Add other relay types in the future such as the ones below: + oneof payload { JSONRPCPayload json_rpc_payload = 2; RESTPayload rest_payload = 3; - // TODO: Add other relay types in the future such as the ones below: // WebSocketsPayload websockets_payload = 4; // GRPCPayload grpc_payload = 5; // GraphQLPayload graphql_payload = 6; } } - +// RelayResponseMetadata is used to hold the metadata for a RelayResponse message RelayResponseMetadata { session.SessionHeader session_header = 1; // The session header for the relay map headers = 2; // The headers of the response - uint32 status_code = 3; - string err = 4; + uint32 status_code = 3; // The status code of the response + string err = 4; // The error message of the response bytes supplier_signature = 5; // The signature of the supplier on the response } +// RelayResponse is used to hold the response to a RelayRequest. message RelayResponse { RelayResponseMetadata meta = 1; - // Every different chain/service may have its own custom payload (e.g. HTTP, JSON, GRPC, non-chain services) - oneof relay_payload { + // TODO: Add other relay types in the future such as the ones below: + oneof payload { JSONRPCPayload json_rpc_payload = 2; RESTPayload rest_payload = 3; + // WebSocketsPayload websockets_payload = 4; + // GRPCPayload grpc_payload = 5; + // GraphQLPayload graphql_payload = 6; } } - -// map headers = 1; -// uint32 status_code = 2; -// string err = 3; -// bytes payload = 4; -// string session_id = 5; -// string servicer_address = 6; -// bytes servicer_signature = 7; -// } - // JSONRPCPayload is used to hold the payload and request metadata for a JSON-RPC request. // See the JSONRPC spec in the following link for more details: https://www.jsonrpc.org/specification#request_object message JSONRPCPayload { bytes id = 1; // JSONRPC version 2 expected a field named "id". string jsonrpc = 2; // JSONRPC version 2 expects a field named "jsonrpc" with a value of "2.0". string method = 3; // The method being invoked on the server. - bytes parameters = 4; // The parameters field can be empty, an array or a structure - + map parameters = 4; // The parameters field can be empty, an array or a structure + bytes data = 5; } // RESTRequestType is used to hold the type of REST request being made. @@ -91,47 +84,4 @@ message RESTPayload { string http_path = 2; string contents = 3; // TODO_INCOMPLETE: Add REST relay payload fields -} - - -// TODO_REFACTOR: See the commened out structure at the bottom of this file for what we should use in prod. - -// Representation of Go's http.Request (simplified naïve implementation) -message RelayRequest { - map headers = 1; - string method = 2; - string url = 3; - bytes payload = 4; - string session_id = 5; - string application_address = 6; - bytes application_signature = 7; -} - - -message RelayProof { - option (gogoproto.goproto_getters) = false; - - string requestHash = 1 [(gogoproto.jsontag) = "request_hash"]; - int64 entropy = 2 [(gogoproto.jsontag) = "entropy"]; - int64 sessionBlockHeight = 3 [(gogoproto.jsontag) = "session_block_height"]; - string servicerPubKey = 4 [(gogoproto.jsontag) = "servicer_pub_key"]; - string blockchain = 5 [(gogoproto.jsontag) = "blockchain"]; - AAT token = 6 [(gogoproto.jsontag) = "aat", (gogoproto.nullable) = false]; - string signature = 7 [(gogoproto.jsontag) = "signature"]; -} - -message ChallengeProofInvalidData { - option (gogoproto.goproto_getters) = false; - - repeated RelayResponse majorityResponses = 1 [(gogoproto.jsontag) = "majority_responses", (gogoproto.nullable) = false]; - RelayResponse minorityResponse = 2 [(gogoproto.jsontag) = "minority_response", (gogoproto.nullable) = false]; - bytes reporterAddress = 3 [(gogoproto.jsontag) = "reporters_address", (gogoproto.casttype) = "github.com/pokt-network/pocket-core/types.Address"]; -} - -message RelayResponse { - option (gogoproto.goproto_getters) = false; - - - string response = 1 [(gogoproto.jsontag) = "payload"]; - RelayProof proof = 2 [(gogoproto.jsontag) = "proof", (gogoproto.nullable) = false]; } \ No newline at end of file