-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed GetValidator caching to fix concurrency error (#8546)
* Removed GetValidator caching to fix concurrency error * Fixed linting and added CHANGELOG entry * Moved benchmark test into its own file * Moved CHANGELOG entry to bug fix * Update CHANGELOG.md Co-authored-by: Cory <cjlevinson@gmail.com> Co-authored-by: Amaury <amaury.martiny@protonmail.com> Co-authored-by: Cory <cjlevinson@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
2154815
commit 090411a
Showing
6 changed files
with
37 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package keeper_test | ||
|
||
import "testing" | ||
|
||
func BenchmarkGetValidator(b *testing.B) { | ||
// 900 is the max number we are allowed to use in order to avoid simapp.CreateTestPubKeys | ||
// panic: encoding/hex: odd length hex string | ||
var powersNumber = 900 | ||
|
||
var totalPower int64 = 0 | ||
var powers = make([]int64, powersNumber) | ||
for i := range powers { | ||
powers[i] = int64(i) | ||
totalPower += int64(i) | ||
} | ||
|
||
app, ctx, _, valAddrs, vals := initValidators(b, totalPower, len(powers), powers) | ||
|
||
for _, validator := range vals { | ||
app.StakingKeeper.SetValidator(ctx, validator) | ||
} | ||
|
||
b.ResetTimer() | ||
for n := 0; n < b.N; n++ { | ||
for _, addr := range valAddrs { | ||
_, _ = app.StakingKeeper.GetValidator(ctx, addr) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters