rpcconsumer

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2024 License: Apache-2.0 Imports: 56 Imported by: 0

README

Lava Server Kit (RPCConsumer)

This README covers technical aspects of running the Lava Server Kit. For more details visit https://docs.lavanet.xyz/access-server-kit or our Discord

Usage

  1. Clone the repository
  2. cd into the repository folder
  3. Run make install-all
  4. Create a configuration file with the following format:
endpoints:
  - network-address: <network-address>
    chain-id: <chain-id>
    api-interface: <api-interface>
  - network-address: <network-address>
    chain-id: <chain-id>
    api-interface: <api-interface>

The network-address specifies the IP address and port number of the node, chain-id specifies the unique identifier of the blockchain, and api-interface specifies the API interface used by the node.

  1. Start the consumer using the command rpcconsumer --config <path/to/config/file>

Documentation

Overview

Package rpcconsumer is a generated GoMock package.

Package rpcconsumer is a generated GoMock package.

Index

Constants

View Source
const (
	CacheMaxCost     = 2000  // each item cost would be 1
	CacheNumCounters = 20000 // expect 2000 items
	EntryTTL         = 5 * time.Minute
)

this class handles seen block values in requests

View Source
const (
	MaxCallsPerRelay                   = 50
	NumberOfRetriesAllowedOnNodeErrors = 2 // we will try maximum additional 2 relays on node errors
)
View Source
const (
	DefaultRPCConsumerFileName = "rpcconsumer.yml"
	DebugRelaysFlagName        = "debug-relays"
	DebugProbesFlagName        = "debug-probes"
)
View Source
const (
	// maximum number of retries to send due to the ticker, if we didn't get a response after 10 different attempts then just wait.
	MaximumNumberOfTickerRelayRetries = 10
	MaxRelayRetries                   = 6
	SendRelayAttempts                 = 3
)
View Source
const RetryEntryTTL = 6 * time.Hour

entries ttl duration

Variables

View Source
var (
	Yaml_config_properties         = []string{"network-address", "chain-id", "api-interface"}
	RelaysHealthEnableFlagDefault  = true
	RelayHealthIntervalFlagDefault = 5 * time.Minute
)
View Source
var NoResponseTimeout = sdkerrors.New("NoResponseTimeout Error", 685, "timeout occurred while waiting for providers responses")

Functions

func CreateRPCConsumerCobraCommand

func CreateRPCConsumerCobraCommand() *cobra.Command

func CreateTestRPCConsumerCobraCommand

func CreateTestRPCConsumerCobraCommand() *cobra.Command

func ParseEndpoints

func ParseEndpoints(viper_endpoints *viper.Viper, geolocation uint64) (endpoints []*lavasession.RPCEndpoint, err error)

Types

type AnalyticsServerAddressess

type AnalyticsServerAddressess struct {
	AddApiMethodCallsMetrics bool
	MetricsListenAddress     string
	RelayServerAddress       string
	ReportsAddressFlag       string
}

type CancelableContextHolder added in v2.4.0

type CancelableContextHolder struct {
	Ctx        context.Context
	CancelFunc context.CancelFunc
}

type ConsumerConsistency

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

func NewConsumerConsistency

func NewConsumerConsistency(specId string) *ConsumerConsistency

func (*ConsumerConsistency) GetSeenBlock

func (cc *ConsumerConsistency) GetSeenBlock(dappId string, ip string) (int64, bool)

func (*ConsumerConsistency) Key

func (cc *ConsumerConsistency) Key(dappId string, ip string) string

func (*ConsumerConsistency) SetSeenBlock

func (cc *ConsumerConsistency) SetSeenBlock(blockSeen int64, dappId string, ip string)

func (*ConsumerConsistency) SetSeenBlockFromKey added in v2.4.0

func (cc *ConsumerConsistency) SetSeenBlockFromKey(blockSeen int64, key string)

used on subscription, where we already have the dapp key stored, but we don't keep the dappId and ip separately

type ConsumerStateTrackerInf

type ConsumerStateTrackerInf interface {
	RegisterForVersionUpdates(ctx context.Context, version *protocoltypes.Version, versionValidator updaters.VersionValidationInf)
	RegisterConsumerSessionManagerForPairingUpdates(ctx context.Context, consumerSessionManager *lavasession.ConsumerSessionManager)
	RegisterForSpecUpdates(ctx context.Context, specUpdatable updaters.SpecUpdatable, endpoint lavasession.RPCEndpoint) error
	RegisterFinalizationConsensusForUpdates(context.Context, *finalizationconsensus.FinalizationConsensus)
	RegisterForDowntimeParamsUpdates(ctx context.Context, downtimeParamsUpdatable updaters.DowntimeParamsUpdatable) error
	TxConflictDetection(ctx context.Context, finalizationConflict *conflicttypes.FinalizationConflict, responseConflict *conflicttypes.ResponseConflict, conflictHandler common.ConflictHandlerInterface) error
	GetConsumerPolicy(ctx context.Context, consumerAddress, chainID string) (*plantypes.Policy, error)
	GetProtocolVersion(ctx context.Context) (*updaters.ProtocolVersionResponse, error)
	GetLatestVirtualEpoch() uint64
}

type ConsumerTxSender

type ConsumerTxSender interface {
	TxConflictDetection(ctx context.Context, finalizationConflict *conflicttypes.FinalizationConflict, responseConflict *conflicttypes.ResponseConflict, conflictHandler common.ConflictHandlerInterface) error
	GetConsumerPolicy(ctx context.Context, consumerAddress, chainID string) (*plantypes.Policy, error)
	GetLatestVirtualEpoch() uint64
}

type MetricsInterface

type MetricsInterface interface {
	SetRelayNodeErrorMetric(chainId string, apiInterface string)
	SetNodeErrorRecoveredSuccessfullyMetric(chainId string, apiInterface string, attempt string)
	SetNodeErrorAttemptMetric(chainId string, apiInterface string)
}

type MockConsumerStateTrackerInf added in v2.4.0

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

MockConsumerStateTrackerInf is a mock of ConsumerStateTrackerInf interface.

func NewMockConsumerStateTrackerInf added in v2.4.0

func NewMockConsumerStateTrackerInf(ctrl *gomock.Controller) *MockConsumerStateTrackerInf

NewMockConsumerStateTrackerInf creates a new mock instance.

func (*MockConsumerStateTrackerInf) EXPECT added in v2.4.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockConsumerStateTrackerInf) GetConsumerPolicy added in v2.4.0

func (m *MockConsumerStateTrackerInf) GetConsumerPolicy(ctx context.Context, consumerAddress, chainID string) (*types0.Policy, error)

GetConsumerPolicy mocks base method.

func (*MockConsumerStateTrackerInf) GetLatestVirtualEpoch added in v2.4.0

func (m *MockConsumerStateTrackerInf) GetLatestVirtualEpoch() uint64

GetLatestVirtualEpoch mocks base method.

func (*MockConsumerStateTrackerInf) GetProtocolVersion added in v2.4.0

GetProtocolVersion mocks base method.

func (*MockConsumerStateTrackerInf) RegisterConsumerSessionManagerForPairingUpdates added in v2.4.0

func (m *MockConsumerStateTrackerInf) RegisterConsumerSessionManagerForPairingUpdates(ctx context.Context, consumerSessionManager *lavasession.ConsumerSessionManager)

RegisterConsumerSessionManagerForPairingUpdates mocks base method.

func (*MockConsumerStateTrackerInf) RegisterFinalizationConsensusForUpdates added in v2.4.0

func (m *MockConsumerStateTrackerInf) RegisterFinalizationConsensusForUpdates(arg0 context.Context, arg1 *finalizationconsensus.FinalizationConsensus)

RegisterFinalizationConsensusForUpdates mocks base method.

func (*MockConsumerStateTrackerInf) RegisterForDowntimeParamsUpdates added in v2.4.0

func (m *MockConsumerStateTrackerInf) RegisterForDowntimeParamsUpdates(ctx context.Context, downtimeParamsUpdatable updaters.DowntimeParamsUpdatable) error

RegisterForDowntimeParamsUpdates mocks base method.

func (*MockConsumerStateTrackerInf) RegisterForSpecUpdates added in v2.4.0

func (m *MockConsumerStateTrackerInf) RegisterForSpecUpdates(ctx context.Context, specUpdatable updaters.SpecUpdatable, endpoint lavasession.RPCEndpoint) error

RegisterForSpecUpdates mocks base method.

func (*MockConsumerStateTrackerInf) RegisterForVersionUpdates added in v2.4.0

func (m *MockConsumerStateTrackerInf) RegisterForVersionUpdates(ctx context.Context, version *types1.Version, versionValidator updaters.VersionValidationInf)

RegisterForVersionUpdates mocks base method.

func (*MockConsumerStateTrackerInf) TxConflictDetection added in v2.4.0

func (m *MockConsumerStateTrackerInf) TxConflictDetection(ctx context.Context, finalizationConflict *types.FinalizationConflict, responseConflict *types.ResponseConflict, conflictHandler common.ConflictHandlerInterface) error

TxConflictDetection mocks base method.

type MockConsumerStateTrackerInfMockRecorder added in v2.4.0

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

MockConsumerStateTrackerInfMockRecorder is the mock recorder for MockConsumerStateTrackerInf.

func (*MockConsumerStateTrackerInfMockRecorder) GetConsumerPolicy added in v2.4.0

func (mr *MockConsumerStateTrackerInfMockRecorder) GetConsumerPolicy(ctx, consumerAddress, chainID any) *gomock.Call

GetConsumerPolicy indicates an expected call of GetConsumerPolicy.

func (*MockConsumerStateTrackerInfMockRecorder) GetLatestVirtualEpoch added in v2.4.0

func (mr *MockConsumerStateTrackerInfMockRecorder) GetLatestVirtualEpoch() *gomock.Call

GetLatestVirtualEpoch indicates an expected call of GetLatestVirtualEpoch.

func (*MockConsumerStateTrackerInfMockRecorder) GetProtocolVersion added in v2.4.0

func (mr *MockConsumerStateTrackerInfMockRecorder) GetProtocolVersion(ctx any) *gomock.Call

GetProtocolVersion indicates an expected call of GetProtocolVersion.

func (*MockConsumerStateTrackerInfMockRecorder) RegisterConsumerSessionManagerForPairingUpdates added in v2.4.0

func (mr *MockConsumerStateTrackerInfMockRecorder) RegisterConsumerSessionManagerForPairingUpdates(ctx, consumerSessionManager any) *gomock.Call

RegisterConsumerSessionManagerForPairingUpdates indicates an expected call of RegisterConsumerSessionManagerForPairingUpdates.

func (*MockConsumerStateTrackerInfMockRecorder) RegisterFinalizationConsensusForUpdates added in v2.4.0

func (mr *MockConsumerStateTrackerInfMockRecorder) RegisterFinalizationConsensusForUpdates(arg0, arg1 any) *gomock.Call

RegisterFinalizationConsensusForUpdates indicates an expected call of RegisterFinalizationConsensusForUpdates.

func (*MockConsumerStateTrackerInfMockRecorder) RegisterForDowntimeParamsUpdates added in v2.4.0

func (mr *MockConsumerStateTrackerInfMockRecorder) RegisterForDowntimeParamsUpdates(ctx, downtimeParamsUpdatable any) *gomock.Call

RegisterForDowntimeParamsUpdates indicates an expected call of RegisterForDowntimeParamsUpdates.

func (*MockConsumerStateTrackerInfMockRecorder) RegisterForSpecUpdates added in v2.4.0

func (mr *MockConsumerStateTrackerInfMockRecorder) RegisterForSpecUpdates(ctx, specUpdatable, endpoint any) *gomock.Call

RegisterForSpecUpdates indicates an expected call of RegisterForSpecUpdates.

func (*MockConsumerStateTrackerInfMockRecorder) RegisterForVersionUpdates added in v2.4.0

func (mr *MockConsumerStateTrackerInfMockRecorder) RegisterForVersionUpdates(ctx, version, versionValidator any) *gomock.Call

RegisterForVersionUpdates indicates an expected call of RegisterForVersionUpdates.

func (*MockConsumerStateTrackerInfMockRecorder) TxConflictDetection added in v2.4.0

func (mr *MockConsumerStateTrackerInfMockRecorder) TxConflictDetection(ctx, finalizationConflict, responseConflict, conflictHandler any) *gomock.Call

TxConflictDetection indicates an expected call of TxConflictDetection.

type MockRelayerClient added in v2.4.0

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

MockRelayerClient is a mock of RelayerClient interface.

func NewMockRelayerClient added in v2.4.0

func NewMockRelayerClient(ctrl *gomock.Controller) *MockRelayerClient

NewMockRelayerClient creates a new mock instance.

func (*MockRelayerClient) EXPECT added in v2.4.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockRelayerClient) Probe added in v2.4.0

Probe mocks base method.

func (*MockRelayerClient) Relay added in v2.4.0

Relay mocks base method.

func (*MockRelayerClient) RelaySubscribe added in v2.4.0

RelaySubscribe mocks base method.

type MockRelayerClientMockRecorder added in v2.4.0

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

MockRelayerClientMockRecorder is the mock recorder for MockRelayerClient.

func (*MockRelayerClientMockRecorder) Probe added in v2.4.0

func (mr *MockRelayerClientMockRecorder) Probe(ctx, in any, opts ...any) *gomock.Call

Probe indicates an expected call of Probe.

func (*MockRelayerClientMockRecorder) Relay added in v2.4.0

func (mr *MockRelayerClientMockRecorder) Relay(ctx, in any, opts ...any) *gomock.Call

Relay indicates an expected call of Relay.

func (*MockRelayerClientMockRecorder) RelaySubscribe added in v2.4.0

func (mr *MockRelayerClientMockRecorder) RelaySubscribe(ctx, in any, opts ...any) *gomock.Call

RelaySubscribe indicates an expected call of RelaySubscribe.

type MockRelayerServer added in v2.4.0

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

MockRelayerServer is a mock of RelayerServer interface.

func NewMockRelayerServer added in v2.4.0

func NewMockRelayerServer(ctrl *gomock.Controller) *MockRelayerServer

NewMockRelayerServer creates a new mock instance.

func (*MockRelayerServer) EXPECT added in v2.4.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockRelayerServer) Probe added in v2.4.0

Probe mocks base method.

func (*MockRelayerServer) Relay added in v2.4.0

Relay mocks base method.

func (*MockRelayerServer) RelaySubscribe added in v2.4.0

RelaySubscribe mocks base method.

type MockRelayerServerMockRecorder added in v2.4.0

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

MockRelayerServerMockRecorder is the mock recorder for MockRelayerServer.

func (*MockRelayerServerMockRecorder) Probe added in v2.4.0

func (mr *MockRelayerServerMockRecorder) Probe(arg0, arg1 any) *gomock.Call

Probe indicates an expected call of Probe.

func (*MockRelayerServerMockRecorder) Relay added in v2.4.0

func (mr *MockRelayerServerMockRecorder) Relay(arg0, arg1 any) *gomock.Call

Relay indicates an expected call of Relay.

func (*MockRelayerServerMockRecorder) RelaySubscribe added in v2.4.0

func (mr *MockRelayerServerMockRecorder) RelaySubscribe(arg0, arg1 any) *gomock.Call

RelaySubscribe indicates an expected call of RelaySubscribe.

type MockRelayer_RelaySubscribeClient added in v2.4.0

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

MockRelayer_RelaySubscribeClient is a mock of Relayer_RelaySubscribeClient interface.

func NewMockRelayer_RelaySubscribeClient added in v2.4.0

func NewMockRelayer_RelaySubscribeClient(ctrl *gomock.Controller) *MockRelayer_RelaySubscribeClient

NewMockRelayer_RelaySubscribeClient creates a new mock instance.

func (*MockRelayer_RelaySubscribeClient) CloseSend added in v2.4.0

func (m *MockRelayer_RelaySubscribeClient) CloseSend() error

CloseSend mocks base method.

func (*MockRelayer_RelaySubscribeClient) Context added in v2.4.0

Context mocks base method.

func (*MockRelayer_RelaySubscribeClient) EXPECT added in v2.4.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockRelayer_RelaySubscribeClient) Header added in v2.4.0

Header mocks base method.

func (*MockRelayer_RelaySubscribeClient) Recv added in v2.4.0

Recv mocks base method.

func (*MockRelayer_RelaySubscribeClient) RecvMsg added in v2.4.0

func (m_2 *MockRelayer_RelaySubscribeClient) RecvMsg(m any) error

RecvMsg mocks base method.

func (*MockRelayer_RelaySubscribeClient) SendMsg added in v2.4.0

func (m_2 *MockRelayer_RelaySubscribeClient) SendMsg(m any) error

SendMsg mocks base method.

func (*MockRelayer_RelaySubscribeClient) Trailer added in v2.4.0

Trailer mocks base method.

type MockRelayer_RelaySubscribeClientMockRecorder added in v2.4.0

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

MockRelayer_RelaySubscribeClientMockRecorder is the mock recorder for MockRelayer_RelaySubscribeClient.

func (*MockRelayer_RelaySubscribeClientMockRecorder) CloseSend added in v2.4.0

CloseSend indicates an expected call of CloseSend.

func (*MockRelayer_RelaySubscribeClientMockRecorder) Context added in v2.4.0

Context indicates an expected call of Context.

func (*MockRelayer_RelaySubscribeClientMockRecorder) Header added in v2.4.0

Header indicates an expected call of Header.

func (*MockRelayer_RelaySubscribeClientMockRecorder) Recv added in v2.4.0

Recv indicates an expected call of Recv.

func (*MockRelayer_RelaySubscribeClientMockRecorder) RecvMsg added in v2.4.0

RecvMsg indicates an expected call of RecvMsg.

func (*MockRelayer_RelaySubscribeClientMockRecorder) SendMsg added in v2.4.0

SendMsg indicates an expected call of SendMsg.

func (*MockRelayer_RelaySubscribeClientMockRecorder) Trailer added in v2.4.0

Trailer indicates an expected call of Trailer.

type MockRelayer_RelaySubscribeServer added in v2.4.0

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

MockRelayer_RelaySubscribeServer is a mock of Relayer_RelaySubscribeServer interface.

func NewMockRelayer_RelaySubscribeServer added in v2.4.0

func NewMockRelayer_RelaySubscribeServer(ctrl *gomock.Controller) *MockRelayer_RelaySubscribeServer

NewMockRelayer_RelaySubscribeServer creates a new mock instance.

func (*MockRelayer_RelaySubscribeServer) Context added in v2.4.0

Context mocks base method.

func (*MockRelayer_RelaySubscribeServer) EXPECT added in v2.4.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockRelayer_RelaySubscribeServer) RecvMsg added in v2.4.0

func (m_2 *MockRelayer_RelaySubscribeServer) RecvMsg(m any) error

RecvMsg mocks base method.

func (*MockRelayer_RelaySubscribeServer) Send added in v2.4.0

Send mocks base method.

func (*MockRelayer_RelaySubscribeServer) SendHeader added in v2.4.0

func (m *MockRelayer_RelaySubscribeServer) SendHeader(arg0 metadata.MD) error

SendHeader mocks base method.

func (*MockRelayer_RelaySubscribeServer) SendMsg added in v2.4.0

func (m_2 *MockRelayer_RelaySubscribeServer) SendMsg(m any) error

SendMsg mocks base method.

func (*MockRelayer_RelaySubscribeServer) SetHeader added in v2.4.0

SetHeader mocks base method.

func (*MockRelayer_RelaySubscribeServer) SetTrailer added in v2.4.0

func (m *MockRelayer_RelaySubscribeServer) SetTrailer(arg0 metadata.MD)

SetTrailer mocks base method.

type MockRelayer_RelaySubscribeServerMockRecorder added in v2.4.0

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

MockRelayer_RelaySubscribeServerMockRecorder is the mock recorder for MockRelayer_RelaySubscribeServer.

func (*MockRelayer_RelaySubscribeServerMockRecorder) Context added in v2.4.0

Context indicates an expected call of Context.

func (*MockRelayer_RelaySubscribeServerMockRecorder) RecvMsg added in v2.4.0

RecvMsg indicates an expected call of RecvMsg.

func (*MockRelayer_RelaySubscribeServerMockRecorder) Send added in v2.4.0

Send indicates an expected call of Send.

func (*MockRelayer_RelaySubscribeServerMockRecorder) SendHeader added in v2.4.0

SendHeader indicates an expected call of SendHeader.

func (*MockRelayer_RelaySubscribeServerMockRecorder) SendMsg added in v2.4.0

SendMsg indicates an expected call of SendMsg.

func (*MockRelayer_RelaySubscribeServerMockRecorder) SetHeader added in v2.4.0

SetHeader indicates an expected call of SetHeader.

func (*MockRelayer_RelaySubscribeServerMockRecorder) SetTrailer added in v2.4.0

SetTrailer indicates an expected call of SetTrailer.

type RPCConsumer

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

func (*RPCConsumer) Start

func (rpcc *RPCConsumer) Start(ctx context.Context, options *rpcConsumerStartOptions) (err error)

spawns a new RPCConsumer server with all it's processes and internals ready for communications

type RPCConsumerServer

type RPCConsumerServer struct {
	ConsumerAddress sdk.AccAddress
	// contains filtered or unexported fields
}

implements Relay Sender interfaced and uses an ChainListener to get it called

func (*RPCConsumerServer) CancelSubscriptionContext added in v2.4.0

func (rpccs *RPCConsumerServer) CancelSubscriptionContext(subscriptionKey string)

func (*RPCConsumerServer) CreateDappKey added in v2.4.0

func (rpccs *RPCConsumerServer) CreateDappKey(dappID, consumerIp string) string

func (*RPCConsumerServer) GetChainIdAndApiInterface

func (rpccs *RPCConsumerServer) GetChainIdAndApiInterface() (string, string)

func (*RPCConsumerServer) GetListeningAddress added in v2.4.0

func (rpccs *RPCConsumerServer) GetListeningAddress() string

func (*RPCConsumerServer) HandleDirectiveHeadersForMessage

func (rpccs *RPCConsumerServer) HandleDirectiveHeadersForMessage(chainMessage chainlib.ChainMessage, directiveHeaders map[string]string)

func (*RPCConsumerServer) IsHealthy

func (rpccs *RPCConsumerServer) IsHealthy() bool

func (*RPCConsumerServer) LavaDirectiveHeaders

func (rpccs *RPCConsumerServer) LavaDirectiveHeaders(metadata []pairingtypes.Metadata) ([]pairingtypes.Metadata, map[string]string)

func (*RPCConsumerServer) ParseRelay added in v2.4.0

func (rpccs *RPCConsumerServer) ParseRelay(
	ctx context.Context,
	url string,
	req string,
	connectionType string,
	dappID string,
	consumerIp string,
	analytics *metrics.RelayMetrics,
	metadata []pairingtypes.Metadata,
) (chainMessage chainlib.ChainMessage, directiveHeaders map[string]string, relayRequestData *pairingtypes.RelayPrivateData, err error)

func (*RPCConsumerServer) ProcessRelaySend

func (rpccs *RPCConsumerServer) ProcessRelaySend(ctx context.Context, directiveHeaders map[string]string, chainMessage chainlib.ChainMessage, relayRequestData *pairingtypes.RelayPrivateData, dappID string, consumerIp string, analytics *metrics.RelayMetrics) (*RelayProcessor, error)

func (*RPCConsumerServer) SendParsedRelay added in v2.4.0

func (rpccs *RPCConsumerServer) SendParsedRelay(
	ctx context.Context,
	dappID string,
	consumerIp string,
	analytics *metrics.RelayMetrics,
	chainMessage chainlib.ChainMessage,
	directiveHeaders map[string]string,
	relayRequestData *pairingtypes.RelayPrivateData,
) (relayResult *common.RelayResult, errRet error)

func (*RPCConsumerServer) SendRelay

func (rpccs *RPCConsumerServer) SendRelay(
	ctx context.Context,
	url string,
	req string,
	connectionType string,
	dappID string,
	consumerIp string,
	analytics *metrics.RelayMetrics,
	metadata []pairingtypes.Metadata,
) (relayResult *common.RelayResult, errRet error)

func (*RPCConsumerServer) ServeRPCRequests

func (rpccs *RPCConsumerServer) ServeRPCRequests(ctx context.Context, listenEndpoint *lavasession.RPCEndpoint,
	consumerStateTracker ConsumerStateTrackerInf,
	chainParser chainlib.ChainParser,
	finalizationConsensus finalizationconsensus.FinalizationConsensusInf,
	consumerSessionManager *lavasession.ConsumerSessionManager,
	requiredResponses int,
	privKey *btcec.PrivateKey,
	lavaChainID string,
	cache *performance.Cache,
	rpcConsumerLogs *metrics.RPCConsumerLogs,
	consumerAddress sdk.AccAddress,
	consumerConsistency *ConsumerConsistency,
	relaysMonitor *metrics.RelaysMonitor,
	cmdFlags common.ConsumerCmdFlags,
	sharedState bool,
	refererData *chainlib.RefererData,
	reporter metrics.Reporter,
	consumerWsSubscriptionManager *chainlib.ConsumerWSSubscriptionManager,
) (err error)

func (*RPCConsumerServer) SetConsistencySeenBlock added in v2.4.0

func (rpccs *RPCConsumerServer) SetConsistencySeenBlock(blockSeen int64, key string)

type RelayError

type RelayError struct {
	ProviderInfo common.ProviderInfo
	// contains filtered or unexported fields
}

TODO: there's no need to save error twice and provider info twice, this can just be a relayResponse

func (RelayError) String

func (re RelayError) String() string

type RelayErrors

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

func (*RelayErrors) GetBestErrorMessageForUser

func (r *RelayErrors) GetBestErrorMessageForUser() RelayError

type RelayProcessor

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

func NewRelayProcessor

func NewRelayProcessor(
	ctx context.Context,
	usedProviders *lavasession.UsedProviders,
	requiredSuccesses int,
	chainMessage chainlib.ChainMessage,
	consumerConsistency *ConsumerConsistency,
	dappID string,
	consumerIp string,
	debugRelay bool,
	metricsInf MetricsInterface,
	chainIdAndApiInterfaceGetter chainIdAndApiInterfaceGetter,
	disableRelayRetry bool,
	relayRetriesManager *RelayRetriesManager,
) *RelayProcessor

func (*RelayProcessor) GetAllowSessionDegradation

func (rp *RelayProcessor) GetAllowSessionDegradation() bool

true if we never got an extension. (default value)

func (*RelayProcessor) GetUsedProviders

func (rp *RelayProcessor) GetUsedProviders() *lavasession.UsedProviders

func (*RelayProcessor) HasRequiredNodeResults

func (rp *RelayProcessor) HasRequiredNodeResults() bool

func (*RelayProcessor) HasResults

func (rp *RelayProcessor) HasResults() bool

this function defines if we should use the processor to return the result (meaning it has some insight and responses) or just return to the user

func (*RelayProcessor) NodeResults

func (rp *RelayProcessor) NodeResults() []common.RelayResult

this function returns all results that came from a node, meaning success, and node errors

func (*RelayProcessor) ProcessingResult

func (rp *RelayProcessor) ProcessingResult() (returnedResult *common.RelayResult, processingError error)

this function returns the results according to the defined strategy results were stored in WaitForResults and now there's logic to select which results are returned to the user will return an error if we did not meet quota of replies, if we did we follow the strategies: if return strategy == get_first: return the first success, if none: get best node error if strategy == quorum get majority of node responses on error: we will return a placeholder relayResult, with a provider address and a status code

func (*RelayProcessor) ProtocolErrors

func (rp *RelayProcessor) ProtocolErrors() uint64

func (*RelayProcessor) SetDisallowDegradation

func (rp *RelayProcessor) SetDisallowDegradation()

in case we had an extension and managed to get a session successfully, we prevent session degradation.

func (*RelayProcessor) SetResponse

func (rp *RelayProcessor) SetResponse(response *relayResponse)

func (*RelayProcessor) ShouldRetry

func (rp *RelayProcessor) ShouldRetry(numberOfRetriesLaunched int) bool

func (*RelayProcessor) String

func (rp *RelayProcessor) String() string

func (*RelayProcessor) WaitForResults

func (rp *RelayProcessor) WaitForResults(ctx context.Context) error

this function waits for the processing results, they are written by multiple go routines and read by this go routine it then updates the responses in their respective place, node errors, protocol errors or success results

type RelayRetriesManager

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

On node errors we try to send a relay again. If this relay failed all retries we ban it from retries to avoid spam and save resources

func NewRelayRetriesManager

func NewRelayRetriesManager() *RelayRetriesManager

func (*RelayRetriesManager) AddHashToCache

func (rrm *RelayRetriesManager) AddHashToCache(hash string)

Add hash to the retry cache.

func (*RelayRetriesManager) CheckHashInCache

func (rrm *RelayRetriesManager) CheckHashInCache(hash string) bool

Check if we already have this hash so we don't retry.

func (*RelayRetriesManager) RemoveHashFromCache

func (rrm *RelayRetriesManager) RemoveHashFromCache(hash string)

Remove hash from cache if it exists

type Selection

type Selection int
const (
	Quorum     Selection = iota // get the majority out of requiredSuccesses
	BestResult                  // get the best result, even if it means waiting
)

Jump to

Keyboard shortcuts

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