Skip to content

Commit

Permalink
add tier chances to report
Browse files Browse the repository at this point in the history
  • Loading branch information
oren-lava committed Dec 1, 2024
1 parent 3e7dd86 commit 17166c6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
26 changes: 14 additions & 12 deletions protocol/metrics/consumer_optimizer_qos_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,23 @@ type OptimizerQoSReport struct {
LatencyScore float64
GenericScore float64
EntryIndex int
TierChances map[int]float64
}

type optimizerQoSReportToSend struct {
Timestamp time.Time `json:"timestamp"`
SyncScore float64 `json:"sync_score"`
AvailabilityScore float64 `json:"availability_score"`
LatencyScore float64 `json:"latency_score"`
GenericScore float64 `json:"generic_score"`
ProviderAddress string `json:"provider"`
ConsumerOrigin string `json:"consumer"`
ChainId string `json:"chain_id"`
NodeErrorRate float64 `json:"node_error_rate"`
Epoch uint64 `json:"epoch"`
ProviderStake int64 `json:"provider_stake"`
EntryIndex int `json:"entry_index"`
Timestamp time.Time `json:"timestamp"`
SyncScore float64 `json:"sync_score"`
AvailabilityScore float64 `json:"availability_score"`
LatencyScore float64 `json:"latency_score"`
GenericScore float64 `json:"generic_score"`
ProviderAddress string `json:"provider"`
ConsumerOrigin string `json:"consumer"`
ChainId string `json:"chain_id"`
NodeErrorRate float64 `json:"node_error_rate"`
Epoch uint64 `json:"epoch"`
ProviderStake int64 `json:"provider_stake"`
EntryIndex int `json:"entry_index"`
TierChances map[int]float64 `json:"tier_chances"`
}

func (oqosr optimizerQoSReportToSend) String() string {
Expand Down
2 changes: 2 additions & 0 deletions protocol/provideroptimizer/provider_optimizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,11 @@ func (po *ProviderOptimizer) CalculateQoSScoresForMetrics(allAddresses []string,
reports := []*metrics.OptimizerQoSReport{}

rawScores := selectionTier.GetRawScores()
tierChances := selectionTier.ShiftTierChance(po.OptimizerNumTiers, map[int]float64{0: ATierChance})
for idx, entry := range rawScores {
qosReport := providersScores[entry.Address]
qosReport.EntryIndex = idx
qosReport.TierChances = tierChances
reports = append(reports, qosReport)
}

Expand Down
2 changes: 2 additions & 0 deletions protocol/provideroptimizer/provider_optimizer_refactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,12 @@ func (po *ProviderOptimizer_Refactor) CalculateQoSScoresForMetrics(allAddresses
selectionTier, _, providersScores := po.CalculateSelectionTiers_Refactor(allAddresses, ignoredProviders, cu, requestedBlock)
reports := []*metrics.OptimizerQoSReport{}

tierChances := selectionTier.ShiftTierChance(po.OptimizerNumTiers, map[int]float64{0: ATierChance_Refactor})
rawScores := selectionTier.GetRawScores()
for idx, entry := range rawScores {
qosReport := providersScores[entry.Address]
qosReport.EntryIndex = idx
qosReport.TierChances = tierChances
reports = append(reports, qosReport)
}

Expand Down

0 comments on commit 17166c6

Please sign in to comment.