rpcconsumer

package
v3.1.7-near-hf Latest Latest
Warning

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

Go to latest
Published: Sep 15, 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     = 20000 // 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 (
	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 (
	MaxCallsPerRelay = 50
)

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

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(userData common.UserData) (int64, bool)

func (*ConsumerConsistency) Key

func (cc *ConsumerConsistency) Key(userData common.UserData) string

func (*ConsumerConsistency) SetSeenBlock

func (cc *ConsumerConsistency) SetSeenBlock(blockSeen int64, userData common.UserData)

func (*ConsumerConsistency) SetSeenBlockFromKey

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 ConsumerRelaySender added in v3.1.5

type ConsumerRelaySender interface {
	GetChainIdAndApiInterface() (string, string)
	GetExtensionParser() *extensionslib.ExtensionParser
	// contains filtered or unexported methods
}

type ConsumerRelayStateMachine added in v3.1.5

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

func (*ConsumerRelayStateMachine) GetDebugState added in v3.1.5

func (crsm *ConsumerRelayStateMachine) GetDebugState() bool

func (*ConsumerRelayStateMachine) GetProtocolMessage added in v3.1.5

func (crsm *ConsumerRelayStateMachine) GetProtocolMessage() chainlib.ProtocolMessage

func (*ConsumerRelayStateMachine) GetRelayTaskChannel added in v3.1.5

func (crsm *ConsumerRelayStateMachine) GetRelayTaskChannel() chan RelayStateSendInstructions

func (*ConsumerRelayStateMachine) GetSelection added in v3.1.5

func (crsm *ConsumerRelayStateMachine) GetSelection() Selection

func (*ConsumerRelayStateMachine) GetUsedProviders added in v3.1.5

func (crsm *ConsumerRelayStateMachine) GetUsedProviders() *lavasession.UsedProviders

func (*ConsumerRelayStateMachine) SetRelayProcessor added in v3.1.5

func (crsm *ConsumerRelayStateMachine) SetRelayProcessor(relayProcessor *RelayProcessor)

func (*ConsumerRelayStateMachine) ShouldRetry added in v3.1.5

func (crsm *ConsumerRelayStateMachine) ShouldRetry(numberOfRetriesLaunched int) bool

func (*ConsumerRelayStateMachine) UpdateBatch added in v3.1.5

func (crsm *ConsumerRelayStateMachine) UpdateBatch(err error)

type ConsumerStateTrackerInf

type ConsumerStateTrackerInf interface {
	RegisterForVersionUpdates(ctx context.Context, version *protocoltypes.Version, versionValidator updaters.VersionValidationInf)
	RegisterConsumerSessionManagerForPairingUpdates(ctx context.Context, consumerSessionManager *lavasession.ConsumerSessionManager, staticProvidersList []*lavasession.RPCProviderEndpoint)
	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

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

MockConsumerStateTrackerInf is a mock of ConsumerStateTrackerInf interface.

func NewMockConsumerStateTrackerInf

func NewMockConsumerStateTrackerInf(ctrl *gomock.Controller) *MockConsumerStateTrackerInf

NewMockConsumerStateTrackerInf creates a new mock instance.

func (*MockConsumerStateTrackerInf) EXPECT

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

func (*MockConsumerStateTrackerInf) GetConsumerPolicy

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

GetConsumerPolicy mocks base method.

func (*MockConsumerStateTrackerInf) GetLatestVirtualEpoch

func (m *MockConsumerStateTrackerInf) GetLatestVirtualEpoch() uint64

GetLatestVirtualEpoch mocks base method.

func (*MockConsumerStateTrackerInf) GetProtocolVersion

GetProtocolVersion mocks base method.

func (*MockConsumerStateTrackerInf) RegisterConsumerSessionManagerForPairingUpdates

func (m *MockConsumerStateTrackerInf) RegisterConsumerSessionManagerForPairingUpdates(ctx context.Context, consumerSessionManager *lavasession.ConsumerSessionManager, staticProviders []*lavasession.RPCProviderEndpoint)

RegisterConsumerSessionManagerForPairingUpdates mocks base method.

func (*MockConsumerStateTrackerInf) RegisterFinalizationConsensusForUpdates

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

RegisterFinalizationConsensusForUpdates mocks base method.

func (*MockConsumerStateTrackerInf) RegisterForDowntimeParamsUpdates

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

RegisterForDowntimeParamsUpdates mocks base method.

func (*MockConsumerStateTrackerInf) RegisterForSpecUpdates

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

RegisterForSpecUpdates mocks base method.

func (*MockConsumerStateTrackerInf) RegisterForVersionUpdates

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

RegisterForVersionUpdates mocks base method.

func (*MockConsumerStateTrackerInf) TxConflictDetection

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

TxConflictDetection mocks base method.

type MockConsumerStateTrackerInfMockRecorder

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

MockConsumerStateTrackerInfMockRecorder is the mock recorder for MockConsumerStateTrackerInf.

func (*MockConsumerStateTrackerInfMockRecorder) GetConsumerPolicy

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

GetConsumerPolicy indicates an expected call of GetConsumerPolicy.

func (*MockConsumerStateTrackerInfMockRecorder) GetLatestVirtualEpoch

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

GetLatestVirtualEpoch indicates an expected call of GetLatestVirtualEpoch.

func (*MockConsumerStateTrackerInfMockRecorder) GetProtocolVersion

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

GetProtocolVersion indicates an expected call of GetProtocolVersion.

func (*MockConsumerStateTrackerInfMockRecorder) RegisterConsumerSessionManagerForPairingUpdates

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

RegisterConsumerSessionManagerForPairingUpdates indicates an expected call of RegisterConsumerSessionManagerForPairingUpdates.

func (*MockConsumerStateTrackerInfMockRecorder) RegisterFinalizationConsensusForUpdates

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

RegisterFinalizationConsensusForUpdates indicates an expected call of RegisterFinalizationConsensusForUpdates.

func (*MockConsumerStateTrackerInfMockRecorder) RegisterForDowntimeParamsUpdates

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

RegisterForDowntimeParamsUpdates indicates an expected call of RegisterForDowntimeParamsUpdates.

func (*MockConsumerStateTrackerInfMockRecorder) RegisterForSpecUpdates

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

RegisterForSpecUpdates indicates an expected call of RegisterForSpecUpdates.

func (*MockConsumerStateTrackerInfMockRecorder) RegisterForVersionUpdates

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

RegisterForVersionUpdates indicates an expected call of RegisterForVersionUpdates.

func (*MockConsumerStateTrackerInfMockRecorder) TxConflictDetection

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

TxConflictDetection indicates an expected call of TxConflictDetection.

type MockRelayerClient

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

MockRelayerClient is a mock of RelayerClient interface.

func NewMockRelayerClient

func NewMockRelayerClient(ctrl *gomock.Controller) *MockRelayerClient

NewMockRelayerClient creates a new mock instance.

func (*MockRelayerClient) EXPECT

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

func (*MockRelayerClient) Probe

Probe mocks base method.

func (*MockRelayerClient) Relay

Relay mocks base method.

func (*MockRelayerClient) RelaySubscribe

RelaySubscribe mocks base method.

type MockRelayerClientMockRecorder

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

MockRelayerClientMockRecorder is the mock recorder for MockRelayerClient.

func (*MockRelayerClientMockRecorder) Probe

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

Probe indicates an expected call of Probe.

func (*MockRelayerClientMockRecorder) Relay

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

Relay indicates an expected call of Relay.

func (*MockRelayerClientMockRecorder) RelaySubscribe

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

RelaySubscribe indicates an expected call of RelaySubscribe.

type MockRelayerServer

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

MockRelayerServer is a mock of RelayerServer interface.

func NewMockRelayerServer

func NewMockRelayerServer(ctrl *gomock.Controller) *MockRelayerServer

NewMockRelayerServer creates a new mock instance.

func (*MockRelayerServer) EXPECT

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

func (*MockRelayerServer) Probe

Probe mocks base method.

func (*MockRelayerServer) Relay

Relay mocks base method.

func (*MockRelayerServer) RelaySubscribe

RelaySubscribe mocks base method.

type MockRelayerServerMockRecorder

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

MockRelayerServerMockRecorder is the mock recorder for MockRelayerServer.

func (*MockRelayerServerMockRecorder) Probe

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

Probe indicates an expected call of Probe.

func (*MockRelayerServerMockRecorder) Relay

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

Relay indicates an expected call of Relay.

func (*MockRelayerServerMockRecorder) RelaySubscribe

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

RelaySubscribe indicates an expected call of RelaySubscribe.

type MockRelayer_RelaySubscribeClient

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

MockRelayer_RelaySubscribeClient is a mock of Relayer_RelaySubscribeClient interface.

func NewMockRelayer_RelaySubscribeClient

func NewMockRelayer_RelaySubscribeClient(ctrl *gomock.Controller) *MockRelayer_RelaySubscribeClient

NewMockRelayer_RelaySubscribeClient creates a new mock instance.

func (*MockRelayer_RelaySubscribeClient) CloseSend

func (m *MockRelayer_RelaySubscribeClient) CloseSend() error

CloseSend mocks base method.

func (*MockRelayer_RelaySubscribeClient) Context

Context mocks base method.

func (*MockRelayer_RelaySubscribeClient) EXPECT

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

func (*MockRelayer_RelaySubscribeClient) Header

Header mocks base method.

func (*MockRelayer_RelaySubscribeClient) Recv

Recv mocks base method.

func (*MockRelayer_RelaySubscribeClient) RecvMsg

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

RecvMsg mocks base method.

func (*MockRelayer_RelaySubscribeClient) SendMsg

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

SendMsg mocks base method.

func (*MockRelayer_RelaySubscribeClient) Trailer

Trailer mocks base method.

type MockRelayer_RelaySubscribeClientMockRecorder

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

MockRelayer_RelaySubscribeClientMockRecorder is the mock recorder for MockRelayer_RelaySubscribeClient.

func (*MockRelayer_RelaySubscribeClientMockRecorder) CloseSend

CloseSend indicates an expected call of CloseSend.

func (*MockRelayer_RelaySubscribeClientMockRecorder) Context

Context indicates an expected call of Context.

func (*MockRelayer_RelaySubscribeClientMockRecorder) Header

Header indicates an expected call of Header.

func (*MockRelayer_RelaySubscribeClientMockRecorder) Recv

Recv indicates an expected call of Recv.

func (*MockRelayer_RelaySubscribeClientMockRecorder) RecvMsg

RecvMsg indicates an expected call of RecvMsg.

func (*MockRelayer_RelaySubscribeClientMockRecorder) SendMsg

SendMsg indicates an expected call of SendMsg.

func (*MockRelayer_RelaySubscribeClientMockRecorder) Trailer

Trailer indicates an expected call of Trailer.

type MockRelayer_RelaySubscribeServer

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

MockRelayer_RelaySubscribeServer is a mock of Relayer_RelaySubscribeServer interface.

func NewMockRelayer_RelaySubscribeServer

func NewMockRelayer_RelaySubscribeServer(ctrl *gomock.Controller) *MockRelayer_RelaySubscribeServer

NewMockRelayer_RelaySubscribeServer creates a new mock instance.

func (*MockRelayer_RelaySubscribeServer) Context

Context mocks base method.

func (*MockRelayer_RelaySubscribeServer) EXPECT

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

func (*MockRelayer_RelaySubscribeServer) RecvMsg

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

RecvMsg mocks base method.

func (*MockRelayer_RelaySubscribeServer) Send

Send mocks base method.

func (*MockRelayer_RelaySubscribeServer) SendHeader

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

SendHeader mocks base method.

func (*MockRelayer_RelaySubscribeServer) SendMsg

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

SendMsg mocks base method.

func (*MockRelayer_RelaySubscribeServer) SetHeader

SetHeader mocks base method.

func (*MockRelayer_RelaySubscribeServer) SetTrailer

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

SetTrailer mocks base method.

type MockRelayer_RelaySubscribeServerMockRecorder

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

MockRelayer_RelaySubscribeServerMockRecorder is the mock recorder for MockRelayer_RelaySubscribeServer.

func (*MockRelayer_RelaySubscribeServerMockRecorder) Context

Context indicates an expected call of Context.

func (*MockRelayer_RelaySubscribeServerMockRecorder) RecvMsg

RecvMsg indicates an expected call of RecvMsg.

func (*MockRelayer_RelaySubscribeServerMockRecorder) Send

Send indicates an expected call of Send.

func (*MockRelayer_RelaySubscribeServerMockRecorder) SendHeader

SendHeader indicates an expected call of SendHeader.

func (*MockRelayer_RelaySubscribeServerMockRecorder) SendMsg

SendMsg indicates an expected call of SendMsg.

func (*MockRelayer_RelaySubscribeServerMockRecorder) SetHeader

SetHeader indicates an expected call of SetHeader.

func (*MockRelayer_RelaySubscribeServerMockRecorder) SetTrailer

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

func (rpccs *RPCConsumerServer) CancelSubscriptionContext(subscriptionKey string)

func (*RPCConsumerServer) CreateDappKey

func (rpccs *RPCConsumerServer) CreateDappKey(userData common.UserData) string

func (*RPCConsumerServer) GetChainIdAndApiInterface

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

func (*RPCConsumerServer) GetExtensionParser added in v3.1.6

func (rpccs *RPCConsumerServer) GetExtensionParser() *extensionslib.ExtensionParser

func (*RPCConsumerServer) GetListeningAddress

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

func (rpccs *RPCConsumerServer) ParseRelay(
	ctx context.Context,
	url string,
	req string,
	connectionType string,
	dappID string,
	consumerIp string,
	analytics *metrics.RelayMetrics,
	metadata []pairingtypes.Metadata,
) (protocolMessage chainlib.ProtocolMessage, err error)

func (*RPCConsumerServer) ProcessRelaySend

func (rpccs *RPCConsumerServer) ProcessRelaySend(ctx context.Context, protocolMessage chainlib.ProtocolMessage, analytics *metrics.RelayMetrics) (*RelayProcessor, error)

func (*RPCConsumerServer) SendParsedRelay

func (rpccs *RPCConsumerServer) SendParsedRelay(
	ctx context.Context,
	analytics *metrics.RelayMetrics,
	protocolMessage chainlib.ProtocolMessage,
) (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

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 {
	ResultsManager
	RelayStateMachine
	// contains filtered or unexported fields
}

func NewRelayProcessor

func NewRelayProcessor(
	ctx context.Context,
	requiredSuccesses int,
	consumerConsistency *ConsumerConsistency,
	metricsInf MetricsInterface,
	chainIdAndApiInterfaceGetter chainIdAndApiInterfaceGetter,
	relayRetriesManager *lavaprotocol.RelayRetriesManager,
	relayStateMachine RelayStateMachine,
) *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) 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) 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) 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 RelayStateMachine added in v3.1.5

type RelayStateMachine interface {
	GetProtocolMessage() chainlib.ProtocolMessage
	ShouldRetry(numberOfRetriesLaunched int) bool
	GetDebugState() bool
	GetRelayTaskChannel() chan RelayStateSendInstructions
	UpdateBatch(err error)
	GetSelection() Selection
	GetUsedProviders() *lavasession.UsedProviders
	SetRelayProcessor(relayProcessor *RelayProcessor)
}

func NewRelayStateMachine added in v3.1.5

func NewRelayStateMachine(
	ctx context.Context,
	usedProviders *lavasession.UsedProviders,
	relaySender ConsumerRelaySender,
	protocolMessage chainlib.ProtocolMessage,
	analytics *metrics.RelayMetrics,
	debugRelays bool,
	tickerMetricSetter tickerMetricSetterInf,
) RelayStateMachine

type RelayStateSendInstructions added in v3.1.5

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

func (*RelayStateSendInstructions) IsDone added in v3.1.5

func (rssi *RelayStateSendInstructions) IsDone() bool

type ResultsManager

type ResultsManager interface {
	String() string
	NodeResults() []common.RelayResult
	RequiredResults(requiredSuccesses int, selection Selection) bool
	ProtocolErrors() uint64
	HasResults() bool
	GetResults() (success int, nodeErrors int, protocolErrors int)
	GetResultsData() (successResults []common.RelayResult, nodeErrors []common.RelayResult, protocolErrors []RelayError)
	SetResponse(response *relayResponse, protocolMessage chainlib.ProtocolMessage) (nodeError error)
	GetBestNodeErrorMessageForUser() RelayError
	GetBestProtocolErrorMessageForUser() RelayError
	// contains filtered or unexported methods
}

func NewResultsManager

func NewResultsManager(guid uint64) ResultsManager

type ResultsManagerInst

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

func (*ResultsManagerInst) GetBestNodeErrorMessageForUser

func (rp *ResultsManagerInst) GetBestNodeErrorMessageForUser() RelayError

func (*ResultsManagerInst) GetBestProtocolErrorMessageForUser

func (rp *ResultsManagerInst) GetBestProtocolErrorMessageForUser() RelayError

func (*ResultsManagerInst) GetResults

func (rm *ResultsManagerInst) GetResults() (success int, nodeErrors int, protocolErrors int)

func (*ResultsManagerInst) GetResultsData

func (rp *ResultsManagerInst) GetResultsData() (successResults []common.RelayResult, nodeErrors []common.RelayResult, protocolErrors []RelayError)

func (*ResultsManagerInst) HasResults

func (rp *ResultsManagerInst) HasResults() bool

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

func (*ResultsManagerInst) NodeResults

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

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

func (*ResultsManagerInst) ProtocolErrors

func (rp *ResultsManagerInst) ProtocolErrors() uint64

func (*ResultsManagerInst) RequiredResults

func (rp *ResultsManagerInst) RequiredResults(requiredSuccesses int, selection Selection) bool

func (*ResultsManagerInst) SetResponse

func (rp *ResultsManagerInst) SetResponse(response *relayResponse, protocolMessage chainlib.ProtocolMessage) (nodeError error)

func (*ResultsManagerInst) String

func (rm *ResultsManagerInst) String() string

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
)

selection Enum, do not add other const

Jump to

Keyboard shortcuts

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