diff --git a/fuzz/common.go b/fuzz/common.go index dfe40f74d56..ba66f998c0d 100644 --- a/fuzz/common.go +++ b/fuzz/common.go @@ -6,11 +6,11 @@ import ( "github.com/prysmaticlabs/prysm/shared/featureconfig" ) -const ENV_BLS = "BLS_ENABLED" +const EnvBls = "BLS_ENABLED" func init() { var blsEnabled bool - if value, exists := os.LookupEnv(ENV_BLS); exists { + if value, exists := os.LookupEnv(EnvBls); exists { blsEnabled = value == "1" } featureconfig.Init(&featureconfig.Flags{ diff --git a/shared/bls/blst/stub.go b/shared/bls/blst/stub.go index 0653cd03a1d..3044c9d66c0 100644 --- a/shared/bls/blst/stub.go +++ b/shared/bls/blst/stub.go @@ -51,7 +51,7 @@ func (p PublicKey) Aggregate(_ common.PublicKey) common.PublicKey { } // IsInfinite -- stub -func (s PublicKey) IsInfinite() bool { +func (p PublicKey) IsInfinite() bool { panic(err) } diff --git a/tools/analyzers/slicedirect/testdata/slice.go b/tools/analyzers/slicedirect/testdata/slice.go index 2025a2b1d66..4819bce567e 100644 --- a/tools/analyzers/slicedirect/testdata/slice.go +++ b/tools/analyzers/slicedirect/testdata/slice.go @@ -7,21 +7,21 @@ func NoIndexProvided() { } } -func StartIndexProvided_NoDiagnostic() { +func StartindexprovidedNodiagnostic() { x := []byte{'f', 'o', 'o'} y := x[1:] if len(y) == 3 { } } -func EndIndexProvided_NoDiagnostic() { +func EndindexprovidedNodiagnostic() { x := []byte{'f', 'o', 'o'} y := x[:2] if len(y) == 3 { } } -func BothIndicesProvided_NoDiagnostic() { +func BothindicesprovidedNodiagnostic() { x := []byte{'f', 'o', 'o'} y := x[1:2] if len(y) == 3 { diff --git a/validator/accounts/accounts.go b/validator/accounts/accounts.go index 4ccce2e308a..968f372dfb9 100644 --- a/validator/accounts/accounts.go +++ b/validator/accounts/accounts.go @@ -11,8 +11,8 @@ var ( ErrCouldNotInitializeKeymanager = "could not initialize keymanager" ) -// AccountsConfig specifies parameters to run to delete, enable, disable accounts. -type AccountsConfig struct { +// Config specifies parameters to run to delete, enable, disable accounts. +type Config struct { Wallet *wallet.Wallet Keymanager keymanager.IKeymanager DisablePublicKeys [][]byte diff --git a/validator/accounts/accounts_delete.go b/validator/accounts/accounts_delete.go index 4c3226d5821..1e681292923 100644 --- a/validator/accounts/accounts_delete.go +++ b/validator/accounts/accounts_delete.go @@ -85,7 +85,7 @@ func DeleteAccountCli(cliCtx *cli.Context) error { } } } - if err := DeleteAccount(cliCtx.Context, &AccountsConfig{ + if err := DeleteAccount(cliCtx.Context, &Config{ Wallet: w, Keymanager: keymanager, DeletePublicKeys: rawPublicKeys, @@ -100,7 +100,7 @@ func DeleteAccountCli(cliCtx *cli.Context) error { } // DeleteAccount deletes the accounts that the user requests to be deleted from the wallet. -func DeleteAccount(ctx context.Context, cfg *AccountsConfig) error { +func DeleteAccount(ctx context.Context, cfg *Config) error { switch cfg.Wallet.KeymanagerKind() { case keymanager.Remote: return errors.New("cannot delete accounts for a remote keymanager") diff --git a/validator/accounts/wallet/wallet.go b/validator/accounts/wallet/wallet.go index f3b3ef0a22b..81d28150b3e 100644 --- a/validator/accounts/wallet/wallet.go +++ b/validator/accounts/wallet/wallet.go @@ -28,7 +28,7 @@ const ( // NewWalletPasswordPromptText for wallet creation. NewWalletPasswordPromptText = "New wallet password" // WalletPasswordPromptText for wallet unlocking. - WalletPasswordPromptText = "Wallet password" + PasswordPromptText = "Wallet password" // ConfirmPasswordPromptText for confirming a wallet password. ConfirmPasswordPromptText = "Confirm password" // DefaultWalletPasswordFile used to store a wallet password with appropriate permissions @@ -179,7 +179,7 @@ func OpenWalletOrElseCli(cliCtx *cli.Context, otherwise func(cliCtx *cli.Context walletPassword, err := inputPassword( cliCtx, flags.WalletPasswordFileFlag, - WalletPasswordPromptText, + PasswordPromptText, false, /* Do not confirm password */ ValidateExistingPass, ) diff --git a/validator/db/kv/attester_protection.go b/validator/db/kv/attester_protection.go index c9d00c16899..45cf81e4b5e 100644 --- a/validator/db/kv/attester_protection.go +++ b/validator/db/kv/attester_protection.go @@ -50,9 +50,9 @@ var ( // AttestationHistoryForPubKey retrieves a list of attestation records for data // we have stored in the database for the given validator public key. -func (store *Store) AttestationHistoryForPubKey(ctx context.Context, pubKey [48]byte) ([]*AttestationRecord, error) { +func (s *Store) AttestationHistoryForPubKey(ctx context.Context, pubKey [48]byte) ([]*AttestationRecord, error) { records := make([]*AttestationRecord, 0) - err := store.view(func(tx *bolt.Tx) error { + err := s.view(func(tx *bolt.Tx) error { bucket := tx.Bucket(pubKeysBucket) pkBucket := bucket.Bucket(pubKey[:]) if pkBucket == nil { @@ -367,11 +367,11 @@ func (s *Store) AttestedPublicKeys(ctx context.Context) ([][48]byte, error) { // SigningRootAtTargetEpoch checks for an existing signing root at a specified // target epoch for a given validator public key. -func (store *Store) SigningRootAtTargetEpoch(ctx context.Context, pubKey [48]byte, target uint64) ([32]byte, error) { +func (s *Store) SigningRootAtTargetEpoch(ctx context.Context, pubKey [48]byte, target uint64) ([32]byte, error) { ctx, span := trace.StartSpan(ctx, "Validator.SigningRootAtTargetEpoch") defer span.End() var signingRoot [32]byte - err := store.view(func(tx *bolt.Tx) error { + err := s.view(func(tx *bolt.Tx) error { bucket := tx.Bucket(pubKeysBucket) pkBucket := bucket.Bucket(pubKey[:]) if pkBucket == nil { diff --git a/validator/keymanager/derived/keymanager.go b/validator/keymanager/derived/keymanager.go index f1b489393c1..c64296d754d 100644 --- a/validator/keymanager/derived/keymanager.go +++ b/validator/keymanager/derived/keymanager.go @@ -117,6 +117,6 @@ func (km *Keymanager) DeleteAccounts(ctx context.Context, publicKeys [][]byte) e // SubscribeAccountChanges creates an event subscription for a channel // to listen for public key changes at runtime, such as when new validator accounts // are imported into the keymanager while the validator process is running. -func (dr *Keymanager) SubscribeAccountChanges(pubKeysChan chan [][48]byte) event.Subscription { - return dr.importedKM.SubscribeAccountChanges(pubKeysChan) +func (km *Keymanager) SubscribeAccountChanges(pubKeysChan chan [][48]byte) event.Subscription { + return km.importedKM.SubscribeAccountChanges(pubKeysChan) } diff --git a/validator/keymanager/remote/keymanager.go b/validator/keymanager/remote/keymanager.go index 41b0a99663b..69d114f7cb1 100644 --- a/validator/keymanager/remote/keymanager.go +++ b/validator/keymanager/remote/keymanager.go @@ -231,7 +231,7 @@ func (km *Keymanager) Sign(ctx context.Context, req *validatorpb.SignRequest) (b // SubscribeAccountChanges is currently NOT IMPLEMENTED for the remote keymanager. // INVOKING THIS FUNCTION HAS NO EFFECT! -func (k *Keymanager) SubscribeAccountChanges(_ chan [][48]byte) event.Subscription { +func (km *Keymanager) SubscribeAccountChanges(_ chan [][48]byte) event.Subscription { return event.NewSubscription(func(i <-chan struct{}) error { return nil }) diff --git a/validator/slashing-protection/cli_export.go b/validator/slashing-protection/cli_export.go index 8ee73817bf2..404c81cfce4 100644 --- a/validator/slashing-protection/cli_export.go +++ b/validator/slashing-protection/cli_export.go @@ -2,6 +2,8 @@ package slashingprotection import ( "encoding/json" + "path/filepath" + "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/shared/cmd" "github.com/prysmaticlabs/prysm/shared/fileutil" @@ -10,7 +12,6 @@ import ( "github.com/prysmaticlabs/prysm/validator/flags" export "github.com/prysmaticlabs/prysm/validator/slashing-protection/local/standard-protection-format" "github.com/urfave/cli/v2" - "path/filepath" ) const ( diff --git a/validator/slashing-protection/local/standard-protection-format/export.go b/validator/slashing-protection/local/standard-protection-format/export.go index 50c2bd1686e..6dadd0f1cc4 100644 --- a/validator/slashing-protection/local/standard-protection-format/export.go +++ b/validator/slashing-protection/local/standard-protection-format/export.go @@ -27,7 +27,7 @@ func ExportStandardProtectionJSON(ctx context.Context, validatorDB db.Database) return nil, err } interchangeJSON.Metadata.GenesisValidatorsRoot = genesisRootHex - interchangeJSON.Metadata.InterchangeFormatVersion = format.INTERCHANGE_FORMAT_VERSION + interchangeJSON.Metadata.InterchangeFormatVersion = format.InterchangeFormatVersion // Extract the existing public keys in our database. proposedPublicKeys, err := validatorDB.ProposedPublicKeys(ctx) diff --git a/validator/slashing-protection/local/standard-protection-format/format/format.go b/validator/slashing-protection/local/standard-protection-format/format/format.go index 59f4de48232..31e5b14fb66 100644 --- a/validator/slashing-protection/local/standard-protection-format/format/format.go +++ b/validator/slashing-protection/local/standard-protection-format/format/format.go @@ -3,9 +3,9 @@ // is critical to allow safe interoperability between eth2 clients. package format -// INTERCHANGE_FORMAT_VERSION specified by https://eips.ethereum.org/EIPS/eip-3076. +// InterchangeFormatVersion specified by https://eips.ethereum.org/EIPS/eip-3076. // The version Prysm supports is version 5. -const INTERCHANGE_FORMAT_VERSION = "5" +const InterchangeFormatVersion = "5" // EIPSlashingProtectionFormat string representation of a standard // format for representing validator slashing protection db data. diff --git a/validator/slashing-protection/local/standard-protection-format/import.go b/validator/slashing-protection/local/standard-protection-format/import.go index c04c8876ae1..56dc2fc3526 100644 --- a/validator/slashing-protection/local/standard-protection-format/import.go +++ b/validator/slashing-protection/local/standard-protection-format/import.go @@ -139,11 +139,11 @@ func ImportStandardProtectionJSON(ctx context.Context, validatorDB db.Database, func validateMetadata(ctx context.Context, validatorDB db.Database, interchangeJSON *format.EIPSlashingProtectionFormat) error { // We need to ensure the version in the metadata field matches the one we support. version := interchangeJSON.Metadata.InterchangeFormatVersion - if version != format.INTERCHANGE_FORMAT_VERSION { + if version != format.InterchangeFormatVersion { return fmt.Errorf( "slashing protection JSON version '%s' is not supported, wanted '%s'", version, - format.INTERCHANGE_FORMAT_VERSION, + format.InterchangeFormatVersion, ) } diff --git a/validator/slashing-protection/local/standard-protection-format/import_test.go b/validator/slashing-protection/local/standard-protection-format/import_test.go index 557d963cced..3cdd2900060 100644 --- a/validator/slashing-protection/local/standard-protection-format/import_test.go +++ b/validator/slashing-protection/local/standard-protection-format/import_test.go @@ -210,7 +210,7 @@ func Test_validateMetadata(t *testing.T) { InterchangeFormatVersion string `json:"interchange_format_version"` GenesisValidatorsRoot string `json:"genesis_validators_root"` }{ - InterchangeFormatVersion: format.INTERCHANGE_FORMAT_VERSION, + InterchangeFormatVersion: format.InterchangeFormatVersion, GenesisValidatorsRoot: string(goodStr), }, }, @@ -250,7 +250,7 @@ func Test_validateMetadataGenesisValidatorRoot(t *testing.T) { InterchangeFormatVersion string `json:"interchange_format_version"` GenesisValidatorsRoot string `json:"genesis_validators_root"` }{ - InterchangeFormatVersion: format.INTERCHANGE_FORMAT_VERSION, + InterchangeFormatVersion: format.InterchangeFormatVersion, GenesisValidatorsRoot: string(goodStr), }, }, @@ -264,7 +264,7 @@ func Test_validateMetadataGenesisValidatorRoot(t *testing.T) { InterchangeFormatVersion string `json:"interchange_format_version"` GenesisValidatorsRoot string `json:"genesis_validators_root"` }{ - InterchangeFormatVersion: format.INTERCHANGE_FORMAT_VERSION, + InterchangeFormatVersion: format.InterchangeFormatVersion, GenesisValidatorsRoot: string(secondStr), }, }, diff --git a/validator/slashing-protection/local/standard-protection-format/round_trip_test.go b/validator/slashing-protection/local/standard-protection-format/round_trip_test.go index a94bac12d25..631ac2c920f 100644 --- a/validator/slashing-protection/local/standard-protection-format/round_trip_test.go +++ b/validator/slashing-protection/local/standard-protection-format/round_trip_test.go @@ -84,7 +84,7 @@ func TestImportExport_RoundTrip_SkippedAttestationEpochs(t *testing.T) { InterchangeFormatVersion string `json:"interchange_format_version"` GenesisValidatorsRoot string `json:"genesis_validators_root"` }{ - InterchangeFormatVersion: format.INTERCHANGE_FORMAT_VERSION, + InterchangeFormatVersion: format.InterchangeFormatVersion, GenesisValidatorsRoot: fmt.Sprintf("%#x", [32]byte{}), }, Data: []*format.ProtectionData{ diff --git a/validator/testing/protection_history.go b/validator/testing/protection_history.go index 242ff5eb746..4830d95a596 100644 --- a/validator/testing/protection_history.go +++ b/validator/testing/protection_history.go @@ -20,7 +20,7 @@ func MockSlashingProtectionJSON( ) (*format.EIPSlashingProtectionFormat, error) { standardProtectionFormat := &format.EIPSlashingProtectionFormat{} standardProtectionFormat.Metadata.GenesisValidatorsRoot = fmt.Sprintf("%#x", bytesutil.PadTo([]byte{32}, 32)) - standardProtectionFormat.Metadata.InterchangeFormatVersion = format.INTERCHANGE_FORMAT_VERSION + standardProtectionFormat.Metadata.InterchangeFormatVersion = format.InterchangeFormatVersion for i := 0; i < len(publicKeys); i++ { data := &format.ProtectionData{ Pubkey: fmt.Sprintf("%#x", publicKeys[i]),