proxy

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRelayerProxyInvalidSession            = sdkerrors.Register(codespace, 1, "invalid session in relayer request")
	ErrRelayerServicesConfigsUndefined       = sdkerrors.Register(codespace, 2, "services configurations are undefined")
	ErrRelayerProxyServiceEndpointNotHandled = sdkerrors.Register(codespace, 3, "service endpoint not handled by relayer proxy")
	ErrRelayerProxyUnsupportedTransportType  = sdkerrors.Register(codespace, 4, "unsupported proxy transport type")
	ErrRelayerProxyInternalError             = sdkerrors.Register(codespace, 5, "internal error")
	ErrRelayerProxyUnknownSession            = sdkerrors.Register(codespace, 6, "relayer proxy encountered unknown session")
	ErrRelayerProxyRateLimited               = sdkerrors.Register(codespace, 7, "offchain rate limit hit by relayer proxy")
	ErrRelayerProxyCalculateRelayCost        = sdkerrors.Register(codespace, 8, "failed to calculate relay cost")
)

Functions

func NewHTTPServer added in v0.0.13

func NewHTTPServer(
	logger polylog.Logger,
	serverConfig *config.RelayMinerServerConfig,
	servedRelaysProducer chan<- *types.Relay,
	relayAuthenticator relayer.RelayAuthenticator,
	relayMeter relayer.RelayMeter,
	blockClient client.BlockClient,
	sharedQueryClient client.SharedQueryClient,
	sessionQueryClient client.SessionQueryClient,
) relayer.RelayServer

NewHTTPServer creates a new RelayServer that listens for incoming relay requests and forwards them to the corresponding proxied service endpoint. TODO_RESEARCH(#590): Currently, the communication between the Gateway and the RelayMiner uses HTTP. This could be changed to a more generic and performant one, such as QUIC or pure TCP.

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:

  • polylog.Logger
  • client.BlockClient
  • client.SupplierQueryClient
  • client.SharedQueryClient
  • client.SessionQueryClient
  • relayer.RelayMeter
  • relayer.RelayAuthenticator

Available options:

  • WithServicesConfigMap

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.

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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