proxy

package
v0.0.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2024 License: MIT Imports: 42 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRelayerProxyUnsupportedRPCType             = sdkerrors.Register(codespace, 1, "unsupported rpc type")
	ErrRelayerProxyInvalidSession                 = sdkerrors.Register(codespace, 2, "invalid session in relayer request")
	ErrRelayerProxyInvalidSupplier                = sdkerrors.Register(codespace, 3, "supplier does not belong to session")
	ErrRelayerProxyUndefinedSigningKeyNames       = sdkerrors.Register(codespace, 4, "supplier signing key names are undefined")
	ErrRelayerServicesConfigsUndefined            = sdkerrors.Register(codespace, 5, "services configurations are undefined")
	ErrRelayerProxyInvalidRelayRequest            = sdkerrors.Register(codespace, 6, "invalid relay request")
	ErrRelayerProxyInvalidRelayResponse           = sdkerrors.Register(codespace, 7, "invalid relay response")
	ErrRelayerProxyServiceEndpointNotHandled      = sdkerrors.Register(codespace, 8, "service endpoint not handled by relayer proxy")
	ErrRelayerProxyUnsupportedTransportType       = sdkerrors.Register(codespace, 9, "unsupported proxy transport type")
	ErrRelayerProxyInternalError                  = sdkerrors.Register(codespace, 10, "internal error")
	ErrRelayerProxyMissingSupplierOperatorAddress = sdkerrors.Register(codespace, 11, "supplier operator address is missing")
	ErrRelayerProxyUnknownSession                 = sdkerrors.Register(codespace, 12, "relayer proxy encountered unknown session")
	ErrRelayerProxyRateLimited                    = sdkerrors.Register(codespace, 13, "offchain rate limit hit by relayer proxy")
	ErrRelayerProxyUnclaimRelayPrice              = sdkerrors.Register(codespace, 14, "failed to unclaim relay price")
)

Functions

func NewRelayMeter added in v0.0.11

func NewRelayMeter(deps depinject.Config) (relayer.RelayMeter, error)

func NewRelayerProxy

func NewRelayerProxy(
	deps depinject.Config,
	opts ...relayer.RelayerProxyOption,
) (relayer.RelayerProxy, error)

NewRelayerProxy creates a new relayer proxy with the given dependencies or returns an error if the dependencies fail to resolve or the options are invalid.

Required dependencies:

  • cosmosclient.Context
  • client.BlockClient
  • crypto.RingCache
  • client.SupplierQueryClient
  • client.SessionQueryClient
  • client.SharedQueryClient
  • keyring.Keyring
  • client.SharedQueryClient
  • client.ApplicationQueryClient
  • client.ServiceQueryClient
  • client.EventsQueryClient

Available options:

  • WithSigningKeyNames
  • WithServicesConfigMap

func NewSynchronousServer

func NewSynchronousServer(
	logger polylog.Logger,
	serverConfig *config.RelayMinerServerConfig,
	servedRelaysProducer chan<- *types.Relay,
	proxy relayer.RelayerProxy,
	relayMeter relayer.RelayMeter,
) relayer.RelayServer

NewSynchronousServer creates a new HTTP server that listens for incoming relay requests and forwards them to the supported proxied service endpoint. It takes the serviceId, endpointUrl, and the main RelayerProxy as arguments and returns a RelayServer that listens to incoming RelayRequests. TODO_RESEARCH(#590): Currently, the communication between the AppGateServer and the RelayMiner uses HTTP. This could be changed to a more generic and performant one, such as pure TCP.

func WithServicesConfigMap

func WithServicesConfigMap(servicesConfigMap map[string]*config.RelayMinerServerConfig) relayer.RelayerProxyOption

WithServicesConfigMap updates the configurations of all the services the RelayMiner proxies requests to. servicesConfigMap is a map of server endpoints to their respective parsed configurations.

func WithSigningKeyNames added in v0.0.3

func WithSigningKeyNames(keyNames []string) relayer.RelayerProxyOption

WithSigningKeyName sets the signing key name used by the relayer proxy to sign relay responses. It is used along with the keyring to get the supplier operator address and sign the relay responses.

Types

type ProxyRelayMeter added in v0.0.11

type ProxyRelayMeter struct {
	// contains filtered or unexported fields
}

ProxyRelayMeter is the offchain Supplier's rate limiter. It ensures that no Application is over-serviced by the Supplier per session. This is done by maintaining the max amount of stake the supplier can consume per session and the amount of stake consumed by mined relays. TODO_POST_MAINNET(@red-0ne): Consider making the relay meter a light client, since it's already receiving all committed blocks and events.

func (*ProxyRelayMeter) AccumulateRelayReward added in v0.0.11

func (rmtr *ProxyRelayMeter) AccumulateRelayReward(ctx context.Context, reqMeta servicetypes.RelayRequestMetadata) error

AccumulateRelayReward accumulates the relay reward for the given relay request. The relay reward is added optimistically, assuming that the relay will be volume / reward applicable and the relay meter would remain up to date.

func (*ProxyRelayMeter) SetNonApplicableRelayReward added in v0.0.11

func (rmtr *ProxyRelayMeter) SetNonApplicableRelayReward(ctx context.Context, reqMeta servicetypes.RelayRequestMetadata) error

SetNonApplicableRelayReward updates the relay meter to make the relay reward for the given relay request as non-applicable. This is used when the relay is not volume / reward applicable but was optimistically accounted for in the relay meter.

func (*ProxyRelayMeter) Start added in v0.0.11

func (rmtr *ProxyRelayMeter) Start(ctx context.Context) error

Start starts the relay meter by observing application staked events and new sessions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL