Documentation
¶
Overview ¶
The package protocol defines the basic concepts of any protocol that can be used by a gateway for serving user requests as relays. It is also a container for all implementations of the gateway.Protocol interface.
Index ¶
Constants ¶
const ( GatewayModeCentralized = "centralized" GatewayModeDelegated = "delegated" GatewayModePermissionless = "permissionless" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Endpoint ¶
type Endpoint interface {
// Addr is used to uniquely identify an endpoint.
// Defining this as an interface allows Shannon to
// define its own service endpoint address scheme.
// See the comment on EndpointAddr type for more details.
Addr() EndpointAddr
// PublicURL is the publically exposed/accessible URL to which relay requests can be sent.
PublicURL() string
// WebsocketURL is the URL of the endpoint for websocket RPC type requests.
// Returns an error if the endpoint does not support websocket RPC type requests.
WebsocketURL() (string, error)
}
Endpoint represents an entity which serves relay requests.
type EndpointAddr ¶
type EndpointAddr string
EndpointAddr is used as the unique identifier for a service endpoint. operator address and the endpoint's URL, separated by a "-" character.
For example:
- "pokt1ggdpwj5stslx2e567qcm50wyntlym5c4n0dst8-https://im.oldgreg.org"
func (EndpointAddr) GetAddress ¶
func (e EndpointAddr) GetAddress() (string, error)
GetAddress returns the address of the endpoint. For example: - Given the endpoint address "pokt1eetcwfv2agdl2nvpf4cprhe89rdq3cxdf037wq-https://relayminer.shannon-mainnet.eu.nodefleet.net" - Would return "pokt1eetcwfv2agdl2nvpf4cprhe89rdq3cxdf037wq"
func (EndpointAddr) GetURL ¶
func (e EndpointAddr) GetURL() (string, error)
GetURL returns the effective TLD+1 domain of the endpoint address. For example: - Given the endpoint address "pokt1eetcwfv2agdl2nvpf4cprhe89rdq3cxdf037wq-https://relayminer.shannon-mainnet.eu.nodefleet.net" - Would return "https://relayminer.shannon-mainnet.eu.nodefleet.net"
func (EndpointAddr) String ¶
func (e EndpointAddr) String() string
type EndpointAddrList ¶
type EndpointAddrList []EndpointAddr
func (EndpointAddrList) String ¶
func (e EndpointAddrList) String() string
type EndpointSelector ¶
type EndpointSelector interface {
Select(EndpointAddrList) (EndpointAddr, error)
SelectMultiple(EndpointAddrList, uint) (EndpointAddrList, error)
}
EndpointSelector defines the functionality that the user of a protocol needs to provide. E.g. selecting an endpoint, from the list of available ones, to which the relay will be sent.
type GatewayMode ¶
type GatewayMode string
TODO_MVP(@adshmh): add a README based on the following notion doc: https://www.notion.so/buildwithgrove/Different-Modes-of-Operation-PATH-LocalNet-Discussions-122a36edfff6805e9090c9a14f72f3b5
GatewayMode represents the operation mode of the gateway that is using a relaying protcol for serving user requests. It is defined in the `protocol` package for: a. Consistency: protocol package defines all key concepts related to a relaying protocol. b. Clarity: make it clear that is a protocol-level concern to be addressed by all protocol implementations.
As of now, the GatewayMode can be one of the following (see the comment attached to each mode for details). 1. Centralized 2. Delegated 3. Permissionless
type Payload ¶
type Payload struct {
Data string
Method string
Path string
Headers map[string]string
// RPCType indicates the type of RPC protocol for routing to appropriate backend ports:
// - RPCType_REST: Cosmos SDK REST API (typically port 1317)
// - RPCType_COMET_BFT: CometBFT RPC (typically port 26657)
// - RPCType_JSON_RPC: EVM JSON-RPC (typically port 8545)
RPCType sharedtypes.RPCType
}
Payload represents the HTTP(s) requests proxied between clients and backend services. TODO_DOCUMENT(@adshmh): Add more examples (e.g. for RESTful services) TODO_IMPROVE(@adshmh): Use an interface here that returns the serialized form of the request.
func EmptyErrorPayload ¶
func EmptyErrorPayload() Payload
EmptyPayload returns an empty payload struct. It should only be used when an error is encountered and the actual request cannot be proxied, parsed or otherwise processed.
type Response ¶
type Response struct {
// Bytes is the response to a relay received from an endpoint.
// An endpoint is the backend server servicing an onchain service.
// This can be the serialized response to any type of RPC (gRPC, HTTP, etc.)
Bytes []byte
// HTTPStatusCode is the HTTP status returned by an endpoint in response to a relay request.
HTTPStatusCode int
// EndpointAddr is the address of the endpoint which returned the response.
EndpointAddr
}
Response is a general purpose struct for capturing the response to a relay, received from an endpoint. TODO_FUTURE(@adshmh): It only supports HTTP responses for now; add support for others.
type ServiceID ¶
type ServiceID string
ServiceID represents a unique onchain ID for a service. It is defined in the `protocol` package and not the `qos` package because: A. Protocols (i.e. Shannon) define and maintain onchain entities, including service IDs. B. The `qos` package handles offchain specs & details. C. This allows the `gateway` package to map multiple Service IDs to a single qos implementation, e.g. all EVM blockchain services can be handled by `qos/evm`.