statetracker

package
v5.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagTimeout                 = "timeout"
	FlagValue                   = "value"
	FlagEventName               = "event"
	FlagBreak                   = "break"
	FlagHasAttributeName        = "has-attribute"
	FlagShowAttributeName       = "show-attribute"
	FlagReset                   = "reset"
	FlagDisableInteractiveShell = "disable-interactive"
)
View Source
const (
	BlocksToSaveLavaChainTracker   = 1 // we only need the latest block
	TendermintConsensusParamsQuery = "consensus_params"
	MAINNET_SPEC                   = "LAVA"
	TESTNET_SPEC                   = "LAV1"
)
View Source
const (
	DefaultGasPrice      = "0.00002" + commontypes.TokenDenom
	DefaultGasAdjustment = "3.0"
	// same account can continue failing the more providers you have under the same account
	// for example if you have a provider staked at 20 chains you will ask for 20 payments per epoch.
	// therefore currently our best solution is to continue retrying increasing sequence number until successful
	RETRY_INCORRECT_SEQUENCE = 100
)
View Source
const (
	// DefaultAverageBlockTime is the default block time for standalone mode
	// This represents the Lava blockchain (LAV1) average block time, NOT the serviced chains
	// Based on LAV1 blockchain average block time (15 seconds)
	// See: specs/mainnet-1/specs/lava.json - "average_block_time": 15000 (milliseconds)
	// Note: This is used for approximate calculations (e.g., epoch size in blocks)
	DefaultAverageBlockTime = 15 * time.Second
)

Variables

View Source
var (

	// TODO: add a governance param change that indicates what spec id belongs to lava.
	LavaSpecOptions = []string{TESTNET_SPEC, MAINNET_SPEC}
)

Functions

func CreateEventsCobraCommand

func CreateEventsCobraCommand() *cobra.Command

func CreateRelayPaymentCSVCobraCommand

func CreateRelayPaymentCSVCobraCommand() *cobra.Command

func CreateTxCounterCobraCommand

func CreateTxCounterCobraCommand() *cobra.Command

func GetLavaSpecWithRetry

func GetLavaSpecWithRetry(ctx context.Context, specQueryClient spectypes.QueryClient) (*spectypes.QueryGetSpecResponse, error)

func IsLavaNativeSpec

func IsLavaNativeSpec(checked string) bool

func RegisterForSpecUpdatesOrSetStaticSpec

func RegisterForSpecUpdatesOrSetStaticSpec(ctx context.Context, chainParser chainlib.ChainParser, specPath string, rpcEndpoint lavasession.RPCEndpoint, specUpdaterInf SpecUpdaterInf) error

Either register for spec updates or set spec for offline spec, used in both consumer and provider process

func RegisterForSpecUpdatesOrSetStaticSpecWithToken added in v5.5.1

func RegisterForSpecUpdatesOrSetStaticSpecWithToken(ctx context.Context, chainParser chainlib.ChainParser, specPath string, rpcEndpoint lavasession.RPCEndpoint, specUpdaterInf SpecUpdaterInf, githubToken string) error

Either register for spec updates or set spec for offline spec with GitHub token support

Types

type ConsumerEmergencyTrackerInf

type ConsumerEmergencyTrackerInf interface {
	GetLatestVirtualEpoch() uint64
}

type ConsumerStateTracker

type ConsumerStateTracker struct {
	StateQuery *updaters.ConsumerStateQuery
	*StateTracker
	ConsumerEmergencyTrackerInf
}

ConsumerStateTracker CSTis a class for tracking consumer data from the lava blockchain, such as epoch changes. it allows also to query specific data form the blockchain and acts as a single place to send transactions

func NewConsumerStateTracker

func NewConsumerStateTracker(ctx context.Context, txFactory tx.Factory, clientCtx client.Context, chainFetcher chaintracker.ChainFetcher, metrics *metrics.ConsumerMetricsManager) (ret *ConsumerStateTracker, err error)

func (*ConsumerStateTracker) GetConsumerPolicy

func (cst *ConsumerStateTracker) GetConsumerPolicy(ctx context.Context, consumerAddress, chainID string) (*plantypes.Policy, error)

func (*ConsumerStateTracker) GetProtocolVersion

func (cst *ConsumerStateTracker) GetProtocolVersion(ctx context.Context) (*updaters.ProtocolVersionResponse, error)

func (*ConsumerStateTracker) RegisterConsumerSessionManagerForPairingUpdates

func (cst *ConsumerStateTracker) RegisterConsumerSessionManagerForPairingUpdates(ctx context.Context, consumerSessionManager *lavasession.ConsumerSessionManager, staticProvidersList []*lavasession.RPCStaticProviderEndpoint, backupProvidersList []*lavasession.RPCStaticProviderEndpoint)

func (*ConsumerStateTracker) RegisterForDowntimeParamsUpdates

func (cst *ConsumerStateTracker) RegisterForDowntimeParamsUpdates(ctx context.Context, downtimeParamsUpdatable updaters.DowntimeParamsUpdatable) error

func (*ConsumerStateTracker) RegisterForPairingUpdates

func (cst *ConsumerStateTracker) RegisterForPairingUpdates(ctx context.Context, pairingUpdatable updaters.PairingUpdatable, specId string)

func (*ConsumerStateTracker) RegisterForSpecUpdates

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

func (*ConsumerStateTracker) RegisterForVersionUpdates

func (cst *ConsumerStateTracker) RegisterForVersionUpdates(ctx context.Context, version *protocoltypes.Version, versionValidator updaters.VersionValidationInf)

type ConsumerTxSender

type ConsumerTxSender struct {
	*TxSender
}

func NewConsumerTxSender

func NewConsumerTxSender(ctx context.Context, clientCtx client.Context, txFactory tx.Factory) (ret *ConsumerTxSender, err error)

type EmergencyTracker

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

func NewEmergencyTracker

func NewEmergencyTracker(metrics EmergencyTrackerMetrics) (emergencyTracker *EmergencyTracker, emergencyCallback func(latestBlockTime time.Time))

func (*EmergencyTracker) GetDowntimeParams

func (cs *EmergencyTracker) GetDowntimeParams() downtimev1.Params

func (*EmergencyTracker) GetLatestVirtualEpoch

func (cs *EmergencyTracker) GetLatestVirtualEpoch() uint64

func (*EmergencyTracker) GetVirtualEpoch

func (cs *EmergencyTracker) GetVirtualEpoch(epoch uint64) uint64

func (*EmergencyTracker) SetDowntimeParams

func (cs *EmergencyTracker) SetDowntimeParams(params downtimev1.Params)

func (*EmergencyTracker) UpdateEpoch

func (cs *EmergencyTracker) UpdateEpoch(epoch uint64)

type EmergencyTrackerMetrics

type EmergencyTrackerMetrics interface {
	SetVirtualEpoch(virtualEpoch uint64)
}

type IStateTracker added in v5.4.1

type IStateTracker interface {
	LatestBlock() int64
	GetAverageBlockTime() time.Duration
	RegisterForUpdates(ctx context.Context, updater Updater) Updater
	GetEventTracker() *updaters.EventTracker
}

type ProviderRewards

type ProviderRewards map[string]map[string]*providerStats

per chain per provider, accumulated cu

type ProviderStateTracker

type ProviderStateTracker struct {
	StateQuery *updaters.ProviderStateQuery

	IStateTracker
	*EmergencyTracker
	// contains filtered or unexported fields
}

ProviderStateTracker PST is a class for tracking provider data from the lava blockchain, such as epoch changes. it allows also to query specific data form the blockchain and acts as a single place to send transactions

func NewProviderStateTracker

func NewProviderStateTracker(ctx context.Context, txFactory tx.Factory, clientCtx client.Context, chainFetcher chaintracker.ChainFetcher, metrics *metrics.ProviderMetricsManager) (ret *ProviderStateTracker, err error)

func (*ProviderStateTracker) EarliestBlockInMemory

func (pst *ProviderStateTracker) EarliestBlockInMemory(ctx context.Context) (uint64, error)

func (*ProviderStateTracker) GetAverageBlockTime

func (pst *ProviderStateTracker) GetAverageBlockTime() time.Duration

func (*ProviderStateTracker) GetEpochSize

func (pst *ProviderStateTracker) GetEpochSize(ctx context.Context) (uint64, error)

func (*ProviderStateTracker) GetEpochSizeMultipliedByRecommendedEpochNumToCollectPayment

func (pst *ProviderStateTracker) GetEpochSizeMultipliedByRecommendedEpochNumToCollectPayment(ctx context.Context) (uint64, error)

func (*ProviderStateTracker) GetMaxCuForUser

func (pst *ProviderStateTracker) GetMaxCuForUser(ctx context.Context, consumerAddress, chainID string, epoch uint64) (maxCu uint64, err error)

func (*ProviderStateTracker) GetProtocolVersion

func (pst *ProviderStateTracker) GetProtocolVersion(ctx context.Context) (*updaters.ProtocolVersionResponse, error)

func (*ProviderStateTracker) GetRecommendedEpochNumToCollectPayment

func (pst *ProviderStateTracker) GetRecommendedEpochNumToCollectPayment(ctx context.Context) (uint64, error)

func (*ProviderStateTracker) GetStateQuery added in v5.6.0

func (pst *ProviderStateTracker) GetStateQuery() *updaters.StateQuery

GetStateQuery returns the StateQuery for accessing blockchain state

func (*ProviderStateTracker) LatestBlock

func (pst *ProviderStateTracker) LatestBlock() int64

func (*ProviderStateTracker) RegisterForDowntimeParamsUpdates

func (pst *ProviderStateTracker) RegisterForDowntimeParamsUpdates(ctx context.Context, downtimeParamsUpdatable updaters.DowntimeParamsUpdatable) error

func (*ProviderStateTracker) RegisterForEpochUpdates

func (pst *ProviderStateTracker) RegisterForEpochUpdates(ctx context.Context, epochUpdatable updaters.EpochUpdatable)

func (*ProviderStateTracker) RegisterForSpecUpdates

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

func (*ProviderStateTracker) RegisterForSpecVerifications

func (pst *ProviderStateTracker) RegisterForSpecVerifications(ctx context.Context, specVerifier updaters.SpecVerifier, chainId string) error

func (*ProviderStateTracker) RegisterForVersionUpdates

func (pst *ProviderStateTracker) RegisterForVersionUpdates(ctx context.Context, version *protocoltypes.Version, versionValidator updaters.VersionValidationInf)

func (*ProviderStateTracker) RegisterPaymentUpdatableForPayments

func (pst *ProviderStateTracker) RegisterPaymentUpdatableForPayments(ctx context.Context, paymentUpdatable updaters.PaymentUpdatable)

func (*ProviderStateTracker) TxRelayPayment

func (pst *ProviderStateTracker) TxRelayPayment(ctx context.Context, relayRequests []*pairingtypes.RelaySession, description string, latestBlocks []*pairingtypes.LatestBlockReport) error

func (*ProviderStateTracker) VerifyPairing

func (pst *ProviderStateTracker) VerifyPairing(ctx context.Context, consumerAddress, providerAddress string, epoch uint64, chainID string) (valid bool, total int64, projectId string, err error)

type ProviderTxSender

type ProviderTxSender struct {
	*TxSender
	// contains filtered or unexported fields
}

func NewProviderTxSender

func NewProviderTxSender(ctx context.Context, clientCtx client.Context, txFactory tx.Factory) (ret *ProviderTxSender, err error)

func (*ProviderTxSender) TxRelayPayment

func (pts *ProviderTxSender) TxRelayPayment(ctx context.Context, relayRequests []*pairingtypes.RelaySession, description string, latestBlocks []*pairingtypes.LatestBlockReport) error

func (*ProviderTxSender) UpdateEpoch

func (pts *ProviderTxSender) UpdateEpoch(epoch uint64)

type SpecUpdaterInf

type SpecUpdaterInf interface {
	RegisterForSpecUpdates(ctx context.Context, specUpdatable updaters.SpecUpdatable, endpoint lavasession.RPCEndpoint) error
}

type StandaloneStateTracker added in v5.6.0

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

StandaloneStateTracker is a minimal implementation of ProviderStateTrackerInf for standalone mode (--static-providers). It doesn't connect to the Lava blockchain but provides all required interfaces using defaults and time-based epochs.

func NewStandaloneStateTracker added in v5.6.0

func NewStandaloneStateTracker(epochTimer *common.EpochTimer, averageBlockTime time.Duration) *StandaloneStateTracker

NewStandaloneStateTracker creates a new standalone state tracker for static providers averageBlockTime: Block time for the Lava blockchain (LAV1), not serviced chains.

Pass 0 to use DefaultAverageBlockTime (15 seconds)

func (*StandaloneStateTracker) EarliestBlockInMemory added in v5.6.0

func (sst *StandaloneStateTracker) EarliestBlockInMemory(ctx context.Context) (uint64, error)

EarliestBlockInMemory returns the earliest block kept in memory

func (*StandaloneStateTracker) GetAverageBlockTime added in v5.6.0

func (sst *StandaloneStateTracker) GetAverageBlockTime() time.Duration

GetAverageBlockTime returns the Lava blockchain's average block time Note: This is NOT the block time of serviced chains (NEAR, ETH, etc.)

func (*StandaloneStateTracker) GetEpochSize added in v5.6.0

func (sst *StandaloneStateTracker) GetEpochSize(ctx context.Context) (uint64, error)

GetEpochSize returns the epoch size in blocks

func (*StandaloneStateTracker) GetEpochSizeMultipliedByRecommendedEpochNumToCollectPayment added in v5.6.0

func (sst *StandaloneStateTracker) GetEpochSizeMultipliedByRecommendedEpochNumToCollectPayment(ctx context.Context) (uint64, error)

GetEpochSizeMultipliedByRecommendedEpochNumToCollectPayment returns memory size for session management

func (*StandaloneStateTracker) GetMaxCuForUser added in v5.6.0

func (sst *StandaloneStateTracker) GetMaxCuForUser(ctx context.Context, consumerAddress, chainID string, epocu uint64) (maxCu uint64, err error)

GetMaxCuForUser returns max CU for a user (returns unlimited in standalone mode)

func (*StandaloneStateTracker) GetProtocolVersion added in v5.6.0

GetProtocolVersion returns the protocol version

func (*StandaloneStateTracker) GetRecommendedEpochNumToCollectPayment added in v5.6.0

func (sst *StandaloneStateTracker) GetRecommendedEpochNumToCollectPayment(ctx context.Context) (uint64, error)

GetRecommendedEpochNumToCollectPayment returns recommended epochs to collect payment

func (*StandaloneStateTracker) GetVirtualEpoch added in v5.6.0

func (sst *StandaloneStateTracker) GetVirtualEpoch(epoch uint64) uint64

GetVirtualEpoch returns the virtual epoch (same as real epoch in standalone)

func (*StandaloneStateTracker) LatestBlock added in v5.6.0

func (sst *StandaloneStateTracker) LatestBlock() int64

LatestBlock returns the latest block number (returns 0 in standalone mode)

func (*StandaloneStateTracker) RegisterForDowntimeParamsUpdates added in v5.6.0

func (sst *StandaloneStateTracker) RegisterForDowntimeParamsUpdates(ctx context.Context, downtimeParamsUpdatable updaters.DowntimeParamsUpdatable) error

RegisterForDowntimeParamsUpdates registers for downtime params updates (no-op in standalone)

func (*StandaloneStateTracker) RegisterForEpochUpdates added in v5.6.0

func (sst *StandaloneStateTracker) RegisterForEpochUpdates(ctx context.Context, epochUpdatable updaters.EpochUpdatable)

RegisterForEpochUpdates registers for epoch updates using the time-based EpochTimer

func (*StandaloneStateTracker) RegisterForSpecUpdates added in v5.6.0

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

RegisterForSpecUpdates registers for spec updates (no-op in standalone, using static specs)

func (*StandaloneStateTracker) RegisterForSpecVerifications added in v5.6.0

func (sst *StandaloneStateTracker) RegisterForSpecVerifications(ctx context.Context, specVerifier updaters.SpecVerifier, chainId string) error

RegisterForSpecVerifications registers for spec verifications (no-op in standalone)

func (*StandaloneStateTracker) RegisterForUpdates added in v5.6.0

func (sst *StandaloneStateTracker) RegisterForUpdates(ctx context.Context, updater Updater) Updater

RegisterForUpdates registers for general updates (no-op in standalone)

func (*StandaloneStateTracker) RegisterForVersionUpdates added in v5.6.0

func (sst *StandaloneStateTracker) RegisterForVersionUpdates(ctx context.Context, version *protocoltypes.Version, versionValidator updaters.VersionValidationInf)

RegisterForVersionUpdates registers for protocol version updates (no-op in standalone)

func (*StandaloneStateTracker) RegisterPaymentUpdatableForPayments added in v5.6.0

func (sst *StandaloneStateTracker) RegisterPaymentUpdatableForPayments(ctx context.Context, paymentUpdatable updaters.PaymentUpdatable)

RegisterPaymentUpdatableForPayments registers for payment updates (no-op in standalone)

func (*StandaloneStateTracker) TxRelayPayment added in v5.6.0

func (sst *StandaloneStateTracker) TxRelayPayment(ctx context.Context, relayRequests []*pairingtypes.RelaySession, description string, latestBlocks []*pairingtypes.LatestBlockReport) error

TxRelayPayment submits relay payment transaction (not supported in standalone mode)

func (*StandaloneStateTracker) VerifyPairing added in v5.6.0

func (sst *StandaloneStateTracker) VerifyPairing(ctx context.Context, consumerAddress, providerAddress string, epoch uint64, chainID string) (valid bool, total int64, projectId string, err error)

VerifyPairing verifies consumer-provider pairing (always valid in standalone mode)

type StateTracker

type StateTracker struct {
	EventTracker     *updaters.EventTracker
	AverageBlockTime time.Duration
	// contains filtered or unexported fields
}

ConsumerStateTracker CSTis a class for tracking consumer data from the lava blockchain, such as epoch changes. it allows also to query specific data form the blockchain and acts as a single place to send transactions

func NewStateTracker

func NewStateTracker(ctx context.Context, txFactory tx.Factory, stateQuery *updaters.StateQuery, chainFetcher chaintracker.ChainFetcher, blockNotFoundCallback func(latestBlockTime time.Time)) (ret *StateTracker, err error)

func (*StateTracker) GetAverageBlockTime

func (st *StateTracker) GetAverageBlockTime() time.Duration

func (*StateTracker) GetEventTracker

func (st *StateTracker) GetEventTracker() *updaters.EventTracker

For lavavisor access

func (*StateTracker) LatestBlock added in v5.4.1

func (st *StateTracker) LatestBlock() int64

func (*StateTracker) RegisterForUpdates

func (st *StateTracker) RegisterForUpdates(ctx context.Context, updater Updater) Updater

func (*StateTracker) UpdateBlockTime

func (st *StateTracker) UpdateBlockTime(blockTime time.Duration)

type TxSender

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

func NewTxSender

func NewTxSender(ctx context.Context, clientCtx client.Context, txFactory tx.Factory) (ret *TxSender, err error)

func (*TxSender) SendTxAndVerifyCommit

func (ts *TxSender) SendTxAndVerifyCommit(txfactory tx.Factory, msg sdk.Msg) (parsedResult common.TxResultData, err error)

func (*TxSender) SimulateAndBroadCastTxWithRetryOnSeqMismatch

func (ts *TxSender) SimulateAndBroadCastTxWithRetryOnSeqMismatch(ctx context.Context, msg sdk.Msg, checkProfitability bool, feeGranter sdk.AccAddress) error

type Updater

type Updater interface {
	Update(int64)
	Reset(int64)
	UpdaterKey() string
}

Directories

Path Synopsis
Package updaters is a generated GoMock package.
Package updaters is a generated GoMock package.

Jump to

Keyboard shortcuts

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