Skip to content
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

Make schedling more spread across validators #903

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions x/evm/keeper/msg_assigner.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package keeper
import (
"errors"
"math"
"math/rand"
"sort"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -189,10 +188,9 @@ func pickValidator(ctx sdk.Context, validatorsInfos map[string]ValidatorInfo, we
}
}

// All else equal, grab a random of our high scorers deterministically within this block
detRand := rand.New(rand.NewSource(ctx.BlockHeight())) //nolint:gosec
// All else equal, grab one of our high scorers, but not always the same one
sort.Strings(highScorers)
return highScorers[detRand.Intn(len(highScorers))]
return highScorers[int(ctx.BlockHeight())%len(highScorers)]
}

func (ma MsgAssigner) PickValidatorForMessage(ctx sdk.Context, weights *types.RelayWeights) (string, error) {
Expand Down