Skip to content

Commit

Permalink
temp fix for invalid qos reports
Browse files Browse the repository at this point in the history
  • Loading branch information
oren-lava committed Jan 19, 2025
1 parent b303d87 commit 349311a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions protocol/lavaprotocol/request_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ func ConstructRelaySession(lavaChainID string, relayRequestData *pairingtypes.Re
copiedQOS := copyQoSServiceReport(singleConsumerSession.QoSInfo.LastQoSReport)
copiedExcellenceQOS := copyQoSServiceReport(singleConsumerSession.QoSInfo.LastExcellenceQoSReportRaw) // copy raw report for the node

// validate and fix QoS excellence report before sending it to the node
copiedExcellenceQOS.ValidateAndFixQoSExcellence()

return &pairingtypes.RelaySession{
SpecId: chainID,
ContentHash: sigs.HashMsg(relayRequestData.GetContentHashData()),
Expand Down
20 changes: 20 additions & 0 deletions x/pairing/types/QualityOfServiceReport.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,23 @@ func (qos QualityOfServiceReport) ComputeQosExcellenceForReputation(syncFactor m
}
return latency.Add(sync).Add(availability), nil
}

// ValidateAndFixQoSExcellence is a temporary function to validate the QoS excellence report
// TODO: remove after the optimizer refactor is merged
func (qos *QualityOfServiceReport) ValidateAndFixQoSExcellence() error {
if qos == nil {
return fmt.Errorf("QoS excellence report is nil")
}

if qos.Availability.LT(sdk.ZeroDec()) {
qos.Availability = sdk.ZeroDec()
}
if qos.Latency.LT(sdk.ZeroDec()) {
qos.Latency = sdk.ZeroDec()
}
if qos.Sync.LT(sdk.ZeroDec()) {
qos.Sync = sdk.ZeroDec()
}

return nil
}

0 comments on commit 349311a

Please sign in to comment.