-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Reputation: CNS-1004 - QoS excellence epoch score aggregation #1612
base: CNS-1003-reputation-proto-definitions
Are you sure you want to change the base?
Changes from 16 commits
54a0136
e3f0183
4471779
d1a4117
841e0e8
32a544c
1a599a0
5e56157
2ff09f5
994e762
13deb57
31f5ddd
21e2819
8a34d74
b7c747f
e374c8b
c7e2a57
5ad9aae
ee2cf55
2262838
600464d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,32 @@ func (k Keeper) GetAllReputation(ctx sdk.Context) []types.ReputationGenesis { | |
return entries | ||
} | ||
|
||
// UpdateReputationEpochQosScore updates the epoch QoS score of the provider's reputation using the score from the relay | ||
// payment's QoS excellence report | ||
func (k Keeper) UpdateReputationEpochQosScore(ctx sdk.Context, chainID string, cluster string, provider string, score math.LegacyDec, weight int64, stake sdk.Coin) { | ||
// get current reputation and get parameters for the epoch score update | ||
r, found := k.GetReputation(ctx, chainID, cluster, provider) | ||
truncate := false | ||
if found { | ||
stabilizationPeriod := k.ReputationVarianceStabilizationPeriod(ctx) | ||
if r.ShouldTruncate(stabilizationPeriod, ctx.BlockTime().UTC().Unix()) { | ||
truncate = true | ||
} | ||
} else { | ||
// new reputation score is not truncated and its decay factor is equal to 1 | ||
r = types.NewReputation(ctx) | ||
} | ||
|
||
// calculate the updated QoS epoch score | ||
updatedEpochScore := r.EpochScore.Update(score, truncate, weight) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we make this in place method? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done. see 600464d |
||
|
||
// update the reputation and set | ||
r.EpochScore = updatedEpochScore | ||
r.TimeLastUpdated = ctx.BlockTime().UTC().Unix() | ||
r.Stake = stake | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is the stake needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. from the comment in the proto:
You'll see it in the next parts |
||
k.SetReputation(ctx, chainID, cluster, provider, r) | ||
} | ||
|
||
// GetReputationScore returns the current reputation pairing score | ||
func (k Keeper) GetReputationScore(ctx sdk.Context, chainID string, cluster string, provider string) (val math.LegacyDec, found bool) { | ||
block := uint64(ctx.BlockHeight()) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better in a function for readability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done. see 5ad9aae