Skip to content

Commit

Permalink
Linter findings
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandofcampos committed Aug 22, 2024
1 parent 0e94df5 commit bea3b5a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ build-local-edits:

lint:
@echo "--> Running linter"
@go run github.com/golangci/golangci-lint/cmd/golangci-lint@latest run --timeout=10m
@go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.3 run --timeout=10m
2 changes: 1 addition & 1 deletion x/emissions/keeper/actor_utils/util_sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func FindTopNByScoreDesc(ctx sdk.Context, n uint64, scoresByActor map[Actor]Scor

topN := make([]Actor, 0)
topNBool := make(map[string]bool)
for i := 0; i < int(n); i++ {
for i := uint64(0); i < n; i++ {
if queue.Len() == 0 {
break
}
Expand Down
18 changes: 9 additions & 9 deletions x/emissions/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ func (k *Keeper) AppendInference(ctx context.Context, topicId TopicId, nonce typ
}
}
// append inference if not reached out topN
if len(newInferences.Inferences) < int(moduleParams.MaxTopInferersToReward) {
if uint64(len(newInferences.Inferences)) < moduleParams.MaxTopInferersToReward {
newInferences.Inferences = append(newInferences.Inferences, inference)
return k.allInferences.Set(ctx, key, newInferences)
}
Expand Down Expand Up @@ -848,7 +848,7 @@ func (k *Keeper) AppendForecast(ctx context.Context, topicId TopicId, nonce type
newForecasts.Forecasts = append(newForecasts.Forecasts, exForecast)
}
}
if len(newForecasts.Forecasts) < int(moduleParams.MaxTopForecastersToReward) {
if uint64(len(newForecasts.Forecasts)) < moduleParams.MaxTopForecastersToReward {
newForecasts.Forecasts = append(newForecasts.Forecasts, forecast)
return k.allForecasts.Set(ctx, key, newForecasts)
}
Expand Down Expand Up @@ -938,7 +938,7 @@ func (k *Keeper) AppendReputerLoss(ctx context.Context, topicId TopicId, block B
newReputerLossBundles.ReputerValueBundles = append(newReputerLossBundles.ReputerValueBundles, exReputation)
}
}
if len(newReputerLossBundles.ReputerValueBundles) < int(moduleParams.MaxTopReputersToReward) {
if uint64(len(newReputerLossBundles.ReputerValueBundles)) < moduleParams.MaxTopReputersToReward {
newReputerLossBundles.ReputerValueBundles = append(newReputerLossBundles.ReputerValueBundles, reputerLoss)
return k.allLossBundles.Set(ctx, key, newReputerLossBundles)
}
Expand Down Expand Up @@ -2286,7 +2286,7 @@ func (k *Keeper) GetInferenceScoresUntilBlock(ctx context.Context, topicId Topic
if err != nil {
return nil, err
}
maxNumTimeSteps := int(moduleParams.MaxSamplesToScaleScores)
maxNumTimeSteps := moduleParams.MaxSamplesToScaleScores

scores := make([]*types.Score, 0, maxNumTimeSteps)

Expand All @@ -2297,13 +2297,13 @@ func (k *Keeper) GetInferenceScoresUntilBlock(ctx context.Context, topicId Topic
}

for _, score := range existingScores.Value.Scores {
if len(scores) < maxNumTimeSteps {
if uint64(len(scores)) < maxNumTimeSteps {
scores = append(scores, score)
} else {
break
}
}
if len(scores) >= maxNumTimeSteps {
if uint64(len(scores)) >= maxNumTimeSteps {
break
}
iter.Next()
Expand Down Expand Up @@ -2363,7 +2363,7 @@ func (k *Keeper) GetForecastScoresUntilBlock(ctx context.Context, topicId TopicI
if err != nil {
return nil, err
}
maxNumTimeSteps := int(moduleParams.MaxSamplesToScaleScores)
maxNumTimeSteps := moduleParams.MaxSamplesToScaleScores

scores := make([]*types.Score, 0, maxNumTimeSteps)

Expand All @@ -2374,13 +2374,13 @@ func (k *Keeper) GetForecastScoresUntilBlock(ctx context.Context, topicId TopicI
}

for _, score := range existingScores.Value.Scores {
if len(scores) < maxNumTimeSteps {
if uint64(len(scores)) < maxNumTimeSteps {
scores = append(scores, score)
} else {
break
}
}
if len(scores) >= maxNumTimeSteps {
if uint64(len(scores)) >= maxNumTimeSteps {
break
}
iter.Next()
Expand Down
2 changes: 1 addition & 1 deletion x/emissions/keeper/msgserver/msg_server_topics.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (ms msgServer) CreateNewTopic(ctx context.Context, msg *types.MsgCreateNewT
if msg.EpochLength < params.MinEpochLength {
return nil, types.ErrTopicCadenceBelowMinimum
}
if msg.GroundTruthLag > int64(params.MaxUnfulfilledReputerRequests)*msg.EpochLength {
if uint64(msg.GroundTruthLag) > params.MaxUnfulfilledReputerRequests*uint64(msg.EpochLength) {
return nil, types.ErrGroundTruthLagTooBig
}

Expand Down
2 changes: 1 addition & 1 deletion x/emissions/module/rewards/topic_rewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func PickChurnableActiveTopics(
MaxUnfulfilledReputerRequests = moduleParams.MaxUnfulfilledReputerRequests
}
// Adding one to cover for one extra epochLength
reputerPruningBlock := block - (int64(MaxUnfulfilledReputerRequests+1)*topic.EpochLength + topic.GroundTruthLag)
reputerPruningBlock := block - (int64(MaxUnfulfilledReputerRequests+1)*topic.EpochLength + topic.GroundTruthLag) //nolint:gosec // G115: integer overflow conversion uint64 -> int64 (gosec)
if reputerPruningBlock > 0 {
ctx.Logger().Debug(fmt.Sprintf("Pruning reputer nonces before block: %v for topic: %d on block: %v", reputerPruningBlock, topic.Id, block))
err = k.PruneReputerNonces(ctx, topic.Id, reputerPruningBlock)
Expand Down

0 comments on commit bea3b5a

Please sign in to comment.