sentry

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxConsecutiveConnectionAttempts = 3
	PercentileToCalculateLatency     = 0.9
	MinProvidersForSync              = 0.6
	LatencyThresholdStatic           = 1 * time.Second
	LatencyThresholdSlope            = 1 * time.Millisecond
	StaleEpochDistance               = 3 // relays done 3 epochs back are ready to be rewarded
)
View Source
const (
	GeolocationFlag = "geolocation"
)

Variables

View Source
var AvailabilityPercentage sdk.Dec = sdk.NewDecWithPrec(5, 2) // TODO move to params pairing

Functions

func CheckProfitabilityAndBroadCastTx

func CheckProfitabilityAndBroadCastTx(clientCtx client.Context, txf tx.Factory, msg sdk.Msg) error

func ReplaceRequestedBlock

func ReplaceRequestedBlock(requestedBlock int64, latestBlock int64) int64

func SimulateAndBroadCastTx

func SimulateAndBroadCastTx(clientCtx client.Context, txf tx.Factory, msg sdk.Msg) error

func UpdateRequestedBlock

func UpdateRequestedBlock(request *pairingtypes.RelayRequest, response *pairingtypes.RelayReply)

Types

type DataReliabilityResult

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

type DataReliabilitySession

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

type PaymentRequest

type PaymentRequest struct {
	CU                  uint64
	BlockHeightDeadline int64
	Amount              sdk.Coin
	Client              sdk.AccAddress
	UniqueIdentifier    uint64
}

type ProviderHashesConsensus

type ProviderHashesConsensus struct {
	FinalizedBlocksHashes map[int64]string
	// contains filtered or unexported fields
}

type Sentry

type Sentry struct {
	ClientCtx client.Context

	ChainID              string
	NewTransactionEvents <-chan ctypes.ResultEvent
	NewBlockEvents       <-chan ctypes.ResultEvent

	Acc string // account address (bech32)

	ApiInterface string

	//
	// expected payments storage
	PaymentsMu sync.RWMutex

	EpochSize          uint64
	EpochBlocksOverlap uint64

	VrfSkMu utils.LavaMutex
	VrfSk   vrf.PrivateKey
	// contains filtered or unexported fields
}

func NewSentry

func NewSentry(
	clientCtx client.Context,
	txFactory tx.Factory,
	chainID string,
	isUser bool,
	voteInitiationCb func(ctx context.Context, voteID string, voteDeadline uint64, voteParams *VoteParams),
	newEpochCb func(epochHeight int64),
	apiInterface string,
	vrf_sk vrf.PrivateKey,
	flagSet *pflag.FlagSet,
	serverID uint64,
) *Sentry

func (*Sentry) AddExpectedPayment

func (s *Sentry) AddExpectedPayment(expectedPay PaymentRequest)

expecting caller to lock

func (*Sentry) AppendToReceivedPayments

func (s *Sentry) AppendToReceivedPayments(paymentReq PaymentRequest)

func (*Sentry) CompareRelaysAndReportConflict

func (s *Sentry) CompareRelaysAndReportConflict(reply0 *pairingtypes.RelayReply, request0 *pairingtypes.RelayRequest, reply1 *pairingtypes.RelayReply, request1 *pairingtypes.RelayRequest) (ok bool)

func (*Sentry) DataReliabilityThresholdToSession

func (s *Sentry) DataReliabilityThresholdToSession(vrfs [][]byte, uniqueIdentifiers []bool) (indexes map[int64]bool)

func (*Sentry) ExpectedBlockHeight

func (s *Sentry) ExpectedBlockHeight() (int64, int)

func (*Sentry) FetchChainParams

func (s *Sentry) FetchChainParams(ctx context.Context) error

func (*Sentry) FetchEpochParams

func (s *Sentry) FetchEpochParams(ctx context.Context) error

func (*Sentry) FetchEpochSize

func (s *Sentry) FetchEpochSize(ctx context.Context) error

func (*Sentry) FetchOverlapSize

func (s *Sentry) FetchOverlapSize(ctx context.Context) error

func (*Sentry) FetchProvidersCount

func (s *Sentry) FetchProvidersCount(ctx context.Context) error

func (*Sentry) GetAllSpecNames

func (s *Sentry) GetAllSpecNames(ctx context.Context) (map[string][]spectypes.ApiInterface, error)

func (*Sentry) GetAverageBlockTime

func (s *Sentry) GetAverageBlockTime() int64

func (*Sentry) GetBlockHeight

func (s *Sentry) GetBlockHeight() int64

func (*Sentry) GetCUServiced

func (s *Sentry) GetCUServiced() uint64

func (*Sentry) GetChainID

func (s *Sentry) GetChainID() string

func (*Sentry) GetCurrentEpochHeight

func (s *Sentry) GetCurrentEpochHeight() uint64

func (*Sentry) GetEpochSize

func (s *Sentry) GetEpochSize() uint64

func (*Sentry) GetLatestFinalizedBlock

func (s *Sentry) GetLatestFinalizedBlock(latestBlock int64) int64

func (*Sentry) GetMaxCUForUser

func (s *Sentry) GetMaxCUForUser(ctx context.Context, address string, chainID string) (maxCu uint64, err error)

func (*Sentry) GetOverlapSize

func (s *Sentry) GetOverlapSize() uint64

func (*Sentry) GetPaidCU

func (s *Sentry) GetPaidCU() uint64

func (*Sentry) GetPrevEpochHeight

func (s *Sentry) GetPrevEpochHeight() uint64

func (*Sentry) GetProvidersCount

func (s *Sentry) GetProvidersCount() uint64

func (*Sentry) GetReliabilityThreshold

func (s *Sentry) GetReliabilityThreshold() uint32

func (*Sentry) GetSpecApiByName

func (s *Sentry) GetSpecApiByName(name string) (spectypes.ServiceApi, bool)

func (*Sentry) GetSpecApiByTag

func (s *Sentry) GetSpecApiByTag(tag string) (spectypes.ServiceApi, bool)

func (*Sentry) GetSpecBlockDistanceForFinalizedData

func (s *Sentry) GetSpecBlockDistanceForFinalizedData() uint32

func (*Sentry) GetSpecBlocksInFinalizationProof

func (s *Sentry) GetSpecBlocksInFinalizationProof() uint32

func (*Sentry) GetSpecDataReliabilityEnabled

func (s *Sentry) GetSpecDataReliabilityEnabled() bool

func (*Sentry) GetSpecHash

func (s *Sentry) GetSpecHash() []byte

func (*Sentry) GetSpecName

func (s *Sentry) GetSpecName() string

func (*Sentry) GetVrfPkAndMaxCuForUser

func (s *Sentry) GetVrfPkAndMaxCuForUser(ctx context.Context, address string, chainID string, requestBlock int64) (vrfPk *utils.VrfPubKey, maxCu uint64, err error)

func (*Sentry) IdentifyMissingPayments

func (s *Sentry) IdentifyMissingPayments()

func (*Sentry) Init

func (s *Sentry) Init(ctx context.Context) error

func (*Sentry) IsAuthorizedConsumer

func (s *Sentry) IsAuthorizedConsumer(ctx context.Context, consumer string, blockHeight uint64) (*pairingtypes.QueryVerifyPairingResponse, error)

func (*Sentry) IsAuthorizedPairing

func (s *Sentry) IsAuthorizedPairing(ctx context.Context, consumer string, provider string, block uint64) (bool, error)

func (*Sentry) IsFinalizedBlock

func (s *Sentry) IsFinalizedBlock(requestedBlock int64, latestBlock int64) bool

func (*Sentry) ListenForTXEvents

func (s *Sentry) ListenForTXEvents(ctx context.Context)

func (*Sentry) MatchSpecApiByName

func (s *Sentry) MatchSpecApiByName(name string) (spectypes.ServiceApi, bool)

func (*Sentry) PrintExpectedPayments

func (s *Sentry) PrintExpectedPayments() string

func (*Sentry) RemoveExpectedPayment

func (s *Sentry) RemoveExpectedPayment(paidCUToFInd uint64, expectedClient sdk.AccAddress, blockHeight int64, uniqueID uint64) bool

func (*Sentry) SendRelay

func (*Sentry) SetBlockHeight

func (s *Sentry) SetBlockHeight(blockHeight int64)

func (*Sentry) SetCUServiced

func (s *Sentry) SetCUServiced(cu uint64)

func (*Sentry) SetCurrentEpochHeight

func (s *Sentry) SetCurrentEpochHeight(blockHeight int64)

func (*Sentry) SetPrevEpochHeight

func (s *Sentry) SetPrevEpochHeight(blockHeight uint64)

func (*Sentry) SetupConsumerSessionManager

func (s *Sentry) SetupConsumerSessionManager(ctx context.Context, consumerSessionManager *lavasession.ConsumerSessionManager) error

func (*Sentry) Start

func (s *Sentry) Start(ctx context.Context)

func (*Sentry) UpdateCUServiced

func (s *Sentry) UpdateCUServiced(cu uint64)

func (*Sentry) UpdatePaidCU

func (s *Sentry) UpdatePaidCU(extraPaidCU uint64)

type VoteParams

type VoteParams struct {
	CloseVote      bool
	ChainID        string
	ApiURL         string
	RequestData    []byte
	RequestBlock   uint64
	Voters         []string
	ConnectionType string
}

func (*VoteParams) GetCloseVote

func (vp *VoteParams) GetCloseVote() bool

Jump to

Keyboard shortcuts

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