Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Session] Adding the Relay type #53

Merged
merged 10 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ require (
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1
google.golang.org/grpc v1.56.1
gopkg.in/yaml.v2 v2.4.0
)
Expand Down Expand Up @@ -259,6 +258,7 @@ require (
gonum.org/v1/gonum v0.11.0 // indirect
google.golang.org/api v0.122.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
106 changes: 106 additions & 0 deletions proto/pocket/service/relay.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
syntax = "proto3";
package pocket.service;

option go_package = "pocket/x/service/types";

import "cosmos_proto/cosmos.proto";
// TODO(@Olshansk): Uncomment the line below once the `service.proto` is added.
// import "pocket/service/service.proto";
import "pocket/application/application.proto";
import "pocket/supplier/supplier.proto";

// Relay contains both the RelayRequest (signed by the Application) and the RelayResponse (signed by the Supplier).
// The serialized tuple is inserted into the SMST leaves as values in the Claim/Proof lifecycle.
message Relay {
RelayRequest req = 1;
RelayResponse res = 2;
}

// RelayRequestMetadata contains the metadata for a RelayRequest.
message RelayRequestMetadata {
// TODO(@Olshansk): Uncomment the line below once the `service.proto` is added.
// session.SessionHeader session_header = 1; // Session header associated with the relay.
// TODO_COMMENT(@h5law): Add link or more details to how this is related to ring signatures once implemented.
bytes signature = 2; // The request signature. This may be the application signature, or any gateway it delegated to.
}

// RelayRequest holds the request details for a relay.
message RelayRequest {
RelayRequestMetadata meta = 1;
oneof payload {
JSONRPCRequestPayload json_rpc_payload = 2;
RESTRequestPayload rest_payload = 3;
// Future possible relay types:
// WebSocketsRequestPayload websockets_payload = 4;
// GRPCRequestPayload grpc_payload = 5;
// GraphQLRequestPayload graphql_payload = 6;
}
}

// JSONRPCRequestPayload contains the payload for a JSON-RPC request.
// See https://www.jsonrpc.org/specification#request_object for more details.
message JSONRPCRequestPayload {
bytes id = 1; // Identifier established by the Client to create context for the request.
string jsonrpc = 2; // Version of JSON-RPC. Must be exactly "2.0".
string method = 3; // Method being invoked on the server.
map<string, string> parameters = 4; // Parameters for the method. https://www.jsonrpc.org/specification#parameter_structures
}

// RESTRequestType represents the type of REST request.
enum RESTRequestType {
REST_REQUEST_TYPE_UNKNOWN = 0; // Default uninitialized value.
REST_REQUEST_TYPE_GET = 1;
REST_REQUEST_TYPE_PUT = 2;
REST_REQUEST_TYPE_POST = 3;
REST_REQUEST_TYPE_DELETE = 4;
}

// RESTRequestPayload contains the payload and metadata for a REST request.
message RESTRequestPayload {
RESTRequestType request_type = 1;
string http_path = 2; // Path for the REST endpoint.
string contents = 3; // Request contents.
map<string, string> headers = 4; // Request headers.
}

// RelayResponse contains the response details for a RelayRequest.
message RelayResponse {
RelayResponseMetadata meta = 1;
oneof payload {
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
JSONRPCResponsePayload json_rpc_payload = 2;
RESTResponsePayload rest_payload = 3;
// Future possible relay types:
// WebSocketsResponsePayload websockets_payload = 4;
// GRPCResponsePayload grpc_payload = 5;
// GraphQLResponsePayload graphql_payload = 6;
}
}

// RelayResponseMetadata contains the metadata for a RelayResponse.
message RelayResponseMetadata {
// TODO(@Olshansk): Uncomment the line below once the `service.proto` is added.
// session.SessionHeader session_header = 1; // Session header associated with the relay.
bytes supplier_signature = 2; // Signature of the supplier on the response.
}

// JSONRPCResponsePayload contains the response details for a JSON-RPC relay.
// See www.jsonrpc.org/specification for more details.
message JSONRPCResponsePayload {
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
bytes id = 1; // Identifier established by the Client to link the response back to the request.
string jsonrpc = 2; // Version of JSON-RPC. Must be exactly "2.0".
bytes result = 3; // Response result payload.
JSONRPCResponseError error = 4; // Error message, if any. Can be nil.
}

message JSONRPCResponseError {
int32 code = 1; // Error code.
string message = 2; // Error message.
bytes data = 3; // Error data.
}

// RESTResponsePayload contains the response details for a REST relay.
message RESTResponsePayload {
uint32 status_code = 1; // Response status code.
string err = 2; // Error message, if any.
bytes payload = 3; // Response payload.
}