diff --git a/beacon-chain/blockchain/process_block.go b/beacon-chain/blockchain/process_block.go index 396709975b..435bd4b9bb 100644 --- a/beacon-chain/blockchain/process_block.go +++ b/beacon-chain/blockchain/process_block.go @@ -611,7 +611,7 @@ func (s *Service) insertBlockToForkChoiceStore(ctx context.Context, blk interfac return s.cfg.ForkChoiceStore.InsertNode(ctx, st, root) } -// Inserts attester slashing indices to fork choice store. +// InsertSlashingsToForkChoiceStore inserts attester slashing indices to fork choice store. // To call this function, it's caller's responsibility to ensure the slashing object is valid. func (s *Service) InsertSlashingsToForkChoiceStore(ctx context.Context, slashings []*ethpb.AttesterSlashing) { for _, slashing := range slashings { diff --git a/beacon-chain/blockchain/state_balance_cache_test.go b/beacon-chain/blockchain/state_balance_cache_test.go index 4bf2055f92..d91b6a7e5b 100644 --- a/beacon-chain/blockchain/state_balance_cache_test.go +++ b/beacon-chain/blockchain/state_balance_cache_test.go @@ -117,7 +117,7 @@ func TestStateBalanceCache(t *testing.T) { balances []uint64 name string } - sentinelCacheMiss := errors.New("Cache missed, as expected!") + sentinelCacheMiss := errors.New("cache missed, as expected") sentinelBalances := []uint64{1, 2, 3, 4, 5} halfExpiredValidators, halfExpiredBalances := testHalfExpiredValidators() halfQueuedValidators, halfQueuedBalances := testHalfQueuedValidators() diff --git a/beacon-chain/rpc/statefetcher/fetcher.go b/beacon-chain/rpc/statefetcher/fetcher.go index 7e29520068..602d9a455d 100644 --- a/beacon-chain/rpc/statefetcher/fetcher.go +++ b/beacon-chain/rpc/statefetcher/fetcher.go @@ -19,10 +19,6 @@ import ( "go.opencensus.io/trace" ) -var ErrNoAncestorForBlock = errors.New("could not find an ancestor state for block") -var ErrNoCanonicalBlockForSlot = errors.New("none of the blocks found in the db slot index are canonical") -var ErrInvalidDBBlock = errors.New("invalid block found in database") - // StateIdParseError represents an error scenario where a state ID could not be parsed. type StateIdParseError struct { message string diff --git a/beacon-chain/state/state-native/error.go b/beacon-chain/state/state-native/error.go index ac8dde525e..8d486527ab 100644 --- a/beacon-chain/state/state-native/error.go +++ b/beacon-chain/state/state-native/error.go @@ -2,4 +2,4 @@ package state_native import "errors" -var ErrNilParticipation = errors.New("Nil epoch participation in state") +var ErrNilParticipation = errors.New("nil epoch participation in state") diff --git a/beacon-chain/state/stategen/replayer.go b/beacon-chain/state/stategen/replayer.go index b40bf7db60..8769e76591 100644 --- a/beacon-chain/state/stategen/replayer.go +++ b/beacon-chain/state/stategen/replayer.go @@ -16,7 +16,6 @@ import ( var ErrFutureSlotRequested = errors.New("cannot replay to future slots") var ErrNoCanonicalBlockForSlot = errors.New("none of the blocks found in the db slot index are canonical") var ErrNoBlocksBelowSlot = errors.New("no blocks found in db below slot") -var ErrInvalidDBBlock = errors.New("invalid block found in database") var ErrReplayTargetSlotExceeded = errors.New("desired replay slot is less than state's slot") type retrievalMethod int diff --git a/beacon-chain/state/v2/error.go b/beacon-chain/state/v2/error.go index 7ab7be4dc6..a9ea20b9a6 100644 --- a/beacon-chain/state/v2/error.go +++ b/beacon-chain/state/v2/error.go @@ -2,4 +2,4 @@ package v2 import "errors" -var ErrNilParticipation = errors.New("Nil epoch participation in state") +var ErrNilParticipation = errors.New("nil epoch participation in state") diff --git a/beacon-chain/state/v3/error.go b/beacon-chain/state/v3/error.go index f7773f8a6d..f2a058a8d9 100644 --- a/beacon-chain/state/v3/error.go +++ b/beacon-chain/state/v3/error.go @@ -2,4 +2,4 @@ package v3 import "errors" -var ErrNilParticipation = errors.New("Nil epoch participation in state") +var ErrNilParticipation = errors.New("nil epoch participation in state") diff --git a/proto/prysm/v1alpha1/cloners_test.go b/proto/prysm/v1alpha1/cloners_test.go index 08047dd7ab..99578f5b57 100644 --- a/proto/prysm/v1alpha1/cloners_test.go +++ b/proto/prysm/v1alpha1/cloners_test.go @@ -692,13 +692,6 @@ func genBlindedBeaconBlockBellatrix() *v1alpha1.BlindedBeaconBlockBellatrix { } } -func genSignedBlindedBeaconBlockBellatrix() *v1alpha1.SignedBlindedBeaconBlockBellatrix { - return &v1alpha1.SignedBlindedBeaconBlockBellatrix{ - Block: genBlindedBeaconBlockBellatrix(), - Signature: bytes(), - } -} - func genSyncCommitteeMessage() *v1alpha1.SyncCommitteeMessage { return &v1alpha1.SyncCommitteeMessage{ Slot: 424555, diff --git a/testing/spectest/shared/altair/fork/BUILD.bazel b/testing/spectest/shared/altair/fork/BUILD.bazel index 7384be563a..a490b41a46 100644 --- a/testing/spectest/shared/altair/fork/BUILD.bazel +++ b/testing/spectest/shared/altair/fork/BUILD.bazel @@ -13,7 +13,6 @@ go_library( "//beacon-chain/core/altair:go_default_library", "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/core/transition:go_default_library", - "//beacon-chain/state:go_default_library", "//beacon-chain/state/v1:go_default_library", "//beacon-chain/state/v2:go_default_library", "//config/params:go_default_library", diff --git a/testing/spectest/shared/altair/fork/transition.go b/testing/spectest/shared/altair/fork/transition.go index 2f07e1f507..5a97568434 100644 --- a/testing/spectest/shared/altair/fork/transition.go +++ b/testing/spectest/shared/altair/fork/transition.go @@ -8,7 +8,6 @@ import ( "github.com/golang/snappy" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/core/transition" - "github.com/prysmaticlabs/prysm/beacon-chain/state" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" stateAltair "github.com/prysmaticlabs/prysm/beacon-chain/state/v2" "github.com/prysmaticlabs/prysm/config/params" @@ -108,13 +107,12 @@ func RunForkTransitionTest(t *testing.T, config string) { beaconState, ok = st.(*v1.BeaconState) require.Equal(t, true, ok) } - altairState := state.BeaconState(beaconState) for _, b := range postforkBlocks { wsb, err := wrapper.WrappedSignedBeaconBlock(b) require.NoError(t, err) - st, err := transition.ExecuteStateTransition(ctx, altairState, wsb) + st, err := transition.ExecuteStateTransition(ctx, beaconState, wsb) require.NoError(t, err) - altairState, ok = st.(*stateAltair.BeaconState) + beaconState, ok = st.(*stateAltair.BeaconState) require.Equal(t, true, ok) } @@ -125,7 +123,7 @@ func RunForkTransitionTest(t *testing.T, config string) { postBeaconState := ðpb.BeaconStateAltair{} require.NoError(t, postBeaconState.UnmarshalSSZ(postBeaconStateSSZ), "Failed to unmarshal") - pbState, err := stateAltair.ProtobufBeaconState(altairState.CloneInnerState()) + pbState, err := stateAltair.ProtobufBeaconState(beaconState.CloneInnerState()) require.NoError(t, err) if !proto.Equal(pbState, postBeaconState) { t.Fatal("Post state does not match expected") diff --git a/testing/spectest/shared/bellatrix/fork/BUILD.bazel b/testing/spectest/shared/bellatrix/fork/BUILD.bazel index 8d717034f0..badee1fe86 100644 --- a/testing/spectest/shared/bellatrix/fork/BUILD.bazel +++ b/testing/spectest/shared/bellatrix/fork/BUILD.bazel @@ -13,7 +13,6 @@ go_library( "//beacon-chain/core/execution:go_default_library", "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/core/transition:go_default_library", - "//beacon-chain/state:go_default_library", "//beacon-chain/state/v2:go_default_library", "//beacon-chain/state/v3:go_default_library", "//config/params:go_default_library", diff --git a/testing/spectest/shared/bellatrix/fork/transition.go b/testing/spectest/shared/bellatrix/fork/transition.go index 0d3b56fd5d..8077d4a547 100644 --- a/testing/spectest/shared/bellatrix/fork/transition.go +++ b/testing/spectest/shared/bellatrix/fork/transition.go @@ -8,7 +8,6 @@ import ( "github.com/golang/snappy" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/core/transition" - "github.com/prysmaticlabs/prysm/beacon-chain/state" v2 "github.com/prysmaticlabs/prysm/beacon-chain/state/v2" v3 "github.com/prysmaticlabs/prysm/beacon-chain/state/v3" "github.com/prysmaticlabs/prysm/config/params" @@ -102,13 +101,13 @@ func RunForkTransitionTest(t *testing.T, config string) { beaconState, ok = st.(*v2.BeaconState) require.Equal(t, true, ok) } - postState := state.BeaconState(beaconState) + for _, b := range postforkBlocks { wsb, err := wrapper.WrappedSignedBeaconBlock(b) require.NoError(t, err) - st, err := transition.ExecuteStateTransition(ctx, postState, wsb) + st, err := transition.ExecuteStateTransition(ctx, beaconState, wsb) require.NoError(t, err) - postState, ok = st.(*v3.BeaconState) + beaconState, ok = st.(*v3.BeaconState) require.Equal(t, true, ok) } @@ -119,7 +118,7 @@ func RunForkTransitionTest(t *testing.T, config string) { postBeaconState := ðpb.BeaconStateBellatrix{} require.NoError(t, postBeaconState.UnmarshalSSZ(postBeaconStateSSZ), "Failed to unmarshal") - pbState, err := v3.ProtobufBeaconState(postState.CloneInnerState()) + pbState, err := v3.ProtobufBeaconState(beaconState.CloneInnerState()) require.NoError(t, err) require.DeepSSZEqual(t, pbState, postBeaconState) }) diff --git a/validator/accounts/BUILD.bazel b/validator/accounts/BUILD.bazel index ad6d3f5e30..d2b0873486 100644 --- a/validator/accounts/BUILD.bazel +++ b/validator/accounts/BUILD.bazel @@ -88,7 +88,6 @@ go_test( "//testing/assert:go_default_library", "//testing/mock:go_default_library", "//testing/require:go_default_library", - "//time:go_default_library", "//validator/accounts/iface:go_default_library", "//validator/accounts/petnames:go_default_library", "//validator/accounts/wallet:go_default_library", diff --git a/validator/accounts/accounts_backup.go b/validator/accounts/accounts_backup.go index fdcf9a6125..3b9244a03f 100644 --- a/validator/accounts/accounts_backup.go +++ b/validator/accounts/accounts_backup.go @@ -24,7 +24,7 @@ const ( ArchiveFilename = "backup.zip" ) -// BackupAccountsCli allows users to select validator accounts from their wallet +// Backup allows users to select validator accounts from their wallet // and export them as a backup.zip file containing the keys as EIP-2335 compliant // keystore.json files, which are compatible with importing in other Ethereum consensus clients. func (acm *AccountsCLIManager) Backup(ctx context.Context) error { diff --git a/validator/accounts/accounts_import.go b/validator/accounts/accounts_import.go index 96bde76015..3399353530 100644 --- a/validator/accounts/accounts_import.go +++ b/validator/accounts/accounts_import.go @@ -74,7 +74,7 @@ type ImportAccountsConfig struct { AccountPassword string } -// ImportAccountsCli can import external, EIP-2335 compliant keystore.json files as +// Import can import external, EIP-2335 compliant keystore.json files as // new accounts into the Prysm validator wallet. This uses the CLI to extract // values necessary to run the function. func (acm *AccountsCLIManager) Import(ctx context.Context) error { diff --git a/validator/accounts/accounts_import_test.go b/validator/accounts/accounts_import_test.go index c5d2df2d1e..840cefff8a 100644 --- a/validator/accounts/accounts_import_test.go +++ b/validator/accounts/accounts_import_test.go @@ -2,26 +2,22 @@ package accounts import ( "context" - "encoding/json" "fmt" "os" "path/filepath" "sort" "testing" - "github.com/google/uuid" "github.com/prysmaticlabs/prysm/config/params" "github.com/prysmaticlabs/prysm/crypto/bls" "github.com/prysmaticlabs/prysm/encoding/bytesutil" ethpbservice "github.com/prysmaticlabs/prysm/proto/eth/service" "github.com/prysmaticlabs/prysm/testing/assert" "github.com/prysmaticlabs/prysm/testing/require" - prysmTime "github.com/prysmaticlabs/prysm/time" "github.com/prysmaticlabs/prysm/validator/accounts/iface" "github.com/prysmaticlabs/prysm/validator/accounts/wallet" "github.com/prysmaticlabs/prysm/validator/keymanager" "github.com/prysmaticlabs/prysm/validator/keymanager/local" - keystorev4 "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4" ) func TestImportAccounts_NoPassword(t *testing.T) { @@ -51,7 +47,7 @@ func TestImportAccounts_NoPassword(t *testing.T) { importer, ok := km.(keymanager.Importer) require.Equal(t, true, ok) resp, err := ImportAccounts(context.Background(), &ImportAccountsConfig{ - Keystores: []*keymanager.Keystore{&keymanager.Keystore{}}, + Keystores: []*keymanager.Keystore{{}}, Importer: importer, AccountPassword: "", }) @@ -179,26 +175,3 @@ func Test_importPrivateKeyAsAccount(t *testing.T) { } // Returns the fullPath to the newly created keystore file. -func createKeystore(t *testing.T, path string) (*keymanager.Keystore, string) { - validatingKey, err := bls.RandKey() - require.NoError(t, err) - encryptor := keystorev4.New() - cryptoFields, err := encryptor.Encrypt(validatingKey.Marshal(), password) - require.NoError(t, err) - id, err := uuid.NewRandom() - require.NoError(t, err) - keystoreFile := &keymanager.Keystore{ - Crypto: cryptoFields, - ID: id.String(), - Pubkey: fmt.Sprintf("%x", validatingKey.PublicKey().Marshal()), - Version: encryptor.Version(), - Name: encryptor.Name(), - } - encoded, err := json.MarshalIndent(keystoreFile, "", "\t") - require.NoError(t, err) - // Write the encoded keystore to disk with the timestamp appended - createdAt := prysmTime.Now().Unix() - fullPath := filepath.Join(path, fmt.Sprintf(local.KeystoreFileNameFormat, createdAt)) - require.NoError(t, os.WriteFile(fullPath, encoded, os.ModePerm)) - return keystoreFile, fullPath -} diff --git a/validator/client/validator_test.go b/validator/client/validator_test.go index c2fcb5bd34..1f4ff20e49 100644 --- a/validator/client/validator_test.go +++ b/validator/client/validator_test.go @@ -1816,7 +1816,7 @@ func TestValidator_PushProposerSettings(t *testing.T) { client.EXPECT().ValidatorIndex( gomock.Any(), // ctx ðpb.ValidatorIndexRequest{PublicKey: keys[0][:]}, - ).Return(nil, errors.New("Could not find validator index for public key")) + ).Return(nil, errors.New("could not find validator index for public key")) config[keys[0]] = &validator_service_config.ProposerOption{ FeeRecipient: common.HexToAddress("0x046Fb65722E7b2455043BFEBf6177F1D2e9738D9"), } diff --git a/validator/keymanager/remote-web3signer/v1/requests_test.go b/validator/keymanager/remote-web3signer/v1/requests_test.go index f1218f250a..c8be79bf4c 100644 --- a/validator/keymanager/remote-web3signer/v1/requests_test.go +++ b/validator/keymanager/remote-web3signer/v1/requests_test.go @@ -7,7 +7,7 @@ import ( fieldparams "github.com/prysmaticlabs/prysm/config/fieldparams" validatorpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/validator-client" v1 "github.com/prysmaticlabs/prysm/validator/keymanager/remote-web3signer/v1" - mock "github.com/prysmaticlabs/prysm/validator/keymanager/remote-web3signer/v1/mock" + "github.com/prysmaticlabs/prysm/validator/keymanager/remote-web3signer/v1/mock" ) func TestGetAggregateAndProofSignRequest(t *testing.T) { diff --git a/validator/rpc/apimiddleware/structs_test.go b/validator/rpc/apimiddleware/structs_test.go index e0aa5f17a4..efdb142c23 100644 --- a/validator/rpc/apimiddleware/structs_test.go +++ b/validator/rpc/apimiddleware/structs_test.go @@ -13,7 +13,7 @@ import ( func TestListKeystores_JSONisEqual(t *testing.T) { middlewareResponse := &listKeystoresResponseJson{ Keystores: []*keystoreJson{ - &keystoreJson{ + { ValidatingPubkey: "0x0", DerivationPath: "m/44'/60'/0'/0/0", }, @@ -22,7 +22,7 @@ func TestListKeystores_JSONisEqual(t *testing.T) { protoResponse := &service.ListKeystoresResponse{ Data: []*service.ListKeystoresResponse_Keystore{ - &service.ListKeystoresResponse_Keystore{ + { ValidatingPubkey: make([]byte, fieldparams.BLSPubkeyLength), DerivationPath: "m/44'/60'/0'/0/0", }, @@ -53,7 +53,7 @@ func TestImportKeystores_JSONisEqual(t *testing.T) { importKeystoresResponse := &importKeystoresResponseJson{ Statuses: []*statusJson{ - &statusJson{ + { Status: "Error", Message: "a", }, @@ -62,7 +62,7 @@ func TestImportKeystores_JSONisEqual(t *testing.T) { protoImportKeystoresResponse := &service.ImportKeystoresResponse{ Data: []*service.ImportedKeystoreStatus{ - &service.ImportedKeystoreStatus{ + { Status: service.ImportedKeystoreStatus_ERROR, Message: "a", }, @@ -82,7 +82,7 @@ func TestDeleteKeystores_JSONisEqual(t *testing.T) { deleteKeystoresRequest := &deleteKeystoresRequestJson{} protoDeleteRequest := &service.DeleteKeystoresRequest{ - Pubkeys: [][]byte{[]byte{}}, + Pubkeys: [][]byte{{}}, } requestResp, err := areJsonPropertyNamesEqual(deleteKeystoresRequest, protoDeleteRequest) @@ -91,7 +91,7 @@ func TestDeleteKeystores_JSONisEqual(t *testing.T) { deleteKeystoresResponse := &deleteKeystoresResponseJson{ Statuses: []*statusJson{ - &statusJson{ + { Status: "Error", Message: "a", }, @@ -100,7 +100,7 @@ func TestDeleteKeystores_JSONisEqual(t *testing.T) { } protoDeleteResponse := &service.DeleteKeystoresResponse{ Data: []*service.DeletedKeystoreStatus{ - &service.DeletedKeystoreStatus{ + { Status: service.DeletedKeystoreStatus_ERROR, Message: "a", }, @@ -121,7 +121,7 @@ func TestDeleteKeystores_JSONisEqual(t *testing.T) { func TestListRemoteKeys_JSONisEqual(t *testing.T) { middlewareResponse := &listRemoteKeysResponseJson{ Keystores: []*remoteKeysListJson{ - &remoteKeysListJson{ + { Pubkey: "0x0", Url: "http://localhost:8080", Readonly: true, @@ -131,7 +131,7 @@ func TestListRemoteKeys_JSONisEqual(t *testing.T) { protoResponse := &service.ListRemoteKeysResponse{ Data: []*service.ListRemoteKeysResponse_Keystore{ - &service.ListRemoteKeysResponse_Keystore{ + { Pubkey: make([]byte, fieldparams.BLSPubkeyLength), Url: "http://localhost:8080", Readonly: true, @@ -153,7 +153,7 @@ func TestImportRemoteKeys_JSONisEqual(t *testing.T) { protoImportRequest := &service.ImportRemoteKeysRequest{ RemoteKeys: []*service.ImportRemoteKeysRequest_Keystore{ - &service.ImportRemoteKeysRequest_Keystore{ + { Pubkey: make([]byte, fieldparams.BLSPubkeyLength), Url: "http://localhost:8080", }, @@ -166,7 +166,7 @@ func TestImportRemoteKeys_JSONisEqual(t *testing.T) { importKeystoresResponse := &importRemoteKeysResponseJson{ Statuses: []*statusJson{ - &statusJson{ + { Status: "Error", Message: "a", }, @@ -175,7 +175,7 @@ func TestImportRemoteKeys_JSONisEqual(t *testing.T) { protoImportKeystoresResponse := &service.ImportRemoteKeysResponse{ Data: []*service.ImportedRemoteKeysStatus{ - &service.ImportedRemoteKeysStatus{ + { Status: service.ImportedRemoteKeysStatus_ERROR, Message: "a", }, @@ -195,7 +195,7 @@ func TestDeleteRemoteKeys_JSONisEqual(t *testing.T) { deleteKeystoresRequest := &deleteRemoteKeysRequestJson{} protoDeleteRequest := &service.DeleteRemoteKeysRequest{ - Pubkeys: [][]byte{[]byte{}}, + Pubkeys: [][]byte{{}}, } requestResp, err := areJsonPropertyNamesEqual(deleteKeystoresRequest, protoDeleteRequest) @@ -204,7 +204,7 @@ func TestDeleteRemoteKeys_JSONisEqual(t *testing.T) { deleteKeystoresResponse := &deleteRemoteKeysResponseJson{ Statuses: []*statusJson{ - &statusJson{ + { Status: "Error", Message: "a", }, @@ -212,7 +212,7 @@ func TestDeleteRemoteKeys_JSONisEqual(t *testing.T) { } protoDeleteResponse := &service.DeleteRemoteKeysResponse{ Data: []*service.DeletedRemoteKeysStatus{ - &service.DeletedRemoteKeysStatus{ + { Status: service.DeletedRemoteKeysStatus_ERROR, Message: "a", }, diff --git a/validator/rpc/standard_api_test.go b/validator/rpc/standard_api_test.go index 67fde0cd9b..76f239eaf6 100644 --- a/validator/rpc/standard_api_test.go +++ b/validator/rpc/standard_api_test.go @@ -620,7 +620,7 @@ func TestServer_ImportRemoteKeys(t *testing.T) { RemoteKeys: remoteKeys, }) expectedStatuses := []*ethpbservice.ImportedRemoteKeysStatus{ - ðpbservice.ImportedRemoteKeysStatus{ + { Status: ethpbservice.ImportedRemoteKeysStatus_IMPORTED, Message: fmt.Sprintf("Successfully added pubkey: %v", hexutil.Encode(bytevalue)), }, @@ -671,7 +671,7 @@ func TestServer_DeleteRemoteKeys(t *testing.T) { Pubkeys: [][]byte{bytevalue}, }) expectedStatuses := []*ethpbservice.DeletedRemoteKeysStatus{ - ðpbservice.DeletedRemoteKeysStatus{ + { Status: ethpbservice.DeletedRemoteKeysStatus_DELETED, Message: fmt.Sprintf("Successfully deleted pubkey: %v", hexutil.Encode(bytevalue)), },