rpcconsumer

package
v0.34.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 47 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

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 (
	DefaultRPCConsumerFileName = "rpcconsumer.yml"
	DebugRelaysFlagName        = "debug-relays"
	DebugProbesFlagName        = "debug-probes"
)
View Source
const (
	MaxRelayRetries = 6
)

Variables

View Source
var (
	Yaml_config_properties         = []string{"network-address", "chain-id", "api-interface"}
	DebugRelaysFlag                = false
	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 {
	MetricsListenAddress string
	RelayServerAddress   string
}

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)

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, *lavaprotocol.FinalizationConsensus)
	RegisterForDowntimeParamsUpdates(ctx context.Context, downtimeParamsUpdatable updaters.DowntimeParamsUpdatable) error
	TxConflictDetection(ctx context.Context, finalizationConflict *conflicttypes.FinalizationConflict, responseConflict *conflicttypes.ResponseConflict, sameProviderConflict *conflicttypes.FinalizationConflict, 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, sameProviderConflict *conflicttypes.FinalizationConflict, conflictHandler common.ConflictHandlerInterface) error
	GetConsumerPolicy(ctx context.Context, consumerAddress, chainID string) (*plantypes.Policy, error)
	GetLatestVirtualEpoch() uint64
}

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

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

func (*RPCConsumerServer) GetInitialUnwantedProviders added in v0.27.2

func (rpccs *RPCConsumerServer) GetInitialUnwantedProviders(directiveHeaders map[string]string) map[string]struct{}

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) 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 *lavaprotocol.FinalizationConsensus,
	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,
) (err error)

type RelayError

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

type RelayErrors

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

func (*RelayErrors) GetBestErrorMessageForUser

func (r *RelayErrors) GetBestErrorMessageForUser() utils.Attribute

Jump to

Keyboard shortcuts

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