Skip to content

Commit

Permalink
Remove keystore keymanager from validator (#5236)
Browse files Browse the repository at this point in the history
* Remove keystore keymanager from validator

* Update dependency

* Update validator/flags/flags.go

* Update validator/flags/flags.go

Co-authored-by: Ivan Martinez <ivanthegreatdev@gmail.com>
  • Loading branch information
mcdee and 0xKiwi committed Mar 30, 2020
1 parent b2375ae commit 4600877
Show file tree
Hide file tree
Showing 18 changed files with 74 additions and 526 deletions.
2 changes: 1 addition & 1 deletion shared/cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var (
// DataDirFlag defines a path on disk.
DataDirFlag = &cli.StringFlag{
Name: "datadir",
Usage: "Data directory for the databases and keystore",
Usage: "Data directory for the databases",
Value: DefaultDataDir(),
}
// EnableTracingFlag defines a flag to enable p2p message tracing.
Expand Down
3 changes: 0 additions & 3 deletions validator/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ go_library(
"//shared/debug:go_default_library",
"//shared/featureconfig:go_default_library",
"//shared/logutil:go_default_library",
"//shared/params:go_default_library",
"//shared/version:go_default_library",
"//validator/accounts:go_default_library",
"//validator/flags:go_default_library",
"//validator/node:go_default_library",
"@com_github_joonix_log//:go_default_library",
Expand Down Expand Up @@ -52,7 +50,6 @@ go_image(
"//shared/logutil:go_default_library",
"//shared/params:go_default_library",
"//shared/version:go_default_library",
"//validator/accounts:go_default_library",
"//validator/flags:go_default_library",
"//validator/node:go_default_library",
"@com_github_joonix_log//:go_default_library",
Expand Down
31 changes: 0 additions & 31 deletions validator/accounts/BUILD.bazel

This file was deleted.

159 changes: 0 additions & 159 deletions validator/accounts/account.go

This file was deleted.

37 changes: 0 additions & 37 deletions validator/accounts/account_test.go

This file was deleted.

2 changes: 0 additions & 2 deletions validator/client/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,10 @@ go_test(
"//shared/bls:go_default_library",
"//shared/bytesutil:go_default_library",
"//shared/featureconfig:go_default_library",
"//shared/keystore:go_default_library",
"//shared/mock:go_default_library",
"//shared/params:go_default_library",
"//shared/roughtime:go_default_library",
"//shared/testutil:go_default_library",
"//validator/accounts:go_default_library",
"//validator/db:go_default_library",
"//validator/internal:go_default_library",
"//validator/keymanager:go_default_library",
Expand Down
36 changes: 16 additions & 20 deletions validator/client/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,44 @@ import (

"github.com/prysmaticlabs/prysm/shared"
"github.com/prysmaticlabs/prysm/shared/bls"
"github.com/prysmaticlabs/prysm/shared/keystore"
"github.com/prysmaticlabs/prysm/shared/testutil"
"github.com/prysmaticlabs/prysm/validator/accounts"
"github.com/prysmaticlabs/prysm/validator/keymanager"
logTest "github.com/sirupsen/logrus/hooks/test"
)

var _ = shared.Service(&ValidatorService{})
var validatorKey *keystore.Key
var validatorPubKey [48]byte
var keyMap map[[48]byte]*keystore.Key
var keyMapThreeValidators map[[48]byte]*keystore.Key
var validatorPubKey *bls.PublicKey
var secKeyMap map[[48]byte]*bls.SecretKey
var pubKeyMap map[[48]byte]*bls.PublicKey
var secKeyMapThreeValidators map[[48]byte]*bls.SecretKey
var pubKeyMapThreeValidators map[[48]byte]*bls.PublicKey
var testKeyManager keymanager.KeyManager
var testKeyManagerThreeValidators keymanager.KeyManager

func keySetup() {
keyMap = make(map[[48]byte]*keystore.Key)
keyMapThreeValidators = make(map[[48]byte]*keystore.Key)

validatorKey, _ = keystore.NewKey()
copy(validatorPubKey[:], validatorKey.PublicKey.Marshal())
keyMap[validatorPubKey] = validatorKey
pubKeyMap = make(map[[48]byte]*bls.PublicKey)
secKeyMap = make(map[[48]byte]*bls.SecretKey)
pubKeyMapThreeValidators = make(map[[48]byte]*bls.PublicKey)
secKeyMapThreeValidators = make(map[[48]byte]*bls.SecretKey)

sks := make([]*bls.SecretKey, 1)
sks[0] = validatorKey.SecretKey
sks[0] = bls.RandKey()
testKeyManager = keymanager.NewDirect(sks)
validatorPubKey = sks[0].PublicKey()

sks = make([]*bls.SecretKey, 3)
for i := 0; i < 3; i++ {
vKey, _ := keystore.NewKey()
secKey := bls.RandKey()
var pubKey [48]byte
copy(pubKey[:], vKey.PublicKey.Marshal())
keyMapThreeValidators[pubKey] = vKey
sks[i] = vKey.SecretKey
copy(pubKey[:], secKey.PublicKey().Marshal())
secKeyMapThreeValidators[pubKey] = secKey
pubKeyMapThreeValidators[pubKey] = secKey.PublicKey()
sks[i] = secKey
}
testKeyManagerThreeValidators = keymanager.NewDirect(sks)
}

func TestMain(m *testing.M) {
dir := testutil.TempDir() + "/keystore1"
defer os.RemoveAll(dir)
accounts.NewValidatorAccount(dir, "1234")
keySetup()
os.Exit(m.Run())
}
Expand Down
7 changes: 4 additions & 3 deletions validator/client/validator_aggregate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/golang/mock/gomock"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil"
logTest "github.com/sirupsen/logrus/hooks/test"
Expand All @@ -18,7 +19,7 @@ func TestSubmitAggregateAndProof_GetDutiesRequestFailure(t *testing.T) {
validator.duties = &ethpb.DutiesResponse{Duties: []*ethpb.DutiesResponse_Duty{}}
defer finish()

validator.SubmitAggregateAndProof(context.Background(), 0, validatorPubKey)
validator.SubmitAggregateAndProof(context.Background(), 0, bytesutil.ToBytes48(validatorPubKey.Marshal()))

testutil.AssertLogsContain(t, hook, "Could not fetch validator assignment")
}
Expand All @@ -29,7 +30,7 @@ func TestSubmitAggregateAndProof_Ok(t *testing.T) {
validator.duties = &ethpb.DutiesResponse{
Duties: []*ethpb.DutiesResponse_Duty{
{
PublicKey: validatorKey.PublicKey.Marshal(),
PublicKey: validatorPubKey.Marshal(),
},
},
}
Expand Down Expand Up @@ -60,7 +61,7 @@ func TestSubmitAggregateAndProof_Ok(t *testing.T) {
gomock.AssignableToTypeOf(&ethpb.SignedAggregateSubmitRequest{}),
).Return(&ethpb.SignedAggregateSubmitResponse{}, nil)

validator.SubmitAggregateAndProof(context.Background(), 0, validatorPubKey)
validator.SubmitAggregateAndProof(context.Background(), 0, bytesutil.ToBytes48(validatorPubKey.Marshal()))
}

func TestWaitForSlotTwoThird_WaitCorrectly(t *testing.T) {
Expand Down
Loading

0 comments on commit 4600877

Please sign in to comment.