forked from erigontech/erigon
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleaned up and optimized proposer index retriaval. (erigontech#6799)
- Loading branch information
1 parent
37cc3d7
commit 1c22a4c
Showing
10 changed files
with
95 additions
and
50 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
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,34 @@ | ||
package state_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/ledgerwatch/erigon/cl/clparams" | ||
"github.com/ledgerwatch/erigon/cl/utils" | ||
"github.com/ledgerwatch/erigon/cmd/erigon-cl/core/state" | ||
eth2_shuffle "github.com/protolambda/eth2-shuffle" | ||
) | ||
|
||
func BenchmarkLambdaShuffledIndex(b *testing.B) { | ||
keccakOptimized := utils.OptimizedKeccak256() | ||
eth2ShuffleHash := func(data []byte) []byte { | ||
hashed := keccakOptimized(data) | ||
return hashed[:] | ||
} | ||
seed := [32]byte{2, 35, 6} | ||
for i := 0; i < b.N; i++ { | ||
eth2_shuffle.PermuteIndex(eth2ShuffleHash, uint8(clparams.MainnetBeaconConfig.ShuffleRoundCount), 10, 1000, seed) | ||
} | ||
} | ||
|
||
// Faster by ~40%, the effects of it will be felt mostly on computation of the proposer index. | ||
func BenchmarkErigonShuffledIndex(b *testing.B) { | ||
s := state.GetEmptyBeaconState() | ||
keccakOptimized := utils.OptimizedKeccak256() | ||
|
||
seed := [32]byte{2, 35, 6} | ||
preInputs := s.ComputeShuffledIndexPreInputs(seed) | ||
for i := 0; i < b.N; i++ { | ||
s.ComputeShuffledIndex(10, 1000, seed, preInputs, keccakOptimized) | ||
} | ||
} |
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