Skip to content

Commit

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

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"`
TierChances map[int]float64 `json:"tier_chances"`
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 string `json:"tier_chances"`
}

func (oqosr optimizerQoSReportToSend) String() string {
Expand Down Expand Up @@ -148,6 +148,7 @@ func (coqc *ConsumerOptimizerQoSClient) appendOptimizerQoSReport(report *Optimiz
Epoch: epoch,
NodeErrorRate: coqc.calculateNodeErrorRate(chainId, report.ProviderAddress),
ProviderStake: coqc.getProviderChainStake(chainId, report.ProviderAddress, epoch),
TierChances: report.TierChances,
}

coqc.queueSender.appendQueue(optimizerQoSReportToSend)
Expand All @@ -169,6 +170,7 @@ func (coqc *ConsumerOptimizerQoSClient) appendOptimizerQoSReportRefactored(repor
Epoch: epoch,
NodeErrorRate: coqc.calculateNodeErrorRate(chainId, report.ProviderAddress),
ProviderStake: coqc.getProviderChainStake(chainId, report.ProviderAddress, epoch),
TierChances: report.TierChances,
}

coqc.queueSenderRefactored.appendQueue(optimizerQoSReportToSend)
Expand Down
2 changes: 1 addition & 1 deletion protocol/provideroptimizer/provider_optimizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func (po *ProviderOptimizer) CalculateQoSScoresForMetrics(allAddresses []string,
for idx, entry := range rawScores {
qosReport := providersScores[entry.Address]
qosReport.EntryIndex = idx
qosReport.TierChances = tierChances
qosReport.TierChances = PrintTierChances(tierChances)
reports = append(reports, qosReport)
}

Expand Down
10 changes: 9 additions & 1 deletion protocol/provideroptimizer/provider_optimizer_refactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,21 @@ func (po *ProviderOptimizer_Refactor) CalculateQoSScoresForMetrics(allAddresses
for idx, entry := range rawScores {
qosReport := providersScores[entry.Address]
qosReport.EntryIndex = idx
qosReport.TierChances = tierChances
qosReport.TierChances = PrintTierChances(tierChances)
reports = append(reports, qosReport)
}

return reports
}

func PrintTierChances(tierChances map[int]float64) string {
var tierChancesString string
for tier, chance := range tierChances {
tierChancesString += fmt.Sprintf("%d: %f, ", tier, chance)
}
return tierChancesString
}

func (po *ProviderOptimizer_Refactor) CalculateSelectionTiers_Refactor(allAddresses []string, ignoredProviders map[string]struct{}, cu uint64, requestedBlock int64) (SelectionTier, Exploration_Refactor, map[string]*metrics.OptimizerQoSReport) {
explorationCandidate := Exploration_Refactor{address: "", time: time.Now().Add(time.Hour)}
selectionTier := NewSelectionTier()
Expand Down

0 comments on commit 9d33edd

Please sign in to comment.