Skip to content

Commit

Permalink
Rename renaming components
Browse files Browse the repository at this point in the history
  • Loading branch information
Olshansk committed Nov 6, 2023
1 parent 60f0fcd commit 2b95bc4
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 56 deletions.
166 changes: 132 additions & 34 deletions docs/static/openapi.yml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
cosmossdk.io/math v1.0.1
github.com/cometbft/cometbft v0.37.2
github.com/cometbft/cometbft-db v0.8.0
github.com/cosmos/cosmos-proto v1.0.0-beta.2
github.com/cosmos/cosmos-sdk v0.47.3
github.com/cosmos/gogoproto v1.4.10
github.com/cosmos/ibc-go/v7 v7.1.0
Expand All @@ -26,6 +27,7 @@ require (
go.uber.org/multierr v1.11.0
golang.org/x/crypto v0.12.0
golang.org/x/sync v0.3.0
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 @@ -69,7 +71,6 @@ require (
github.com/containerd/cgroups v1.1.0 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.2 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/iavl v0.20.0 // indirect
Expand Down Expand Up @@ -265,7 +266,6 @@ 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
2 changes: 1 addition & 1 deletion pkg/relayer/proxy/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ type RelayServer interface {
// Stop terminates the service server and returns an error if it fails.
Stop(ctx context.Context) error

// ServiceId returns the serviceId of the service.
// Service returns the serviceId of the service.
Service() *sharedtypes.Service
}
14 changes: 7 additions & 7 deletions pkg/relayer/proxy/jsonrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
var _ RelayServer = (*jsonRPCServer)(nil)

type jsonRPCServer struct {
// serviceId is the id of the service that the server is responsible for.
serviceId *sharedtypes.ServiceId
// service is the id of the service that the server is responsible for.
service *sharedtypes.Service

// serverEndpoint is the advertised endpoint configuration that the server uses to
// listen for incoming relay requests.
Expand All @@ -38,14 +38,14 @@ type jsonRPCServer struct {
// It takes the serviceId, endpointUrl, and the main RelayerProxy as arguments and returns
// a RelayServer that listens to incoming RelayRequests
func NewJSONRPCServer(
serviceId *sharedtypes.ServiceId,
service *sharedtypes.Service,
supplierEndpoint *sharedtypes.SupplierEndpoint,
proxiedServiceEndpoint url.URL,
servedRelaysProducer chan<- *types.Relay,
proxy RelayerProxy,
) RelayServer {
return &jsonRPCServer{
serviceId: serviceId,
service: service,
serverEndpoint: supplierEndpoint,
server: &http.Server{Addr: supplierEndpoint.Url},
relayerProxy: proxy,
Expand All @@ -71,9 +71,9 @@ func (j *jsonRPCServer) Stop(ctx context.Context) error {
return j.server.Shutdown(ctx)
}

// ServiceId returns the serviceId of the JSON-RPC service.
func (j *jsonRPCServer) ServiceId() *sharedtypes.ServiceId {
return j.serviceId
// Service returns the serviceId of the JSON-RPC service.
func (j *jsonRPCServer) Service() *sharedtypes.Service {
return j.service
}

// ServeHTTP listens for incoming relay requests. It implements the respective
Expand Down
8 changes: 4 additions & 4 deletions pkg/relayer/proxy/server_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func (rp *relayerProxy) BuildProvidedServices(ctx context.Context) error {
// Build the advertised relay servers map. For each service's endpoint, create the appropriate RelayServer.
providedServices := make(relayServersMap)
for _, serviceConfig := range services {
serviceId := serviceConfig.ServiceId
proxiedServicesEndpoints := rp.proxiedServicesEndpoints[serviceId.Id]
service := serviceConfig.Service
proxiedServicesEndpoints := rp.proxiedServicesEndpoints[service.Id]
serviceEndpoints := make([]RelayServer, len(serviceConfig.Endpoints))

for _, endpoint := range serviceConfig.Endpoints {
Expand All @@ -40,7 +40,7 @@ func (rp *relayerProxy) BuildProvidedServices(ctx context.Context) error {
switch endpoint.RpcType {
case sharedtypes.RPCType_JSON_RPC:
server = NewJSONRPCServer(
serviceId,
service,
endpoint,
proxiedServicesEndpoints,
rp.servedRelaysProducer,
Expand All @@ -53,7 +53,7 @@ func (rp *relayerProxy) BuildProvidedServices(ctx context.Context) error {
serviceEndpoints = append(serviceEndpoints, server)
}

providedServices[serviceId.Id] = serviceEndpoints
providedServices[service.Id] = serviceEndpoints
}

rp.advertisedRelayServers = providedServices
Expand Down
7 changes: 1 addition & 6 deletions proto/pocket/shared/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,14 @@ package pocket.shared;

option go_package = "github.com/pokt-network/poktroll/x/shared/types";

// TODO_CLEANUP(@Olshansk): Add native optional identifiers once its supported; https://github.com/ignite/cli/issues/3698

// Service message to encapsulate unique and semantic identifiers for a service on the network
message Service {
// NOTE: `ServiceId.Id` may seem redundant but was desigtned created to enable more complex service identification
// NOTE: `Service.Id` may seem redundant but was desigtned created to enable more complex service identification
// For example, what if we want to request a session for a certain service but with some additional configs that identify it?
string id = 1; // Unique identifier for the service

// TODO_TECHDEBT: Name is currently unused but acts as a reminder than an optional onchain representation of the service is necessary
string name = 2; // (Optional) Semantic human readable name for the service

// NOTE: `ServiceId.Id` may seem redundant but was designed to enable more complex service identification.
// For example, what if we want to request a session for a certain service but with some additional configs that identify it?
}

// ApplicationServiceConfig holds the service configuration the application stakes for
Expand Down
2 changes: 1 addition & 1 deletion x/session/keeper/session_hydrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (k Keeper) hydrateSessionID(ctx sdk.Context, sh *sessionHydrator) error {
prevHashBz := []byte("TODO_BLOCKER: See the comment above")
appPubKeyBz := []byte(sh.sessionHeader.ApplicationAddress)

// TODO_TECHDEBT: In the future, we will need to valid that the ServiceId is a valid service depending on whether
// TODO_TECHDEBT: In the future, we will need to valid that the Service is a valid service depending on whether
// or not its permissioned or permissionless
// TODO(@Olshansk): Add a check to make sure `IsValidServiceName(Service.Id)` returns True
serviceIdBz := []byte(sh.sessionHeader.Service.Id)
Expand Down
2 changes: 1 addition & 1 deletion x/supplier/keeper/supplier.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ func (k Keeper) GetAllSupplier(ctx sdk.Context) (suppliers []sharedtypes.Supplie
return
}

// TODO_OPTIMIZE: Index suppliers by serviceId so we can easily query `k.GetAllSupplier(ctx, ServiceId)`
// TODO_OPTIMIZE: Index suppliers by serviceId so we can easily query `k.GetAllSupplier(ctx, Service)`
// func (k Keeper) GetAllSupplier(ctx, sdkContext, serviceId string) (suppliers []sharedtypes.Supplier) {}

0 comments on commit 2b95bc4

Please sign in to comment.