Documentation ¶
Index ¶
- Constants
- Variables
- func CalcWeightsByStake(providers map[uint64]*ConsumerSessionsWithProvider) (weights map[string]int64)
- func CalculateAvailabilityScore(qosReport *QoSReport) (downtimePercentageRet, scaledAvailabilityScoreRet sdk.Dec)
- func ConnectGRPCClient(ctx context.Context, address string, allowInsecure bool, skipTLS bool, ...) (*grpc.ClientConn, error)
- func GenerateSelfSignedCertificate() (tls.Certificate, error)
- func GetCaCertificate(serverCertPath, serverKeyPath string) (*tls.Config, error)
- func GetSelfSignedConfig() (*tls.Config, error)
- func GetTlsConfig(networkAddress NetworkAddressData) *tls.Config
- func IsEpochValidForUse(targetEpoch, blockedEpochHeight uint64) bool
- func IsSessionSyncLoss(err error) bool
- func SortByGeolocations(pairingEndpoints []*Endpoint, currentGeo planstypes.Geolocation)
- type ActiveSubscriptionProvidersStorage
- type BadgeSession
- type BlockedProvidersInf
- type ConsumerSessionManager
- func (csm *ConsumerSessionManager) CalculateAddonValidAddresses(addon string, extensions []string) (supportingProviderAddresses []string)
- func (csm *ConsumerSessionManager) GenerateReconnectCallback(consumerSessionsWithProvider *ConsumerSessionsWithProvider) func() error
- func (csm *ConsumerSessionManager) GetAtomicPairingAddressesLength() uint64
- func (csm *ConsumerSessionManager) GetNumberOfValidProviders() int
- func (csm *ConsumerSessionManager) GetReportedProviders(epoch uint64) []*pairingtypes.ReportedProvider
- func (csm *ConsumerSessionManager) GetSessions(ctx context.Context, cuNeededForSession uint64, usedProviders UsedProvidersInf, ...) (consumerSessionMap ConsumerSessionsMap, errRet error)
- func (csm *ConsumerSessionManager) Initialized() bool
- func (csm *ConsumerSessionManager) OnSessionDone(consumerSession *SingleConsumerSession, latestServicedBlock int64, ...) error
- func (csm *ConsumerSessionManager) OnSessionDoneIncreaseCUOnly(consumerSession *SingleConsumerSession, latestServicedBlock int64) error
- func (csm *ConsumerSessionManager) OnSessionFailure(consumerSession *SingleConsumerSession, errorReceived error) error
- func (csm *ConsumerSessionManager) RPCEndpoint() RPCEndpoint
- func (csm *ConsumerSessionManager) RemoveAddonAddresses(addon string, extensions []string)
- func (csm *ConsumerSessionManager) UpdateAllProviders(epoch uint64, pairingList map[uint64]*ConsumerSessionsWithProvider) error
- type ConsumerSessionsMap
- type ConsumerSessionsWithProvider
- func (cswp *ConsumerSessionsWithProvider) ConflictAlreadyReported() bool
- func (cswp *ConsumerSessionsWithProvider) ConnectRawClientWithTimeout(ctx context.Context, addr string) (pairingtypes.RelayerClient, *grpc.ClientConn, error)
- func (cswp *ConsumerSessionsWithProvider) GetConsumerSessionInstanceFromEndpoint(endpointConnection *EndpointConnection, numberOfResets uint64) (singleConsumerSession *SingleConsumerSession, pairingEpoch uint64, err error)
- func (cswp *ConsumerSessionsWithProvider) GetPairingEpoch() uint64
- func (cswp *ConsumerSessionsWithProvider) IsSupportingAddon(addon string) bool
- func (cswp *ConsumerSessionsWithProvider) IsSupportingExtensions(extensions []string) bool
- func (cswp *ConsumerSessionsWithProvider) StoreConflictReported()
- type DataReliabilitySession
- type Endpoint
- type EndpointAndChosenConnection
- type EndpointConnection
- type EndpointInfo
- type EndpointInfoList
- type NetworkAddressData
- type NumberOfActiveSubscriptions
- type ProviderOptimizer
- type ProviderSessionManager
- func (psm *ProviderSessionManager) GetBlockedEpochHeight() uint64
- func (psm *ProviderSessionManager) GetCurrentEpochAtomic() uint64
- func (psm *ProviderSessionManager) GetSession(ctx context.Context, consumerAddress string, ...) (*SingleProviderSession, error)
- func (psm *ProviderSessionManager) IsActiveProject(epoch uint64, projectId string) (providerSessionWithConsumer *ProviderSessionsWithConsumerProject, err error)
- func (psm *ProviderSessionManager) IsValidEpoch(epoch uint64) (valid bool)
- func (psm *ProviderSessionManager) OnSessionDone(singleProviderSession *SingleProviderSession, relayNumber uint64) (err error)
- func (psm *ProviderSessionManager) OnSessionFailure(singleProviderSession *SingleProviderSession, relayNumber uint64) (err error)
- func (psm *ProviderSessionManager) RPCProviderEndpoint() *RPCProviderEndpoint
- func (psm *ProviderSessionManager) RegisterProviderSessionWithConsumer(ctx context.Context, consumerAddress string, ...) (*SingleProviderSession, error)
- func (psm *ProviderSessionManager) ReportConsumer() (address string, epoch uint64, err error)
- func (psm *ProviderSessionManager) UpdateEpoch(epoch uint64)
- func (psm *ProviderSessionManager) UpdateSessionCU(consumerAddress string, epoch, sessionID, newCU uint64) error
- type ProviderSessionsEpochData
- type ProviderSessionsWithConsumerProject
- type QoSReport
- type RPCEndpoint
- type RPCProviderEndpoint
- type RPCSubscription
- type ReportedProviderEntry
- type ReportedProviders
- func (rp *ReportedProviders) AppendReport(report metrics.ReportsRequest)
- func (rp *ReportedProviders) GetReportedProviders() []*pairingtypes.ReportedProvider
- func (rp *ReportedProviders) IsReported(address string) bool
- func (rp *ReportedProviders) ReconnectCandidates() []reconnectCandidate
- func (rp *ReportedProviders) ReconnectProviders()
- func (rp *ReportedProviders) RemoveReport(address string)
- func (rp *ReportedProviders) ReportProvider(providerAddr string, errors uint64, disconnections uint64, ...)
- func (rp *ReportedProviders) Reset()
- type RouterKey
- type SessionInfo
- type SessionWithProvider
- type SessionWithProviderMap
- type SingleConsumerSession
- func (cs *SingleConsumerSession) CalculateExpectedLatency(timeoutGivenToRelay time.Duration) time.Duration
- func (cs *SingleConsumerSession) CalculateQoS(latency, expectedLatency time.Duration, blockHeightDiff int64, ...)
- func (scs *SingleConsumerSession) Free(err error)
- func (scs *SingleConsumerSession) GetProviderUniqueId() string
- func (scs *SingleConsumerSession) SetUsageForSession(cuNeededForSession uint64, ...) error
- func (session *SingleConsumerSession) TryUseSession() (blocked bool, ok bool)
- func (consumerSession *SingleConsumerSession) VerifyLock() error
- func (scs *SingleConsumerSession) VerifyProviderUniqueIdAndStoreIfFirstTime(providerUniqueId string) bool
- type SingleProviderSession
- func (sps *SingleProviderSession) DisbandSession() error
- func (sps *SingleProviderSession) GetOccupyingGuid() uint64
- func (sps *SingleProviderSession) GetPairingEpoch() uint64
- func (sps *SingleProviderSession) IsBadgeSession() bool
- func (sps *SingleProviderSession) IsPayingRelay() bool
- func (sps *SingleProviderSession) PrepareDataReliabilitySessionForUsage(relayRequestTotalCU uint64) error
- func (sps *SingleProviderSession) PrepareSessionForUsage(ctx context.Context, cuFromSpec, relayRequestTotalCU uint64, ...) error
- func (sps *SingleProviderSession) SetPairingEpoch(epoch uint64)
- func (sps *SingleProviderSession) VerifyLock() error
- type UniqueUsedProviders
- type UsedProviders
- func (up *UsedProviders) AddUnwantedAddresses(address string, routerKey RouterKey)
- func (up *UsedProviders) AddUsed(sessions ConsumerSessionsMap, err error)
- func (up *UsedProviders) AllUnwantedAddresses() []string
- func (up *UsedProviders) BatchNumber() int
- func (up *UsedProviders) ClearUnwanted()
- func (up *UsedProviders) CurrentlyUsed() int
- func (up *UsedProviders) CurrentlyUsedAddresses() []string
- func (up *UsedProviders) GetErroredProviders(routerKey RouterKey) map[string]struct{}
- func (up *UsedProviders) GetUnwantedProvidersToSend(routerKey RouterKey) map[string]struct{}
- func (up *UsedProviders) RemoveUsed(provider string, routerKey RouterKey, err error)
- func (up *UsedProviders) SessionsLatestBatch() int
- func (up *UsedProviders) TryLockSelection(ctx context.Context) error
- type UsedProvidersInf
Constants ¶
const ( MaxConsecutiveConnectionAttempts = 5 TimeoutForEstablishingAConnection = 1500 * time.Millisecond // 1.5 seconds MaxSessionsAllowedPerProvider = 1000 // Max number of sessions allowed per provider MaxAllowedBlockListedSessionPerProvider = MaxSessionsAllowedPerProvider / 3 MaximumNumberOfFailuresAllowedPerConsumerSession = 15 RelayNumberIncrement = 1 DataReliabilitySessionId = 0 // data reliability session id is 0. we can change to more sessions later if needed. DataReliabilityRelayNumber = 1 DataReliabilityCuSum = 0 GeolocationFlag = "geolocation" TendermintUnsubscribeAll = "unsubscribe_all" IndexNotFound = -15 MinValidAddressesForBlockingProbing = 2 BACKOFF_TIME_ON_FAILURE = 3 * time.Second BLOCKING_PROBE_SLEEP_TIME = 1000 * time.Millisecond // maximum amount of time to sleep before triggering probe, to scatter probes uniformly across chains BLOCKING_PROBE_TIMEOUT = time.Minute // maximum time to wait for probe to complete before updating pairing )
const ( PercentileToCalculateLatency = 0.9 MinProvidersForSync = 0.6 OptimizerPerturbation = 0.10 LatencyThresholdStatic = 1 * time.Second LatencyThresholdSlope = 1 * time.Millisecond StaleEpochDistance = 3 // relays done 3 epochs back are ready to be rewarded )
const ( BlockedProviderSessionUsedStatus = uint32(1) BlockedProviderSessionUnusedStatus = uint32(0) )
const ( AllowInsecureConnectionToProvidersFlag = "allow-insecure-provider-dialing" AllowGRPCCompressionFlag = "allow-grpc-compression-for-consumer-provider-communication" WeightMultiplierForStaticProviders = 10 )
const MaximumNumberOfSelectionLockAttempts = 500
const (
ReconnectCandidateTime = 30 * time.Second
)
const (
RouterKeySeparator = "|"
)
const (
TRY_LOCK_ATTEMPTS = 30
)
Variables ¶
var ( AllowInsecureConnectionToProviders = false AllowGRPCCompressionForConsumerProviderCommunication = false )
var ( PairingListEmptyError = sdkerrors.New("pairingListEmpty Error", 665, "No pairings available.") // client could not connect to any provider. UnreachableCodeError = sdkerrors.New("UnreachableCode Error", 666, "Should not get here.") AllProviderEndpointsDisabledError = sdkerrors.New("AllProviderEndpointsDisabled Error", 667, "All endpoints are not available.") // a provider is completely unresponsive all endpoints are not available MaximumNumberOfSessionsExceededError = sdkerrors.New("MaximumNumberOfSessionsExceeded Error", 668, "Provider reached maximum number of active sessions.") MaxComputeUnitsExceededError = sdkerrors.New("MaxComputeUnitsExceeded Error", 669, "Consumer is trying to exceed the maximum number of compute units available.") EpochMismatchError = sdkerrors.New("ReportingAnOldEpoch Error", 670, "Tried to Report to an older epoch") AddressIndexWasNotFoundError = sdkerrors.New("AddressIndexWasNotFound Error", 671, "address index was not found in list") LockMisUseDetectedError = sdkerrors.New("LockMisUseDetected Error", 672, "Faulty use of locks detected") SessionIsAlreadyBlockListedError = sdkerrors.New("SessionIsAlreadyBlockListed Error", 673, "Session is already in block list") NegativeComputeUnitsAmountError = sdkerrors.New("NegativeComputeUnitsAmount", 674, "Tried to subtract to negative compute units amount") ReportAndBlockProviderError = sdkerrors.New("ReportAndBlockProvider Error", 675, "Report and block the provider") BlockProviderError = sdkerrors.New("BlockProvider Error", 676, "Block the provider") SessionOutOfSyncError = sdkerrors.New("SessionOutOfSync Error", 677, "Session went out of sync with the provider") // do no change the name, before also fixing the consumerSessionManager.ts file as it relies on the error message MaximumNumberOfBlockListedSessionsError = sdkerrors.New("MaximumNumberOfBlockListedSessions Error", 678, "Provider reached maximum number of block listed sessions.") SendRelayError = sdkerrors.New("SendRelay Error", 679, "Failed To Send Relay") DataReliabilityIndexRequestedIsOriginalProviderError = sdkerrors.New("DataReliabilityIndexRequestedIsOriginalProvider Error", 680, "Data reliability session index belongs to the original provider") DataReliabilityIndexOutOfRangeError = sdkerrors.New("DataReliabilityIndexOutOfRange Error", 681, "Trying to get provider index out of range") DataReliabilityAlreadySentThisEpochError = sdkerrors.New("DataReliabilityAlreadySentThisEpoch Error", 682, "Trying to send data reliability more than once per provider per epoch") FailedToConnectToEndPointForDataReliabilityError = sdkerrors.New("FailedToConnectToEndPointForDataReliability Error", 683, "Failed to connect to a providers endpoints") DataReliabilityEpochMismatchError = sdkerrors.New("DataReliabilityEpochMismatch Error", 684, "Data reliability epoch mismatch original session epoch.") NoDataReliabilitySessionWasCreatedError = sdkerrors.New("NoDataReliabilitySessionWasCreated Error", 685, "No Data reliability session was created") ContextDoneNoNeedToLockSelectionError = sdkerrors.New("ContextDoneNoNeedToLockSelection Error", 687, "Context deadline exceeded while trying to lock selection") BlockEndpointError = sdkerrors.New("BlockEndpoint Error", 688, "Block the endpoint") )
var ( InvalidEpochError = sdkerrors.New("InvalidEpoch Error", 881, "Requested Epoch Is Too Old") NewSessionWithRelayNumError = sdkerrors.New("NewSessionWithRelayNum Error", 882, "Requested Session With Relay Number Is Invalid") ConsumerIsBlockListed = sdkerrors.New("ConsumerIsBlockListed Error", 883, "This Consumer Is Blocked.") ConsumerNotRegisteredYet = sdkerrors.New("ConsumerNotActive Error", 884, "This Consumer Is Not Currently In The Pool.") SessionDoesNotExist = sdkerrors.New("SessionDoesNotExist Error", 885, "This Session Id Does Not Exist.") MaximumCULimitReachedByConsumer = sdkerrors.New("MaximumCULimitReachedByConsumer Error", 886, "Consumer reached maximum cu limit") ProviderConsumerCuMisMatch = sdkerrors.New("ProviderConsumerCuMisMatch Error", 887, "Provider and Consumer disagree on total cu for session") RelayNumberMismatch = sdkerrors.New("RelayNumberMismatch Error", 888, "Provider and Consumer disagree on relay number for session") SubscriptionInitiationError = sdkerrors.New("SubscriptionInitiationError Error", 889, "Provider failed initiating subscription") EpochIsNotRegisteredError = sdkerrors.New("EpochIsNotRegisteredError Error", 890, "Epoch is not registered in provider session manager") ConsumerIsNotRegisteredError = sdkerrors.New("ConsumerIsNotRegisteredError Error", 891, "Consumer is not registered in provider session manager") SubscriptionAlreadyExistsError = sdkerrors.New("SubscriptionAlreadyExists Error", 892, "Subscription already exists in single provider session") DataReliabilitySessionAlreadyUsedError = sdkerrors.New("DataReliabilitySessionAlreadyUsed Error", 893, "Data Reliability Session already used by this consumer in this epoch") DataReliabilityCuSumMisMatchError = sdkerrors.New("DataReliabilityCuSumMisMatch Error", 894, "Data Reliability Cu sum mismatch error") DataReliabilityRelayNumberMisMatchError = sdkerrors.New("DataReliabilityRelayNumberMisMatch Error", 895, "Data Reliability RelayNumber mismatch error") SubscriptionPointerIsNilError = sdkerrors.New("SubscriptionPointerIsNil Error", 896, "Trying to unsubscribe a nil pointer.") CouldNotFindIndexAsConsumerNotYetRegisteredError = sdkerrors.New("CouldNotFindIndexAsConsumerNotYetRegistered Error", 897, "fetching provider index from psm failed") ProviderIndexMisMatchError = sdkerrors.New("ProviderIndexMisMatch Error", 898, "provider index mismatch") SessionIdNotFoundError = sdkerrors.New("SessionIdNotFound Error", 899, "Session Id not found") )
var AvailabilityPercentage sdk.Dec = sdk.NewDecWithPrec(1, 1) // TODO move to params pairing
var (
DebugProbes = false
)
Functions ¶
func CalcWeightsByStake ¶
func CalcWeightsByStake(providers map[uint64]*ConsumerSessionsWithProvider) (weights map[string]int64)
func ConnectGRPCClient ¶
func GenerateSelfSignedCertificate ¶
func GenerateSelfSignedCertificate() (tls.Certificate, error)
func GetCaCertificate ¶
func GetSelfSignedConfig ¶
func GetTlsConfig ¶
func GetTlsConfig(networkAddress NetworkAddressData) *tls.Config
func IsEpochValidForUse ¶
func IsSessionSyncLoss ¶
func SortByGeolocations ¶
func SortByGeolocations(pairingEndpoints []*Endpoint, currentGeo planstypes.Geolocation)
Types ¶
type ActiveSubscriptionProvidersStorage ¶
type ActiveSubscriptionProvidersStorage struct {
// contains filtered or unexported fields
}
func NewActiveSubscriptionProvidersStorage ¶
func NewActiveSubscriptionProvidersStorage() *ActiveSubscriptionProvidersStorage
func (*ActiveSubscriptionProvidersStorage) AddProvider ¶
func (asps *ActiveSubscriptionProvidersStorage) AddProvider(providerAddress string)
func (*ActiveSubscriptionProvidersStorage) IsProviderCurrentlyUsed ¶
func (asps *ActiveSubscriptionProvidersStorage) IsProviderCurrentlyUsed(providerAddress string) bool
func (*ActiveSubscriptionProvidersStorage) RemoveProvider ¶
func (asps *ActiveSubscriptionProvidersStorage) RemoveProvider(providerAddress string)
type BadgeSession ¶
type BlockedProvidersInf ¶
type BlockedProvidersInf interface {
GetBlockedProviders() []string
}
type ConsumerSessionManager ¶
type ConsumerSessionManager struct {
// contains filtered or unexported fields
}
created with NewConsumerSessionManager
func NewConsumerSessionManager ¶
func NewConsumerSessionManager( rpcEndpoint *RPCEndpoint, providerOptimizer ProviderOptimizer, consumerMetricsManager *metrics.ConsumerMetricsManager, reporter metrics.Reporter, consumerPublicAddress string, activeSubscriptionProvidersStorage *ActiveSubscriptionProvidersStorage, ) *ConsumerSessionManager
func (*ConsumerSessionManager) CalculateAddonValidAddresses ¶
func (csm *ConsumerSessionManager) CalculateAddonValidAddresses(addon string, extensions []string) (supportingProviderAddresses []string)
csm is Rlocked
func (*ConsumerSessionManager) GenerateReconnectCallback ¶
func (csm *ConsumerSessionManager) GenerateReconnectCallback(consumerSessionsWithProvider *ConsumerSessionsWithProvider) func() error
func (*ConsumerSessionManager) GetAtomicPairingAddressesLength ¶
func (csm *ConsumerSessionManager) GetAtomicPairingAddressesLength() uint64
Atomically read csm.pairingAddressesLength for data reliability.
func (*ConsumerSessionManager) GetNumberOfValidProviders ¶
func (csm *ConsumerSessionManager) GetNumberOfValidProviders() int
func (*ConsumerSessionManager) GetReportedProviders ¶
func (csm *ConsumerSessionManager) GetReportedProviders(epoch uint64) []*pairingtypes.ReportedProvider
Get the reported providers currently stored in the session manager.
func (*ConsumerSessionManager) GetSessions ¶
func (csm *ConsumerSessionManager) GetSessions(ctx context.Context, cuNeededForSession uint64, usedProviders UsedProvidersInf, requestedBlock int64, addon string, extensions []*spectypes.Extension, stateful uint32, virtualEpoch uint64) ( consumerSessionMap ConsumerSessionsMap, errRet error, )
GetSessions will return a ConsumerSession, given cu needed for that session. The user can also request specific providers to not be included in the search for a session.
func (*ConsumerSessionManager) Initialized ¶
func (csm *ConsumerSessionManager) Initialized() bool
func (*ConsumerSessionManager) OnSessionDone ¶
func (csm *ConsumerSessionManager) OnSessionDone( consumerSession *SingleConsumerSession, latestServicedBlock int64, specComputeUnits uint64, currentLatency time.Duration, expectedLatency time.Duration, expectedBH int64, numOfProviders int, providersCount uint64, isHangingApi bool, extensions []*spectypes.Extension, ) error
On a successful session this function will update all necessary fields in the consumerSession. and unlock it when it finishes
func (*ConsumerSessionManager) OnSessionDoneIncreaseCUOnly ¶
func (csm *ConsumerSessionManager) OnSessionDoneIncreaseCUOnly(consumerSession *SingleConsumerSession, latestServicedBlock int64) error
On a successful Subscribe relay
func (*ConsumerSessionManager) OnSessionFailure ¶
func (csm *ConsumerSessionManager) OnSessionFailure(consumerSession *SingleConsumerSession, errorReceived error) error
Report session failure, mark it as blocked from future usages, report if timeout happened.
func (*ConsumerSessionManager) RPCEndpoint ¶
func (csm *ConsumerSessionManager) RPCEndpoint() RPCEndpoint
this is being read in multiple locations and but never changes so no need to lock.
func (*ConsumerSessionManager) RemoveAddonAddresses ¶
func (csm *ConsumerSessionManager) RemoveAddonAddresses(addon string, extensions []string)
func (*ConsumerSessionManager) UpdateAllProviders ¶
func (csm *ConsumerSessionManager) UpdateAllProviders(epoch uint64, pairingList map[uint64]*ConsumerSessionsWithProvider) error
type ConsumerSessionsMap ¶
type ConsumerSessionsMap map[string]*SessionInfo
type ConsumerSessionsWithProvider ¶
type ConsumerSessionsWithProvider struct { Lock sync.RWMutex PublicLavaAddress string Endpoints []*Endpoint Sessions map[int64]*SingleConsumerSession MaxComputeUnits uint64 UsedComputeUnits uint64 PairingEpoch uint64 StaticProvider bool // contains filtered or unexported fields }
func (*ConsumerSessionsWithProvider) ConflictAlreadyReported ¶
func (cswp *ConsumerSessionsWithProvider) ConflictAlreadyReported() bool
checking if this provider was reported this epoch already, as we can only report once per epoch
func (*ConsumerSessionsWithProvider) ConnectRawClientWithTimeout ¶
func (cswp *ConsumerSessionsWithProvider) ConnectRawClientWithTimeout(ctx context.Context, addr string) (pairingtypes.RelayerClient, *grpc.ClientConn, error)
func (*ConsumerSessionsWithProvider) GetConsumerSessionInstanceFromEndpoint ¶
func (cswp *ConsumerSessionsWithProvider) GetConsumerSessionInstanceFromEndpoint(endpointConnection *EndpointConnection, numberOfResets uint64) (singleConsumerSession *SingleConsumerSession, pairingEpoch uint64, err error)
func (*ConsumerSessionsWithProvider) GetPairingEpoch ¶
func (cswp *ConsumerSessionsWithProvider) GetPairingEpoch() uint64
func (*ConsumerSessionsWithProvider) IsSupportingAddon ¶
func (cswp *ConsumerSessionsWithProvider) IsSupportingAddon(addon string) bool
func (*ConsumerSessionsWithProvider) IsSupportingExtensions ¶
func (cswp *ConsumerSessionsWithProvider) IsSupportingExtensions(extensions []string) bool
func (*ConsumerSessionsWithProvider) StoreConflictReported ¶
func (cswp *ConsumerSessionsWithProvider) StoreConflictReported()
setting this provider as conflict reported.
type DataReliabilitySession ¶
type DataReliabilitySession struct { SingleConsumerSession *SingleConsumerSession Epoch uint64 ProviderPublicAddress string UniqueIdentifier bool }
type Endpoint ¶
type Endpoint struct { NetworkAddress string // change at the end to NetworkAddress Enabled bool Connections []*EndpointConnection ConnectionRefusals uint64 Addons map[string]struct{} Extensions map[string]struct{} Geolocation planstypes.Geolocation }
type EndpointAndChosenConnection ¶
type EndpointAndChosenConnection struct {
// contains filtered or unexported fields
}
type EndpointConnection ¶
type EndpointConnection struct { Client pairingtypes.RelayerClient // contains filtered or unexported fields }
func (*EndpointConnection) GetLbUniqueId ¶
func (ec *EndpointConnection) GetLbUniqueId() string
type EndpointInfo ¶
type EndpointInfoList ¶
type EndpointInfoList []EndpointInfo
Slice to hold EndpointInfo
func (EndpointInfoList) Len ¶
func (list EndpointInfoList) Len() int
Implement sort.Interface for EndpointInfoList
func (EndpointInfoList) Less ¶
func (list EndpointInfoList) Less(i, j int) bool
func (EndpointInfoList) Swap ¶
func (list EndpointInfoList) Swap(i, j int)
type NetworkAddressData ¶
type NetworkAddressData struct { Address string `yaml:"address,omitempty" json:"address,omitempty" mapstructure:"address,omitempty"` // HOST:PORT KeyPem string `yaml:"key-pem,omitempty" json:"key-pem,omitempty" mapstructure:"key-pem"` CertPem string `yaml:"cert-pem,omitempty" json:"cert-pem,omitempty" mapstructure:"cert-pem"` DisableTLS bool `yaml:"disable-tls,omitempty" json:"disable-tls,omitempty" mapstructure:"disable-tls"` }
type NumberOfActiveSubscriptions ¶
type NumberOfActiveSubscriptions int64
type ProviderOptimizer ¶
type ProviderOptimizer interface { AppendProbeRelayData(providerAddress string, latency time.Duration, success bool) AppendRelayFailure(providerAddress string) AppendRelayData(providerAddress string, latency time.Duration, isHangingApi bool, cu, syncBlock uint64) ChooseProvider(allAddresses []string, ignoredProviders map[string]struct{}, cu uint64, requestedBlock int64) (addresses []string, tier int) GetExcellenceQoSReportForProvider(string) (*pairingtypes.QualityOfServiceReport, *pairingtypes.QualityOfServiceReport) Strategy() provideroptimizer.Strategy UpdateWeights(map[string]int64, uint64) }
type ProviderSessionManager ¶
type ProviderSessionManager struct {
// contains filtered or unexported fields
}
func NewProviderSessionManager ¶
func NewProviderSessionManager(rpcProviderEndpoint *RPCProviderEndpoint, numberOfBlocksKeptInMemory uint64) *ProviderSessionManager
Returning a new provider session manager
func (*ProviderSessionManager) GetBlockedEpochHeight ¶
func (psm *ProviderSessionManager) GetBlockedEpochHeight() uint64
func (*ProviderSessionManager) GetCurrentEpochAtomic ¶
func (psm *ProviderSessionManager) GetCurrentEpochAtomic() uint64
func (*ProviderSessionManager) GetSession ¶
func (psm *ProviderSessionManager) GetSession(ctx context.Context, consumerAddress string, epoch, sessionId, relayNumber uint64, badge *pairingtypes.Badge) (*SingleProviderSession, error)
func (*ProviderSessionManager) IsActiveProject ¶
func (psm *ProviderSessionManager) IsActiveProject(epoch uint64, projectId string) (providerSessionWithConsumer *ProviderSessionsWithConsumerProject, err error)
Check if consumer exists and is not blocked, if all is valid return the ProviderSessionsWithConsumer pointer
func (*ProviderSessionManager) IsValidEpoch ¶
func (psm *ProviderSessionManager) IsValidEpoch(epoch uint64) (valid bool)
func (*ProviderSessionManager) OnSessionDone ¶
func (psm *ProviderSessionManager) OnSessionDone(singleProviderSession *SingleProviderSession, relayNumber uint64) (err error)
OnSessionDone unlocks the session gracefully, this happens when session finished successfully
func (*ProviderSessionManager) OnSessionFailure ¶
func (psm *ProviderSessionManager) OnSessionFailure(singleProviderSession *SingleProviderSession, relayNumber uint64) (err error)
OnSessionDone unlocks the session gracefully, this happens when session finished with an error
func (*ProviderSessionManager) RPCProviderEndpoint ¶
func (psm *ProviderSessionManager) RPCProviderEndpoint() *RPCProviderEndpoint
func (*ProviderSessionManager) RegisterProviderSessionWithConsumer ¶
func (psm *ProviderSessionManager) RegisterProviderSessionWithConsumer(ctx context.Context, consumerAddress string, epoch, sessionId, relayNumber, maxCuForConsumer uint64, pairedProviders int64, projectId string, badge *pairingtypes.Badge) (*SingleProviderSession, error)
func (*ProviderSessionManager) ReportConsumer ¶
func (psm *ProviderSessionManager) ReportConsumer() (address string, epoch uint64, err error)
func (*ProviderSessionManager) UpdateEpoch ¶
func (psm *ProviderSessionManager) UpdateEpoch(epoch uint64)
on a new epoch we are cleaning stale provider data, also we are making sure consumers who are trying to use past data are not capable to
func (*ProviderSessionManager) UpdateSessionCU ¶
func (psm *ProviderSessionManager) UpdateSessionCU(consumerAddress string, epoch, sessionID, newCU uint64) error
Called when the reward server has information on a higher cu proof and usage and this providerSessionsManager needs to sync up on it
type ProviderSessionsWithConsumerProject ¶
type ProviderSessionsWithConsumerProject struct { Sessions map[uint64]*SingleProviderSession Lock sync.RWMutex // contains filtered or unexported fields }
holds all of the data for a consumer (project) for a certain epoch
func NewProviderSessionsWithConsumer ¶
func NewProviderSessionsWithConsumer(projectId string, epochData *ProviderSessionsEpochData, isDataReliability uint32, pairedProviders int64) *ProviderSessionsWithConsumerProject
func (*ProviderSessionsWithConsumerProject) SafeAddMissingComputeUnits ¶
func (pswc *ProviderSessionsWithConsumerProject) SafeAddMissingComputeUnits(currentMissingCU uint64, allowedThreshold float64) (legitimate bool, totalMissingCu uint64)
type QoSReport ¶
type QoSReport struct { LastQoSReport *pairingtypes.QualityOfServiceReport LastExcellenceQoSReport *pairingtypes.QualityOfServiceReport LastExcellenceQoSReportRaw *pairingtypes.QualityOfServiceReport LatencyScoreList []sdk.Dec SyncScoreSum int64 TotalSyncScore int64 TotalRelays uint64 AnsweredRelays uint64 }
type RPCEndpoint ¶
type RPCEndpoint struct { NetworkAddress string `yaml:"network-address,omitempty" json:"network-address,omitempty" mapstructure:"network-address"` // HOST:PORT ChainID string `yaml:"chain-id,omitempty" json:"chain-id,omitempty" mapstructure:"chain-id"` // spec chain identifier ApiInterface string `yaml:"api-interface,omitempty" json:"api-interface,omitempty" mapstructure:"api-interface"` TLSEnabled bool `yaml:"tls-enabled,omitempty" json:"tls-enabled,omitempty" mapstructure:"tls-enabled"` HealthCheckPath string `yaml:"health-check-path,omitempty" json:"health-check-path,omitempty" mapstructure:"health-check-path"` // health check status code 200 path, default is "/" Geolocation uint64 `yaml:"geolocation,omitempty" json:"geolocation,omitempty" mapstructure:"geolocation"` }
func (*RPCEndpoint) Key ¶
func (rpce *RPCEndpoint) Key() string
func (*RPCEndpoint) New ¶
func (rpce *RPCEndpoint) New(address, chainID, apiInterface string, geolocation uint64) *RPCEndpoint
func (*RPCEndpoint) String ¶
func (endpoint *RPCEndpoint) String() (retStr string)
type RPCProviderEndpoint ¶
type RPCProviderEndpoint struct { NetworkAddress NetworkAddressData `yaml:"network-address,omitempty" json:"network-address,omitempty" mapstructure:"network-address,omitempty"` ChainID string `yaml:"chain-id,omitempty" json:"chain-id,omitempty" mapstructure:"chain-id"` // spec chain identifier ApiInterface string `yaml:"api-interface,omitempty" json:"api-interface,omitempty" mapstructure:"api-interface"` Geolocation uint64 `yaml:"geolocation,omitempty" json:"geolocation,omitempty" mapstructure:"geolocation"` NodeUrls []common.NodeUrl `yaml:"node-urls,omitempty" json:"node-urls,omitempty" mapstructure:"node-urls"` }
func (*RPCProviderEndpoint) AddonsString ¶
func (endpoint *RPCProviderEndpoint) AddonsString() string
func (*RPCProviderEndpoint) Key ¶
func (rpcpe *RPCProviderEndpoint) Key() string
func (*RPCProviderEndpoint) String ¶
func (endpoint *RPCProviderEndpoint) String() string
func (*RPCProviderEndpoint) UrlsString ¶
func (endpoint *RPCProviderEndpoint) UrlsString() string
func (*RPCProviderEndpoint) Validate ¶
func (endpoint *RPCProviderEndpoint) Validate() error
type RPCSubscription ¶
type RPCSubscription struct { Id string Sub *rpcclient.ClientSubscription SubscribeRepliesChan chan interface{} }
type ReportedProviderEntry ¶
type ReportedProviders ¶
type ReportedProviders struct {
// contains filtered or unexported fields
}
func NewReportedProviders ¶
func NewReportedProviders(reporter metrics.Reporter, chainId string) *ReportedProviders
func (*ReportedProviders) AppendReport ¶
func (rp *ReportedProviders) AppendReport(report metrics.ReportsRequest)
func (*ReportedProviders) GetReportedProviders ¶
func (rp *ReportedProviders) GetReportedProviders() []*pairingtypes.ReportedProvider
func (*ReportedProviders) IsReported ¶
func (rp *ReportedProviders) IsReported(address string) bool
func (*ReportedProviders) ReconnectCandidates ¶
func (rp *ReportedProviders) ReconnectCandidates() []reconnectCandidate
func (*ReportedProviders) ReconnectProviders ¶
func (rp *ReportedProviders) ReconnectProviders()
func (*ReportedProviders) RemoveReport ¶
func (rp *ReportedProviders) RemoveReport(address string)
will be called after a disconnected provider got a valid connection
func (*ReportedProviders) ReportProvider ¶
func (*ReportedProviders) Reset ¶
func (rp *ReportedProviders) Reset()
type RouterKey ¶
type RouterKey struct {
// contains filtered or unexported fields
}
func GetEmptyRouterKey ¶
func GetEmptyRouterKey() RouterKey
func NewRouterKey ¶
func NewRouterKeyFromExtensions ¶ added in v4.1.0
func (*RouterKey) ApplyInternalPath ¶ added in v4.1.1
func (*RouterKey) ApplyMethodsRoute ¶
func (RouterKey) HasExtension ¶ added in v4.1.1
func (*RouterKey) SetExtensions ¶ added in v4.1.1
type SessionInfo ¶
type SessionInfo struct { Session *SingleConsumerSession StakeSize sdk.Coin QoSSummeryResult sdk.Dec // using ComputeQoS to get the total QOS Epoch uint64 ReportedProviders []*pairingtypes.ReportedProvider }
type SessionWithProvider ¶
type SessionWithProvider struct { SessionsWithProvider *ConsumerSessionsWithProvider CurrentEpoch uint64 }
type SessionWithProviderMap ¶
type SessionWithProviderMap map[string]*SessionWithProvider // key is the provider address
type SingleConsumerSession ¶
type SingleConsumerSession struct { CuSum uint64 LatestRelayCu uint64 // set by GetSessions cuNeededForSession QoSInfo QoSReport SessionId int64 Parent *ConsumerSessionsWithProvider RelayNum uint64 LatestBlock int64 // Each session will holds a pointer to a connection, if the connection is lost, this session will be banned (wont be picked) EndpointConnection *EndpointConnection BlockListed bool // if session lost sync we blacklist it. ConsecutiveErrors []error StaticProvider bool // contains filtered or unexported fields }
func (*SingleConsumerSession) CalculateExpectedLatency ¶
func (cs *SingleConsumerSession) CalculateExpectedLatency(timeoutGivenToRelay time.Duration) time.Duration
returns the expected latency to a threshold.
func (*SingleConsumerSession) CalculateQoS ¶
func (*SingleConsumerSession) Free ¶
func (scs *SingleConsumerSession) Free(err error)
func (*SingleConsumerSession) GetProviderUniqueId ¶
func (scs *SingleConsumerSession) GetProviderUniqueId() string
func (*SingleConsumerSession) SetUsageForSession ¶
func (scs *SingleConsumerSession) SetUsageForSession(cuNeededForSession uint64, qoSExcellenceReport *pairingtypes.QualityOfServiceReport, rawQoSExcellenceReport *pairingtypes.QualityOfServiceReport, usedProviders UsedProvidersInf, routerKey RouterKey) error
func (*SingleConsumerSession) TryUseSession ¶
func (session *SingleConsumerSession) TryUseSession() (blocked bool, ok bool)
func (*SingleConsumerSession) VerifyLock ¶
func (consumerSession *SingleConsumerSession) VerifyLock() error
Verify the consumerSession is locked when getting to this function, if its not locked throw an error
func (*SingleConsumerSession) VerifyProviderUniqueIdAndStoreIfFirstTime ¶
func (scs *SingleConsumerSession) VerifyProviderUniqueIdAndStoreIfFirstTime(providerUniqueId string) bool
type SingleProviderSession ¶
type SingleProviderSession struct { CuSum uint64 LatestRelayCu uint64 SessionID uint64 RelayNum uint64 PairingEpoch uint64 BadgeUserData *ProviderSessionsEpochData // contains filtered or unexported fields }
func (*SingleProviderSession) DisbandSession ¶
func (sps *SingleProviderSession) DisbandSession() error
func (*SingleProviderSession) GetOccupyingGuid ¶
func (sps *SingleProviderSession) GetOccupyingGuid() uint64
func (*SingleProviderSession) GetPairingEpoch ¶
func (sps *SingleProviderSession) GetPairingEpoch() uint64
func (*SingleProviderSession) IsBadgeSession ¶
func (sps *SingleProviderSession) IsBadgeSession() bool
func (*SingleProviderSession) IsPayingRelay ¶
func (sps *SingleProviderSession) IsPayingRelay() bool
to be used only when locked, otherwise can return wrong values is used to determine if the proof is beneficial and needs to be sent to rewardServer
func (*SingleProviderSession) PrepareDataReliabilitySessionForUsage ¶
func (sps *SingleProviderSession) PrepareDataReliabilitySessionForUsage(relayRequestTotalCU uint64) error
In case the user session is a data reliability we just need to verify that the cusum is the amount agreed between the consumer and the provider
func (*SingleProviderSession) PrepareSessionForUsage ¶
func (sps *SingleProviderSession) PrepareSessionForUsage(ctx context.Context, cuFromSpec, relayRequestTotalCU uint64, allowedThreshold float64, virtualEpoch uint64) error
if this errors out the caller needs to unlock the session, this is not implemented inside because code between getting the session and this needs the same behavior
func (*SingleProviderSession) SetPairingEpoch ¶
func (sps *SingleProviderSession) SetPairingEpoch(epoch uint64)
func (*SingleProviderSession) VerifyLock ¶
func (sps *SingleProviderSession) VerifyLock() error
Verify the SingleProviderSession is locked when getting to this function, if its not locked throw an error
type UniqueUsedProviders ¶ added in v4.1.0
type UniqueUsedProviders struct {
// contains filtered or unexported fields
}
unique used providers are specific for an extension router key. meaning each extension router key has a different used providers struct
type UsedProviders ¶
type UsedProviders struct {
// contains filtered or unexported fields
}
func NewUsedProviders ¶
func NewUsedProviders(blockedProviders BlockedProvidersInf) *UsedProviders
func (*UsedProviders) AddUnwantedAddresses ¶
func (up *UsedProviders) AddUnwantedAddresses(address string, routerKey RouterKey)
func (*UsedProviders) AddUsed ¶
func (up *UsedProviders) AddUsed(sessions ConsumerSessionsMap, err error)
func (*UsedProviders) AllUnwantedAddresses ¶ added in v4.1.0
func (up *UsedProviders) AllUnwantedAddresses() []string
func (*UsedProviders) BatchNumber ¶
func (up *UsedProviders) BatchNumber() int
func (*UsedProviders) ClearUnwanted ¶
func (up *UsedProviders) ClearUnwanted()
func (*UsedProviders) CurrentlyUsed ¶
func (up *UsedProviders) CurrentlyUsed() int
func (*UsedProviders) CurrentlyUsedAddresses ¶
func (up *UsedProviders) CurrentlyUsedAddresses() []string
func (*UsedProviders) GetErroredProviders ¶
func (up *UsedProviders) GetErroredProviders(routerKey RouterKey) map[string]struct{}
func (*UsedProviders) GetUnwantedProvidersToSend ¶
func (up *UsedProviders) GetUnwantedProvidersToSend(routerKey RouterKey) map[string]struct{}
func (*UsedProviders) RemoveUsed ¶
func (up *UsedProviders) RemoveUsed(provider string, routerKey RouterKey, err error)
func (*UsedProviders) SessionsLatestBatch ¶
func (up *UsedProviders) SessionsLatestBatch() int
func (*UsedProviders) TryLockSelection ¶
func (up *UsedProviders) TryLockSelection(ctx context.Context) error
type UsedProvidersInf ¶
type UsedProvidersInf interface { RemoveUsed(providerAddress string, routerKey RouterKey, err error) TryLockSelection(context.Context) error AddUsed(ConsumerSessionsMap, error) GetUnwantedProvidersToSend(RouterKey) map[string]struct{} AddUnwantedAddresses(address string, routerKey RouterKey) CurrentlyUsed() int }