mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00:00
enable cryptorand analyzer in slasher (#7417)
This commit is contained in:
parent
b589ddd774
commit
e36e9250f1
@ -86,6 +86,7 @@
|
||||
"only_files": {
|
||||
"beacon-chain/.*": "",
|
||||
"shared/.*": "",
|
||||
"slasher/.*": "",
|
||||
"validator/.*": ""
|
||||
},
|
||||
"exclude_files": {
|
||||
|
@ -8,6 +8,7 @@ go_library(
|
||||
importpath = "github.com/prysmaticlabs/prysm/slasher/db/testing",
|
||||
visibility = ["//slasher:__subpackages__"],
|
||||
deps = [
|
||||
"//shared/rand:go_default_library",
|
||||
"//shared/testutil:go_default_library",
|
||||
"//slasher/db:go_default_library",
|
||||
"//slasher/db/kv:go_default_library",
|
||||
|
@ -3,13 +3,12 @@
|
||||
package testing
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"os"
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/shared/rand"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
slasherDB "github.com/prysmaticlabs/prysm/slasher/db"
|
||||
"github.com/prysmaticlabs/prysm/slasher/db/kv"
|
||||
@ -17,10 +16,7 @@ import (
|
||||
|
||||
// SetupSlasherDB instantiates and returns a SlasherDB instance.
|
||||
func SetupSlasherDB(t testing.TB, spanCacheEnabled bool) *kv.Store {
|
||||
randPath, err := rand.Int(rand.Reader, big.NewInt(1000000))
|
||||
if err != nil {
|
||||
t.Fatalf("Could not generate random file path: %v", err)
|
||||
}
|
||||
randPath := rand.NewDeterministicGenerator().Int()
|
||||
p := path.Join(testutil.TempDir(), fmt.Sprintf("/%d", randPath))
|
||||
if err := os.RemoveAll(p); err != nil {
|
||||
t.Fatalf("Failed to remove directory: %v", err)
|
||||
|
@ -7,6 +7,7 @@ go_library(
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//shared/params:go_default_library",
|
||||
"//shared/rand:go_default_library",
|
||||
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",
|
||||
],
|
||||
)
|
||||
|
@ -3,10 +3,9 @@
|
||||
package testing
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/rand"
|
||||
)
|
||||
|
||||
// SignedBlockHeader given slot, proposer index this function generates signed block header.
|
||||
@ -43,7 +42,8 @@ func BlockHeader(slot uint64, proposerIdx uint64) (*ethpb.BeaconBlockHeader, err
|
||||
|
||||
func genRandomByteArray(length int) ([]byte, error) {
|
||||
blk := make([]byte, length)
|
||||
_, err := rand.Read(blk)
|
||||
randGen := rand.NewDeterministicGenerator()
|
||||
_, err := randGen.Read(blk)
|
||||
return blk, err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user