mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 21:08:10 -05:00
Fix validator export failing when validator.db is in nested directory (#15351)
* files changed * added changelog file * added tests and formatting changes * fixed bugs * fixed formatting
This commit is contained in:
3
changelog/rose2221_fix-slashing-export-nested-db.md
Normal file
3
changelog/rose2221_fix-slashing-export-nested-db.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fix `slashing-protection-history export` failing when `validator.db` is in a nested folder like `data/direct/`. (#14954)
|
||||||
@@ -58,10 +58,11 @@ func exportSlashingProtectionJSON(cliCtx *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that the database is found under the specified dir or its subdirectories
|
// Ensure that the database is found under the specified dir or its subdirectories
|
||||||
|
var matchPath string
|
||||||
if isDatabaseMinimal {
|
if isDatabaseMinimal {
|
||||||
found, _, err = file.RecursiveDirFind(filesystem.DatabaseDirName, dataDir)
|
found, matchPath, err = file.RecursiveDirFind(filesystem.DatabaseDirName, dataDir)
|
||||||
} else {
|
} else {
|
||||||
found, _, err = file.RecursiveFileFind(kv.ProtectionDbFileName, dataDir)
|
found, matchPath, err = file.RecursiveFileFind(kv.ProtectionDbFileName, dataDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -74,6 +75,12 @@ func exportSlashingProtectionJSON(cliCtx *cli.Context) error {
|
|||||||
databaseFileDir = filesystem.DatabaseDirName
|
databaseFileDir = filesystem.DatabaseDirName
|
||||||
}
|
}
|
||||||
return fmt.Errorf("%s (validator database) was not found at path %s, so nothing to export", databaseFileDir, dataDir)
|
return fmt.Errorf("%s (validator database) was not found at path %s, so nothing to export", databaseFileDir, dataDir)
|
||||||
|
} else {
|
||||||
|
if !isDatabaseMinimal {
|
||||||
|
matchPath = filepath.Dir(matchPath) // strip the file name
|
||||||
|
}
|
||||||
|
dataDir = matchPath
|
||||||
|
log.Infof("Found validator database at path %s", dataDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open the validator database.
|
// Open the validator database.
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package historycmd
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/OffchainLabs/prysm/v6/cmd"
|
"github.com/OffchainLabs/prysm/v6/cmd"
|
||||||
"github.com/OffchainLabs/prysm/v6/cmd/validator/flags"
|
"github.com/OffchainLabs/prysm/v6/cmd/validator/flags"
|
||||||
@@ -45,16 +46,29 @@ func importSlashingProtectionJSON(cliCtx *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that the database is found under the specified directory or its subdirectories
|
// Ensure that the database is found under the specified directory or its subdirectories
|
||||||
|
var matchPath string
|
||||||
if isDatabaseMinimal {
|
if isDatabaseMinimal {
|
||||||
found, _, err = file.RecursiveDirFind(filesystem.DatabaseDirName, dataDir)
|
found, matchPath, err = file.RecursiveDirFind(filesystem.DatabaseDirName, dataDir)
|
||||||
} else {
|
} else {
|
||||||
found, _, err = file.RecursiveFileFind(kv.ProtectionDbFileName, dataDir)
|
found, matchPath, err = file.RecursiveFileFind(kv.ProtectionDbFileName, dataDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "error finding validator database at path %s", dataDir)
|
return errors.Wrapf(err, "error finding validator database at path %s", dataDir)
|
||||||
}
|
}
|
||||||
|
if !found {
|
||||||
|
databaseFileDir := kv.ProtectionDbFileName
|
||||||
|
if isDatabaseMinimal {
|
||||||
|
databaseFileDir = filesystem.DatabaseDirName
|
||||||
|
}
|
||||||
|
return fmt.Errorf("%s (validator database) was not found at path %s, so nothing to export", databaseFileDir, dataDir)
|
||||||
|
} else {
|
||||||
|
if !isDatabaseMinimal {
|
||||||
|
matchPath = filepath.Dir(matchPath) // strip the file name
|
||||||
|
}
|
||||||
|
dataDir = matchPath
|
||||||
|
log.Infof("Found validator database at path %s", dataDir)
|
||||||
|
}
|
||||||
message := "Found existing database inside of %s"
|
message := "Found existing database inside of %s"
|
||||||
if !found {
|
if !found {
|
||||||
message = "Did not find existing database inside of %s, creating a new one"
|
message = "Did not find existing database inside of %s, creating a new one"
|
||||||
|
|||||||
@@ -3,9 +3,6 @@ package historycmd
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
"path/filepath"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/OffchainLabs/prysm/v6/cmd"
|
"github.com/OffchainLabs/prysm/v6/cmd"
|
||||||
"github.com/OffchainLabs/prysm/v6/cmd/validator/flags"
|
"github.com/OffchainLabs/prysm/v6/cmd/validator/flags"
|
||||||
"github.com/OffchainLabs/prysm/v6/io/file"
|
"github.com/OffchainLabs/prysm/v6/io/file"
|
||||||
@@ -16,6 +13,8 @@ import (
|
|||||||
"github.com/OffchainLabs/prysm/v6/validator/slashing-protection-history/format"
|
"github.com/OffchainLabs/prysm/v6/validator/slashing-protection-history/format"
|
||||||
mocks "github.com/OffchainLabs/prysm/v6/validator/testing"
|
mocks "github.com/OffchainLabs/prysm/v6/validator/testing"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func setupCliCtx(
|
func setupCliCtx(
|
||||||
@@ -41,76 +40,100 @@ func setupCliCtx(
|
|||||||
// slashing protection history database will keep only the latest signed block slot / attestations,
|
// slashing protection history database will keep only the latest signed block slot / attestations,
|
||||||
// and thus will not be able to export the same data as the original file.
|
// and thus will not be able to export the same data as the original file.
|
||||||
func TestImportExportSlashingProtectionCli_RoundTrip(t *testing.T) {
|
func TestImportExportSlashingProtectionCli_RoundTrip(t *testing.T) {
|
||||||
numValidators := 10
|
layouts := []struct {
|
||||||
outputPath := filepath.Join(t.TempDir(), "slashing-exports")
|
name string
|
||||||
err := file.MkdirAll(outputPath)
|
mutate func(t *testing.T) (string, string)
|
||||||
require.NoError(t, err)
|
}{
|
||||||
protectionFileName := "slashing_history_import.json"
|
{
|
||||||
|
name: "flat",
|
||||||
// Create some mock slashing protection history. and JSON file
|
mutate: func(t *testing.T) (string, string) {
|
||||||
pubKeys, err := mocks.CreateRandomPubKeys(numValidators)
|
dbPath := t.TempDir()
|
||||||
require.NoError(t, err)
|
return dbPath, dbPath
|
||||||
attestingHistory, proposalHistory := mocks.MockAttestingAndProposalHistories(pubKeys)
|
},
|
||||||
require.NoError(t, err)
|
},
|
||||||
mockJSON, err := mocks.MockSlashingProtectionJSON(pubKeys, attestingHistory, proposalHistory)
|
{
|
||||||
require.NoError(t, err)
|
name: "nested",
|
||||||
|
mutate: func(t *testing.T) (string, string) {
|
||||||
// We JSON encode the protection file and save it to disk as a JSON file.
|
dbPath := t.TempDir()
|
||||||
encoded, err := json.Marshal(mockJSON)
|
nestedDir := filepath.Join(dbPath, "data", "direct")
|
||||||
require.NoError(t, err)
|
return dbPath, nestedDir
|
||||||
|
},
|
||||||
protectionFilePath := filepath.Join(outputPath, protectionFileName)
|
},
|
||||||
err = file.WriteFile(protectionFilePath, encoded)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
// We create a CLI context with the required values, such as the database datadir and output directory.
|
|
||||||
isSlashingProtectionMinimal := false
|
|
||||||
validatorDB := dbTest.SetupDB(t, pubKeys, isSlashingProtectionMinimal)
|
|
||||||
dbPath := validatorDB.DatabasePath()
|
|
||||||
require.NoError(t, validatorDB.Close())
|
|
||||||
cliCtx := setupCliCtx(t, dbPath, protectionFilePath, outputPath)
|
|
||||||
|
|
||||||
// We import the slashing protection history file via CLI.
|
|
||||||
err = importSlashingProtectionJSON(cliCtx)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
// We export the slashing protection history file via CLI.
|
|
||||||
err = exportSlashingProtectionJSON(cliCtx)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
// Attempt to read the exported file from the output directory.
|
|
||||||
enc, err := file.ReadFileAsBytes(filepath.Join(outputPath, jsonExportFileName))
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
receivedJSON := &format.EIPSlashingProtectionFormat{}
|
|
||||||
err = json.Unmarshal(enc, receivedJSON)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
// We verify the parsed JSON file matches. Given there is no guarantee of order,
|
|
||||||
// we will have to carefully compare and sort values as needed.
|
|
||||||
//
|
|
||||||
// First, we compare basic data such as the MetadataV0 value in the JSON file.
|
|
||||||
require.DeepEqual(t, mockJSON.Metadata, receivedJSON.Metadata)
|
|
||||||
wantedHistoryByPublicKey := make(map[string]*format.ProtectionData)
|
|
||||||
for _, item := range mockJSON.Data {
|
|
||||||
wantedHistoryByPublicKey[item.Pubkey] = item
|
|
||||||
}
|
}
|
||||||
|
for _, tc := range layouts {
|
||||||
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
numValidators := 10
|
||||||
|
outputPath := filepath.Join(t.TempDir(), "slashing-exports")
|
||||||
|
err := file.MkdirAll(outputPath)
|
||||||
|
require.NoError(t, err)
|
||||||
|
protectionFileName := "slashing_history_import.json"
|
||||||
|
|
||||||
// Next, we compare all the data for each validator public key.
|
// Create some mock slashing protection history. and JSON file
|
||||||
for _, item := range receivedJSON.Data {
|
pubKeys, err := mocks.CreateRandomPubKeys(numValidators)
|
||||||
wanted, ok := wantedHistoryByPublicKey[item.Pubkey]
|
require.NoError(t, err)
|
||||||
require.Equal(t, true, ok)
|
attestingHistory, proposalHistory := mocks.MockAttestingAndProposalHistories(pubKeys)
|
||||||
wantedAttsByRoot := make(map[string]*format.SignedAttestation)
|
require.NoError(t, err)
|
||||||
for _, att := range wanted.SignedAttestations {
|
mockJSON, err := mocks.MockSlashingProtectionJSON(pubKeys, attestingHistory, proposalHistory)
|
||||||
wantedAttsByRoot[att.SigningRoot] = att
|
require.NoError(t, err)
|
||||||
}
|
|
||||||
for _, att := range item.SignedAttestations {
|
// We JSON encode the protection file and save it to disk as a JSON file.
|
||||||
wantedAtt, ok := wantedAttsByRoot[att.SigningRoot]
|
encoded, err := json.Marshal(mockJSON)
|
||||||
require.Equal(t, true, ok)
|
require.NoError(t, err)
|
||||||
require.DeepEqual(t, wantedAtt, att)
|
|
||||||
}
|
protectionFilePath := filepath.Join(outputPath, protectionFileName)
|
||||||
require.Equal(t, len(wanted.SignedBlocks), len(item.SignedBlocks))
|
err = file.WriteFile(protectionFilePath, encoded)
|
||||||
require.DeepEqual(t, wanted.SignedBlocks, item.SignedBlocks)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// We create a CLI context with the required values, such as the database datadir and output directory.
|
||||||
|
isSlashingProtectionMinimal := false
|
||||||
|
dataDir, dataPath := tc.mutate(t)
|
||||||
|
validatorDB := dbTest.SetupDB(t, dataPath, pubKeys, isSlashingProtectionMinimal)
|
||||||
|
require.NoError(t, validatorDB.Close())
|
||||||
|
cliCtx := setupCliCtx(t, dataDir, protectionFilePath, outputPath)
|
||||||
|
|
||||||
|
// We import the slashing protection history file via CLI.
|
||||||
|
err = importSlashingProtectionJSON(cliCtx)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// We export the slashing protection history file via CLI.
|
||||||
|
err = exportSlashingProtectionJSON(cliCtx)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// Attempt to read the exported file from the output directory.
|
||||||
|
enc, err := file.ReadFileAsBytes(filepath.Join(outputPath, jsonExportFileName))
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
receivedJSON := &format.EIPSlashingProtectionFormat{}
|
||||||
|
err = json.Unmarshal(enc, receivedJSON)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// We verify the parsed JSON file matches. Given there is no guarantee of order,
|
||||||
|
// we will have to carefully compare and sort values as needed.
|
||||||
|
//
|
||||||
|
// First, we compare basic data such as the MetadataV0 value in the JSON file.
|
||||||
|
require.DeepEqual(t, mockJSON.Metadata, receivedJSON.Metadata)
|
||||||
|
wantedHistoryByPublicKey := make(map[string]*format.ProtectionData)
|
||||||
|
for _, item := range mockJSON.Data {
|
||||||
|
wantedHistoryByPublicKey[item.Pubkey] = item
|
||||||
|
}
|
||||||
|
|
||||||
|
// Next, we compare all the data for each validator public key.
|
||||||
|
for _, item := range receivedJSON.Data {
|
||||||
|
wanted, ok := wantedHistoryByPublicKey[item.Pubkey]
|
||||||
|
require.Equal(t, true, ok)
|
||||||
|
wantedAttsByRoot := make(map[string]*format.SignedAttestation)
|
||||||
|
for _, att := range wanted.SignedAttestations {
|
||||||
|
wantedAttsByRoot[att.SigningRoot] = att
|
||||||
|
}
|
||||||
|
for _, att := range item.SignedAttestations {
|
||||||
|
wantedAtt, ok := wantedAttsByRoot[att.SigningRoot]
|
||||||
|
require.Equal(t, true, ok)
|
||||||
|
require.DeepEqual(t, wantedAtt, att)
|
||||||
|
}
|
||||||
|
require.Equal(t, len(wanted.SignedBlocks), len(item.SignedBlocks))
|
||||||
|
require.DeepEqual(t, wanted.SignedBlocks, item.SignedBlocks)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +170,7 @@ func TestImportExportSlashingProtectionCli_EmptyData(t *testing.T) {
|
|||||||
|
|
||||||
// We create a CLI context with the required values, such as the database datadir and output directory.
|
// We create a CLI context with the required values, such as the database datadir and output directory.
|
||||||
isSlashingProtectionMinimal := false
|
isSlashingProtectionMinimal := false
|
||||||
validatorDB := dbTest.SetupDB(t, pubKeys, isSlashingProtectionMinimal)
|
validatorDB := dbTest.SetupDB(t, t.TempDir(), pubKeys, isSlashingProtectionMinimal)
|
||||||
dbPath := validatorDB.DatabasePath()
|
dbPath := validatorDB.DatabasePath()
|
||||||
require.NoError(t, validatorDB.Close())
|
require.NoError(t, validatorDB.Close())
|
||||||
cliCtx := setupCliCtx(t, dbPath, protectionFilePath, outputPath)
|
cliCtx := setupCliCtx(t, dbPath, protectionFilePath, outputPath)
|
||||||
|
|||||||
@@ -930,7 +930,7 @@ func TestProposerSettingsLoader(t *testing.T) {
|
|||||||
set.Bool(flags.EnableBuilderFlag.Name, true, "")
|
set.Bool(flags.EnableBuilderFlag.Name, true, "")
|
||||||
}
|
}
|
||||||
cliCtx := cli.NewContext(&app, set, nil)
|
cliCtx := cli.NewContext(&app, set, nil)
|
||||||
validatorDB := dbTest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
validatorDB := dbTest.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||||
if tt.withdb != nil {
|
if tt.withdb != nil {
|
||||||
err := tt.withdb(validatorDB)
|
err := tt.withdb(validatorDB)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -978,7 +978,7 @@ func Test_ProposerSettingsLoaderWithOnlyBuilder_DoesNotSaveInDB(t *testing.T) {
|
|||||||
set := flag.NewFlagSet("test", 0)
|
set := flag.NewFlagSet("test", 0)
|
||||||
set.Bool(flags.EnableBuilderFlag.Name, true, "")
|
set.Bool(flags.EnableBuilderFlag.Name, true, "")
|
||||||
cliCtx := cli.NewContext(&app, set, nil)
|
cliCtx := cli.NewContext(&app, set, nil)
|
||||||
validatorDB := dbTest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
validatorDB := dbTest.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||||
loader, err := NewProposerSettingsLoader(
|
loader, err := NewProposerSettingsLoader(
|
||||||
cliCtx,
|
cliCtx,
|
||||||
validatorDB,
|
validatorDB,
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ func setup(t *testing.T, isSlashingProtectionMinimal bool) (*validator, *mocks,
|
|||||||
func setupWithKey(t *testing.T, validatorKey bls.SecretKey, isSlashingProtectionMinimal bool) (*validator, *mocks, bls.SecretKey, func()) {
|
func setupWithKey(t *testing.T, validatorKey bls.SecretKey, isSlashingProtectionMinimal bool) (*validator, *mocks, bls.SecretKey, func()) {
|
||||||
var pubKey [fieldparams.BLSPubkeyLength]byte
|
var pubKey [fieldparams.BLSPubkeyLength]byte
|
||||||
copy(pubKey[:], validatorKey.PublicKey().Marshal())
|
copy(pubKey[:], validatorKey.PublicKey().Marshal())
|
||||||
valDB := testing2.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{pubKey}, isSlashingProtectionMinimal)
|
valDB := testing2.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{pubKey}, isSlashingProtectionMinimal)
|
||||||
ctrl := gomock.NewController(t)
|
ctrl := gomock.NewController(t)
|
||||||
m := &mocks{
|
m := &mocks{
|
||||||
validatorClient: validatormock.NewMockValidatorClient(ctrl),
|
validatorClient: validatormock.NewMockValidatorClient(ctrl),
|
||||||
@@ -1105,7 +1105,7 @@ func TestGetGraffitiOrdered_Ok(t *testing.T) {
|
|||||||
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
|
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
|
||||||
t.Run(fmt.Sprintf("SlashingProtectionMinimal:%v", isSlashingProtectionMinimal), func(t *testing.T) {
|
t.Run(fmt.Sprintf("SlashingProtectionMinimal:%v", isSlashingProtectionMinimal), func(t *testing.T) {
|
||||||
pubKey := [fieldparams.BLSPubkeyLength]byte{'a'}
|
pubKey := [fieldparams.BLSPubkeyLength]byte{'a'}
|
||||||
valDB := testing2.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{pubKey}, isSlashingProtectionMinimal)
|
valDB := testing2.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{pubKey}, isSlashingProtectionMinimal)
|
||||||
ctrl := gomock.NewController(t)
|
ctrl := gomock.NewController(t)
|
||||||
m := &mocks{
|
m := &mocks{
|
||||||
validatorClient: validatormock.NewMockValidatorClient(ctrl),
|
validatorClient: validatormock.NewMockValidatorClient(ctrl),
|
||||||
@@ -1188,7 +1188,7 @@ func Test_validator_DeleteGraffiti(t *testing.T) {
|
|||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
v := &validator{
|
v := &validator{
|
||||||
db: testing2.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{pubKey}, false),
|
db: testing2.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{pubKey}, false),
|
||||||
proposerSettings: tt.proposerSettings,
|
proposerSettings: tt.proposerSettings,
|
||||||
}
|
}
|
||||||
err := v.DeleteGraffiti(context.Background(), pubKey)
|
err := v.DeleteGraffiti(context.Background(), pubKey)
|
||||||
@@ -1268,7 +1268,7 @@ func Test_validator_SetGraffiti(t *testing.T) {
|
|||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
v := &validator{
|
v := &validator{
|
||||||
db: testing2.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{pubKey}, false),
|
db: testing2.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{pubKey}, false),
|
||||||
proposerSettings: tt.proposerSettings,
|
proposerSettings: tt.proposerSettings,
|
||||||
}
|
}
|
||||||
err := v.SetGraffiti(context.Background(), pubKey, []byte(tt.graffiti))
|
err := v.SetGraffiti(context.Background(), pubKey, []byte(tt.graffiti))
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ func TestWaitForChainStart_SetsGenesisInfo(t *testing.T) {
|
|||||||
defer ctrl.Finish()
|
defer ctrl.Finish()
|
||||||
client := validatormock.NewMockValidatorClient(ctrl)
|
client := validatormock.NewMockValidatorClient(ctrl)
|
||||||
|
|
||||||
db := dbTest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
db := dbTest.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||||
v := validator{
|
v := validator{
|
||||||
validatorClient: client,
|
validatorClient: client,
|
||||||
db: db,
|
db: db,
|
||||||
@@ -215,7 +215,7 @@ func TestWaitForChainStart_SetsGenesisInfo_IncorrectSecondTry(t *testing.T) {
|
|||||||
defer ctrl.Finish()
|
defer ctrl.Finish()
|
||||||
client := validatormock.NewMockValidatorClient(ctrl)
|
client := validatormock.NewMockValidatorClient(ctrl)
|
||||||
|
|
||||||
db := dbTest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
db := dbTest.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||||
v := validator{
|
v := validator{
|
||||||
validatorClient: client,
|
validatorClient: client,
|
||||||
db: db,
|
db: db,
|
||||||
@@ -925,7 +925,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
|
|||||||
km := genMockKeymanager(t, 10)
|
km := genMockKeymanager(t, 10)
|
||||||
keys, err := km.FetchValidatingPublicKeys(context.Background())
|
keys, err := km.FetchValidatingPublicKeys(context.Background())
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
db := dbTest.SetupDB(t, keys, isSlashingProtectionMinimal)
|
db := dbTest.SetupDB(t, t.TempDir(), keys, isSlashingProtectionMinimal)
|
||||||
req := ðpb.DoppelGangerRequest{ValidatorRequests: []*ethpb.DoppelGangerRequest_ValidatorRequest{}}
|
req := ðpb.DoppelGangerRequest{ValidatorRequests: []*ethpb.DoppelGangerRequest_ValidatorRequest{}}
|
||||||
for _, k := range keys {
|
for _, k := range keys {
|
||||||
pkey := k
|
pkey := k
|
||||||
@@ -959,7 +959,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
|
|||||||
km := genMockKeymanager(t, 10)
|
km := genMockKeymanager(t, 10)
|
||||||
keys, err := km.FetchValidatingPublicKeys(context.Background())
|
keys, err := km.FetchValidatingPublicKeys(context.Background())
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
db := dbTest.SetupDB(t, keys, isSlashingProtectionMinimal)
|
db := dbTest.SetupDB(t, t.TempDir(), keys, isSlashingProtectionMinimal)
|
||||||
req := ðpb.DoppelGangerRequest{ValidatorRequests: []*ethpb.DoppelGangerRequest_ValidatorRequest{}}
|
req := ðpb.DoppelGangerRequest{ValidatorRequests: []*ethpb.DoppelGangerRequest_ValidatorRequest{}}
|
||||||
resp := ðpb.DoppelGangerResponse{Responses: []*ethpb.DoppelGangerResponse_ValidatorResponse{}}
|
resp := ðpb.DoppelGangerResponse{Responses: []*ethpb.DoppelGangerResponse_ValidatorResponse{}}
|
||||||
for i, k := range keys {
|
for i, k := range keys {
|
||||||
@@ -1000,7 +1000,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
|
|||||||
km := genMockKeymanager(t, 10)
|
km := genMockKeymanager(t, 10)
|
||||||
keys, err := km.FetchValidatingPublicKeys(context.Background())
|
keys, err := km.FetchValidatingPublicKeys(context.Background())
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
db := dbTest.SetupDB(t, keys, isSlashingProtectionMinimal)
|
db := dbTest.SetupDB(t, t.TempDir(), keys, isSlashingProtectionMinimal)
|
||||||
req := ðpb.DoppelGangerRequest{ValidatorRequests: []*ethpb.DoppelGangerRequest_ValidatorRequest{}}
|
req := ðpb.DoppelGangerRequest{ValidatorRequests: []*ethpb.DoppelGangerRequest_ValidatorRequest{}}
|
||||||
resp := ðpb.DoppelGangerResponse{Responses: []*ethpb.DoppelGangerResponse_ValidatorResponse{}}
|
resp := ðpb.DoppelGangerResponse{Responses: []*ethpb.DoppelGangerResponse_ValidatorResponse{}}
|
||||||
for i, k := range keys {
|
for i, k := range keys {
|
||||||
@@ -1039,7 +1039,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
|
|||||||
km := genMockKeymanager(t, 10)
|
km := genMockKeymanager(t, 10)
|
||||||
keys, err := km.FetchValidatingPublicKeys(context.Background())
|
keys, err := km.FetchValidatingPublicKeys(context.Background())
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
db := dbTest.SetupDB(t, keys, isSlashingProtectionMinimal)
|
db := dbTest.SetupDB(t, t.TempDir(), keys, isSlashingProtectionMinimal)
|
||||||
req := ðpb.DoppelGangerRequest{ValidatorRequests: []*ethpb.DoppelGangerRequest_ValidatorRequest{}}
|
req := ðpb.DoppelGangerRequest{ValidatorRequests: []*ethpb.DoppelGangerRequest_ValidatorRequest{}}
|
||||||
resp := ðpb.DoppelGangerResponse{Responses: []*ethpb.DoppelGangerResponse_ValidatorResponse{}}
|
resp := ðpb.DoppelGangerResponse{Responses: []*ethpb.DoppelGangerResponse_ValidatorResponse{}}
|
||||||
attLimit := 5
|
attLimit := 5
|
||||||
@@ -1085,7 +1085,7 @@ func TestValidator_CheckDoppelGanger(t *testing.T) {
|
|||||||
km := genMockKeymanager(t, 1)
|
km := genMockKeymanager(t, 1)
|
||||||
keys, err := km.FetchValidatingPublicKeys(context.Background())
|
keys, err := km.FetchValidatingPublicKeys(context.Background())
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
db := dbTest.SetupDB(t, keys, isSlashingProtectionMinimal)
|
db := dbTest.SetupDB(t, t.TempDir(), keys, isSlashingProtectionMinimal)
|
||||||
resp := ðpb.DoppelGangerResponse{Responses: []*ethpb.DoppelGangerResponse_ValidatorResponse{}}
|
resp := ðpb.DoppelGangerResponse{Responses: []*ethpb.DoppelGangerResponse_ValidatorResponse{}}
|
||||||
req := ðpb.DoppelGangerRequest{ValidatorRequests: []*ethpb.DoppelGangerRequest_ValidatorRequest{}}
|
req := ðpb.DoppelGangerRequest{ValidatorRequests: []*ethpb.DoppelGangerRequest_ValidatorRequest{}}
|
||||||
for _, k := range keys {
|
for _, k := range keys {
|
||||||
@@ -1123,7 +1123,7 @@ func TestValidatorAttestationsAreOrdered(t *testing.T) {
|
|||||||
km := genMockKeymanager(t, 10)
|
km := genMockKeymanager(t, 10)
|
||||||
keys, err := km.FetchValidatingPublicKeys(context.Background())
|
keys, err := km.FetchValidatingPublicKeys(context.Background())
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
db := dbTest.SetupDB(t, keys, isSlashingProtectionMinimal)
|
db := dbTest.SetupDB(t, t.TempDir(), keys, isSlashingProtectionMinimal)
|
||||||
|
|
||||||
k := keys[0]
|
k := keys[0]
|
||||||
att := createAttestation(10, 14)
|
att := createAttestation(10, 14)
|
||||||
@@ -1303,7 +1303,7 @@ func TestValidator_WaitForKeymanagerInitialization_web3Signer(t *testing.T) {
|
|||||||
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
|
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
|
||||||
t.Run(fmt.Sprintf("SlashingProtectionMinimal:%v", isSlashingProtectionMinimal), func(t *testing.T) {
|
t.Run(fmt.Sprintf("SlashingProtectionMinimal:%v", isSlashingProtectionMinimal), func(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
db := dbTest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
db := dbTest.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||||
root := make([]byte, 32)
|
root := make([]byte, 32)
|
||||||
copy(root[2:], "a")
|
copy(root[2:], "a")
|
||||||
err := db.SaveGenesisValidatorsRoot(ctx, root)
|
err := db.SaveGenesisValidatorsRoot(ctx, root)
|
||||||
@@ -1336,7 +1336,7 @@ func TestValidator_WaitForKeymanagerInitialization_Web(t *testing.T) {
|
|||||||
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
|
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
|
||||||
t.Run(fmt.Sprintf("SlashingProtectionMinimal:%v", isSlashingProtectionMinimal), func(t *testing.T) {
|
t.Run(fmt.Sprintf("SlashingProtectionMinimal:%v", isSlashingProtectionMinimal), func(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
db := dbTest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
db := dbTest.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||||
root := make([]byte, 32)
|
root := make([]byte, 32)
|
||||||
copy(root[2:], "a")
|
copy(root[2:], "a")
|
||||||
err := db.SaveGenesisValidatorsRoot(ctx, root)
|
err := db.SaveGenesisValidatorsRoot(ctx, root)
|
||||||
@@ -1370,7 +1370,7 @@ func TestValidator_WaitForKeymanagerInitialization_Interop(t *testing.T) {
|
|||||||
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
|
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
|
||||||
t.Run(fmt.Sprintf("SlashingProtectionMinimal:%v", isSlashingProtectionMinimal), func(t *testing.T) {
|
t.Run(fmt.Sprintf("SlashingProtectionMinimal:%v", isSlashingProtectionMinimal), func(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
db := dbTest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
db := dbTest.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||||
root := make([]byte, 32)
|
root := make([]byte, 32)
|
||||||
copy(root[2:], "a")
|
copy(root[2:], "a")
|
||||||
err := db.SaveGenesisValidatorsRoot(ctx, root)
|
err := db.SaveGenesisValidatorsRoot(ctx, root)
|
||||||
@@ -1430,7 +1430,7 @@ func TestValidator_PushSettings(t *testing.T) {
|
|||||||
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
|
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
|
||||||
ctrl := gomock.NewController(t)
|
ctrl := gomock.NewController(t)
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
db := dbTest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
db := dbTest.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||||
client := validatormock.NewMockValidatorClient(ctrl)
|
client := validatormock.NewMockValidatorClient(ctrl)
|
||||||
nodeClient := validatormock.NewMockNodeClient(ctrl)
|
nodeClient := validatormock.NewMockNodeClient(ctrl)
|
||||||
defaultFeeHex := "0x046Fb65722E7b2455043BFEBf6177F1D2e9738D9"
|
defaultFeeHex := "0x046Fb65722E7b2455043BFEBf6177F1D2e9738D9"
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func TestMigrateUp_NoDBFound(t *testing.T) {
|
|||||||
// This, it is tested only for complete slashing protection database.
|
// This, it is tested only for complete slashing protection database.
|
||||||
func TestMigrateUp_OK(t *testing.T) {
|
func TestMigrateUp_OK(t *testing.T) {
|
||||||
isSlashingProtectionMinimal := false
|
isSlashingProtectionMinimal := false
|
||||||
validatorDB := dbtest.SetupDB(t, nil, isSlashingProtectionMinimal)
|
validatorDB := dbtest.SetupDB(t, t.TempDir(), nil, isSlashingProtectionMinimal)
|
||||||
dbPath := validatorDB.DatabasePath()
|
dbPath := validatorDB.DatabasePath()
|
||||||
require.NoError(t, validatorDB.Close())
|
require.NoError(t, validatorDB.Close())
|
||||||
app := cli.App{}
|
app := cli.App{}
|
||||||
@@ -52,7 +52,7 @@ func TestMigrateDown_NoDBFound(t *testing.T) {
|
|||||||
// This, it is tested only for complete slashing protection database.
|
// This, it is tested only for complete slashing protection database.
|
||||||
func TestMigrateDown_OK(t *testing.T) {
|
func TestMigrateDown_OK(t *testing.T) {
|
||||||
isSlashingProtectionMinimal := false
|
isSlashingProtectionMinimal := false
|
||||||
validatorDB := dbtest.SetupDB(t, nil, isSlashingProtectionMinimal)
|
validatorDB := dbtest.SetupDB(t, t.TempDir(), nil, isSlashingProtectionMinimal)
|
||||||
dbPath := validatorDB.DatabasePath()
|
dbPath := validatorDB.DatabasePath()
|
||||||
require.NoError(t, validatorDB.Close())
|
require.NoError(t, validatorDB.Close())
|
||||||
app := cli.App{}
|
app := cli.App{}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
// SetupDB instantiates and returns a DB instance for the validator client.
|
// SetupDB instantiates and returns a DB instance for the validator client.
|
||||||
// The `minimal` flag indicates whether the DB should be instantiated with minimal, filesystem
|
// The `minimal` flag indicates whether the DB should be instantiated with minimal, filesystem
|
||||||
// slashing protection database.
|
// slashing protection database.
|
||||||
func SetupDB(t testing.TB, pubkeys [][fieldparams.BLSPubkeyLength]byte, minimal bool) iface.ValidatorDB {
|
func SetupDB(t testing.TB, dataPath string, pubkeys [][fieldparams.BLSPubkeyLength]byte, minimal bool) iface.ValidatorDB {
|
||||||
var (
|
var (
|
||||||
db iface.ValidatorDB
|
db iface.ValidatorDB
|
||||||
err error
|
err error
|
||||||
@@ -22,10 +22,10 @@ func SetupDB(t testing.TB, pubkeys [][fieldparams.BLSPubkeyLength]byte, minimal
|
|||||||
// Create a new DB instance.
|
// Create a new DB instance.
|
||||||
if minimal {
|
if minimal {
|
||||||
config := &filesystem.Config{PubKeys: pubkeys}
|
config := &filesystem.Config{PubKeys: pubkeys}
|
||||||
db, err = filesystem.NewStore(t.TempDir(), config)
|
db, err = filesystem.NewStore(dataPath, config)
|
||||||
} else {
|
} else {
|
||||||
config := &kv.Config{PubKeys: pubkeys}
|
config := &kv.Config{PubKeys: pubkeys}
|
||||||
db, err = kv.NewKVStore(context.Background(), t.TempDir(), config)
|
db, err = kv.NewKVStore(context.Background(), dataPath, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -1110,7 +1110,7 @@ func TestServer_SetGasLimit(t *testing.T) {
|
|||||||
m := &testutil.FakeValidator{}
|
m := &testutil.FakeValidator{}
|
||||||
err := m.SetProposerSettings(ctx, tt.proposerSettings)
|
err := m.SetProposerSettings(ctx, tt.proposerSettings)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
validatorDB := dbtest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
validatorDB := dbtest.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||||
vs, err := client.NewValidatorService(ctx, &client.Config{
|
vs, err := client.NewValidatorService(ctx, &client.Config{
|
||||||
Validator: m,
|
Validator: m,
|
||||||
DB: validatorDB,
|
DB: validatorDB,
|
||||||
@@ -1299,7 +1299,7 @@ func TestServer_DeleteGasLimit(t *testing.T) {
|
|||||||
m := &testutil.FakeValidator{}
|
m := &testutil.FakeValidator{}
|
||||||
err := m.SetProposerSettings(ctx, tt.proposerSettings)
|
err := m.SetProposerSettings(ctx, tt.proposerSettings)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
validatorDB := dbtest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
validatorDB := dbtest.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||||
vs, err := client.NewValidatorService(ctx, &client.Config{
|
vs, err := client.NewValidatorService(ctx, &client.Config{
|
||||||
Validator: m,
|
Validator: m,
|
||||||
DB: validatorDB,
|
DB: validatorDB,
|
||||||
@@ -1777,7 +1777,7 @@ func TestServer_FeeRecipientByPubkey(t *testing.T) {
|
|||||||
m := &testutil.FakeValidator{}
|
m := &testutil.FakeValidator{}
|
||||||
err := m.SetProposerSettings(ctx, tt.proposerSettings)
|
err := m.SetProposerSettings(ctx, tt.proposerSettings)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
validatorDB := dbtest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
validatorDB := dbtest.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||||
|
|
||||||
// save a default here
|
// save a default here
|
||||||
vs, err := client.NewValidatorService(ctx, &client.Config{
|
vs, err := client.NewValidatorService(ctx, &client.Config{
|
||||||
@@ -1889,7 +1889,7 @@ func TestServer_DeleteFeeRecipientByPubkey(t *testing.T) {
|
|||||||
m := &testutil.FakeValidator{}
|
m := &testutil.FakeValidator{}
|
||||||
err := m.SetProposerSettings(ctx, tt.proposerSettings)
|
err := m.SetProposerSettings(ctx, tt.proposerSettings)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
validatorDB := dbtest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
validatorDB := dbtest.SetupDB(t, t.TempDir(), [][fieldparams.BLSPubkeyLength]byte{}, isSlashingProtectionMinimal)
|
||||||
vs, err := client.NewValidatorService(ctx, &client.Config{
|
vs, err := client.NewValidatorService(ctx, &client.Config{
|
||||||
Validator: m,
|
Validator: m,
|
||||||
DB: validatorDB,
|
DB: validatorDB,
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ func TestExportStandardProtectionJSON_EmptyGenesisRoot(t *testing.T) {
|
|||||||
pubKeys := [][fieldparams.BLSPubkeyLength]byte{
|
pubKeys := [][fieldparams.BLSPubkeyLength]byte{
|
||||||
{1},
|
{1},
|
||||||
}
|
}
|
||||||
validatorDB := dbtest.SetupDB(t, pubKeys, isSlashingProtectionMinimal)
|
validatorDB := dbtest.SetupDB(t, t.TempDir(), pubKeys, isSlashingProtectionMinimal)
|
||||||
_, err := ExportStandardProtectionJSON(ctx, validatorDB)
|
_, err := ExportStandardProtectionJSON(ctx, validatorDB)
|
||||||
require.ErrorContains(t, "genesis validators root is empty", err)
|
require.ErrorContains(t, "genesis validators root is empty", err)
|
||||||
genesisValidatorsRoot := [32]byte{1}
|
genesisValidatorsRoot := [32]byte{1}
|
||||||
@@ -40,7 +40,7 @@ func Test_getSignedAttestationsByPubKey(t *testing.T) {
|
|||||||
{1},
|
{1},
|
||||||
}
|
}
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
validatorDB := dbtest.SetupDB(t, pubKeys, isSlashingProtectionMinimal)
|
validatorDB := dbtest.SetupDB(t, t.TempDir(), pubKeys, isSlashingProtectionMinimal)
|
||||||
|
|
||||||
// No attestation history stored should return empty.
|
// No attestation history stored should return empty.
|
||||||
signedAttestations, err := signedAttestationsByPubKey(ctx, validatorDB, pubKeys[0])
|
signedAttestations, err := signedAttestationsByPubKey(ctx, validatorDB, pubKeys[0])
|
||||||
@@ -98,7 +98,7 @@ func Test_getSignedAttestationsByPubKey(t *testing.T) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
isSlashingProtectionMinimal := false
|
isSlashingProtectionMinimal := false
|
||||||
validatorDB := dbtest.SetupDB(t, pubKeys, isSlashingProtectionMinimal)
|
validatorDB := dbtest.SetupDB(t, t.TempDir(), pubKeys, isSlashingProtectionMinimal)
|
||||||
|
|
||||||
// No attestation history stored should return empty.
|
// No attestation history stored should return empty.
|
||||||
signedAttestations, err := signedAttestationsByPubKey(ctx, validatorDB, pubKeys[0])
|
signedAttestations, err := signedAttestationsByPubKey(ctx, validatorDB, pubKeys[0])
|
||||||
@@ -145,7 +145,7 @@ func Test_getSignedAttestationsByPubKey(t *testing.T) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
isSlashingProtectionMinimal := false
|
isSlashingProtectionMinimal := false
|
||||||
validatorDB := dbtest.SetupDB(t, pubKeys, isSlashingProtectionMinimal)
|
validatorDB := dbtest.SetupDB(t, t.TempDir(), pubKeys, isSlashingProtectionMinimal)
|
||||||
|
|
||||||
// No attestation history stored should return empty.
|
// No attestation history stored should return empty.
|
||||||
signedAttestations, err := signedAttestationsByPubKey(ctx, validatorDB, pubKeys[0])
|
signedAttestations, err := signedAttestationsByPubKey(ctx, validatorDB, pubKeys[0])
|
||||||
@@ -196,7 +196,7 @@ func Test_getSignedBlocksByPubKey(t *testing.T) {
|
|||||||
{1},
|
{1},
|
||||||
}
|
}
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
validatorDB := dbtest.SetupDB(t, pubKeys, isSlashingProtectionMinimal)
|
validatorDB := dbtest.SetupDB(t, t.TempDir(), pubKeys, isSlashingProtectionMinimal)
|
||||||
|
|
||||||
// No highest and/or lowest signed blocks will return empty.
|
// No highest and/or lowest signed blocks will return empty.
|
||||||
signedBlocks, err := signedBlocksByPubKey(ctx, validatorDB, pubKeys[0])
|
signedBlocks, err := signedBlocksByPubKey(ctx, validatorDB, pubKeys[0])
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ func TestImportExport_RoundTrip(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
isSlashingProtectionMinimal := false
|
isSlashingProtectionMinimal := false
|
||||||
validatorDB := dbtest.SetupDB(t, publicKeys, isSlashingProtectionMinimal)
|
validatorDB := dbtest.SetupDB(t, t.TempDir(), publicKeys, isSlashingProtectionMinimal)
|
||||||
|
|
||||||
// First we setup some mock attesting and proposal histories and create a mock
|
// First we setup some mock attesting and proposal histories and create a mock
|
||||||
// standard slashing protection format JSON struct.
|
// standard slashing protection format JSON struct.
|
||||||
@@ -98,7 +98,7 @@ func TestImportExport_RoundTrip_SkippedAttestationEpochs(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
isSlashingProtectionMinimal := false
|
isSlashingProtectionMinimal := false
|
||||||
validatorDB := dbtest.SetupDB(t, pubKeys, isSlashingProtectionMinimal)
|
validatorDB := dbtest.SetupDB(t, t.TempDir(), pubKeys, isSlashingProtectionMinimal)
|
||||||
wanted := &format.EIPSlashingProtectionFormat{
|
wanted := &format.EIPSlashingProtectionFormat{
|
||||||
Metadata: struct {
|
Metadata: struct {
|
||||||
InterchangeFormatVersion string `json:"interchange_format_version"`
|
InterchangeFormatVersion string `json:"interchange_format_version"`
|
||||||
@@ -164,7 +164,7 @@ func TestImportExport_FilterKeys(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
isSlashingProtectionMinimal := false
|
isSlashingProtectionMinimal := false
|
||||||
validatorDB := dbtest.SetupDB(t, publicKeys, isSlashingProtectionMinimal)
|
validatorDB := dbtest.SetupDB(t, t.TempDir(), publicKeys, isSlashingProtectionMinimal)
|
||||||
|
|
||||||
// First we setup some mock attesting and proposal histories and create a mock
|
// First we setup some mock attesting and proposal histories and create a mock
|
||||||
// standard slashing protection format JSON struct.
|
// standard slashing protection format JSON struct.
|
||||||
@@ -209,7 +209,7 @@ func TestImportInterchangeData_OK(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
isSlashingProtectionMinimal := false
|
isSlashingProtectionMinimal := false
|
||||||
validatorDB := dbtest.SetupDB(t, publicKeys, isSlashingProtectionMinimal)
|
validatorDB := dbtest.SetupDB(t, t.TempDir(), publicKeys, isSlashingProtectionMinimal)
|
||||||
|
|
||||||
// First we setup some mock attesting and proposal histories and create a mock
|
// First we setup some mock attesting and proposal histories and create a mock
|
||||||
// standard slashing protection format JSON struct.
|
// standard slashing protection format JSON struct.
|
||||||
@@ -279,7 +279,7 @@ func TestImportInterchangeData_OK_SavesBlacklistedPublicKeys(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
isSlashingProtectionMinimal := false
|
isSlashingProtectionMinimal := false
|
||||||
validatorDB := dbtest.SetupDB(t, publicKeys, isSlashingProtectionMinimal)
|
validatorDB := dbtest.SetupDB(t, t.TempDir(), publicKeys, isSlashingProtectionMinimal)
|
||||||
|
|
||||||
// First we setup some mock attesting and proposal histories and create a mock
|
// First we setup some mock attesting and proposal histories and create a mock
|
||||||
// standard slashing protection format JSON struct.
|
// standard slashing protection format JSON struct.
|
||||||
@@ -374,7 +374,7 @@ func TestStore_ImportInterchangeData_BadFormat_PreventsDBWrites(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
isSlashingProtectionMinimal := false
|
isSlashingProtectionMinimal := false
|
||||||
validatorDB := dbtest.SetupDB(t, publicKeys, isSlashingProtectionMinimal)
|
validatorDB := dbtest.SetupDB(t, t.TempDir(), publicKeys, isSlashingProtectionMinimal)
|
||||||
|
|
||||||
// First we setup some mock attesting and proposal histories and create a mock
|
// First we setup some mock attesting and proposal histories and create a mock
|
||||||
// standard slashing protection format JSON struct.
|
// standard slashing protection format JSON struct.
|
||||||
|
|||||||
Reference in New Issue
Block a user