diff --git a/.golangci.yml b/.golangci.yml index 732933852b02..0f395923e6fd 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,7 +4,6 @@ run: sort-results: true allow-parallel-runners: true exclude-dir: testutil/testdata - concurrency: 4 linters: disable-all: true @@ -54,6 +53,10 @@ issues: max-same-issues: 10000 linters-settings: + gofumpt: + # Choose whether to use the extra rules. + # Default: false + extra-rules: true dogsled: max-blank-identifiers: 3 maligned: diff --git a/baseapp/block_gas_test.go b/baseapp/block_gas_test.go index 86ec9664350e..5c79772d2c8c 100644 --- a/baseapp/block_gas_test.go +++ b/baseapp/block_gas_test.go @@ -190,7 +190,7 @@ func TestBaseApp_BlockGas(t *testing.T) { } } -func createTestTx(txConfig client.TxConfig, txBuilder client.TxBuilder, privs []cryptotypes.PrivKey, accNums []uint64, accSeqs []uint64, chainID string) (xauthsigning.Tx, []byte, error) { +func createTestTx(txConfig client.TxConfig, txBuilder client.TxBuilder, privs []cryptotypes.PrivKey, accNums, accSeqs []uint64, chainID string) (xauthsigning.Tx, []byte, error) { // First round: we gather all the signer infos. We use the "set empty // signature" hack to do that. var sigsV2 []signing.SignatureV2 diff --git a/client/account_retriever.go b/client/account_retriever.go index 24de5423e2ea..c1f2a060a87f 100644 --- a/client/account_retriever.go +++ b/client/account_retriever.go @@ -20,7 +20,7 @@ type AccountRetriever interface { GetAccount(clientCtx Context, addr sdk.AccAddress) (Account, error) GetAccountWithHeight(clientCtx Context, addr sdk.AccAddress) (Account, int64, error) EnsureExists(clientCtx Context, addr sdk.AccAddress) error - GetAccountNumberSequence(clientCtx Context, addr sdk.AccAddress) (accNum uint64, accSeq uint64, err error) + GetAccountNumberSequence(clientCtx Context, addr sdk.AccAddress) (accNum, accSeq uint64, err error) } var _ AccountRetriever = (*MockAccountRetriever)(nil) diff --git a/client/debug/main.go b/client/debug/main.go index f5a033c5279a..17dd0ba2a19f 100644 --- a/client/debug/main.go +++ b/client/debug/main.go @@ -90,7 +90,7 @@ func bytesToPubkey(bz []byte, keytype string) (cryptotypes.PubKey, bool) { // getPubKeyFromRawString returns a PubKey (PubKeyEd25519 or PubKeySecp256k1) by attempting // to decode the pubkey string from hex, base64, and finally bech32. If all // encodings fail, an error is returned. -func getPubKeyFromRawString(pkstr string, keytype string) (cryptotypes.PubKey, error) { +func getPubKeyFromRawString(pkstr, keytype string) (cryptotypes.PubKey, error) { // Try hex decoding bz, err := hex.DecodeString(pkstr) if err == nil { diff --git a/client/rpc/block.go b/client/rpc/block.go index 5b7540f6df14..93c710a857c5 100644 --- a/client/rpc/block.go +++ b/client/rpc/block.go @@ -47,7 +47,7 @@ func GetChainHeight(clientCtx client.Context) (int64, error) { // tx.height = 5 # all txs of the fifth block // // For more information, see the /subscribe CometBFT RPC endpoint documentation -func QueryBlocks(clientCtx client.Context, page, limit int, query string, orderBy string) (*sdk.SearchBlocksResult, error) { +func QueryBlocks(clientCtx client.Context, page, limit int, query, orderBy string) (*sdk.SearchBlocksResult, error) { node, err := clientCtx.GetNode() if err != nil { return nil, err diff --git a/client/test_helpers.go b/client/test_helpers.go index 214184b50f17..8c7c27a674c1 100644 --- a/client/test_helpers.go +++ b/client/test_helpers.go @@ -74,7 +74,7 @@ func (t TestAccountRetriever) EnsureExists(_ Context, addr sdk.AccAddress) error } // GetAccountNumberSequence implements AccountRetriever.GetAccountNumberSequence -func (t TestAccountRetriever) GetAccountNumberSequence(_ Context, addr sdk.AccAddress) (accNum uint64, accSeq uint64, err error) { +func (t TestAccountRetriever) GetAccountNumberSequence(_ Context, addr sdk.AccAddress) (accNum, accSeq uint64, err error) { acc, ok := t.Accounts[addr.String()] if !ok { return 0, 0, fmt.Errorf("account %s not found", addr) diff --git a/client/tx/factory.go b/client/tx/factory.go index d642991a4426..2586fcf5dc79 100644 --- a/client/tx/factory.go +++ b/client/tx/factory.go @@ -168,7 +168,7 @@ func (f Factory) WithFees(fees string) Factory { } // WithTips returns a copy of the Factory with an updated tip. -func (f Factory) WithTips(tip string, tipper string) Factory { +func (f Factory) WithTips(tip, tipper string) Factory { parsedTips, err := sdk.ParseCoinsNormalized(tip) if err != nil { panic(err) diff --git a/crypto/armor.go b/crypto/armor.go index b65854262387..6b1c2503f749 100644 --- a/crypto/armor.go +++ b/crypto/armor.go @@ -128,7 +128,7 @@ func unarmorBytes(armorStr, blockType string) (bz []byte, header map[string]stri // encrypt/decrypt with armor // Encrypt and armor the private key. -func EncryptArmorPrivKey(privKey cryptotypes.PrivKey, passphrase string, algo string) string { +func EncryptArmorPrivKey(privKey cryptotypes.PrivKey, passphrase, algo string) string { saltBytes, encBytes := encryptPrivKey(privKey, passphrase) header := map[string]string{ "kdf": "bcrypt", @@ -147,7 +147,7 @@ func EncryptArmorPrivKey(privKey cryptotypes.PrivKey, passphrase string, algo st // encrypt the given privKey with the passphrase using a randomly // generated salt and the xsalsa20 cipher. returns the salt and the // encrypted priv key. -func encryptPrivKey(privKey cryptotypes.PrivKey, passphrase string) (saltBytes []byte, encBytes []byte) { +func encryptPrivKey(privKey cryptotypes.PrivKey, passphrase string) (saltBytes, encBytes []byte) { saltBytes = crypto.CRandBytes(16) key, err := bcrypt.GenerateFromPassword(saltBytes, []byte(passphrase), BcryptSecurityParameter) if err != nil { @@ -161,7 +161,7 @@ func encryptPrivKey(privKey cryptotypes.PrivKey, passphrase string) (saltBytes [ } // UnarmorDecryptPrivKey returns the privkey byte slice, a string of the algo type, and an error -func UnarmorDecryptPrivKey(armorStr string, passphrase string) (privKey cryptotypes.PrivKey, algo string, err error) { +func UnarmorDecryptPrivKey(armorStr, passphrase string) (privKey cryptotypes.PrivKey, algo string, err error) { blockType, header, encBytes, err := DecodeArmor(armorStr) if err != nil { return privKey, "", err @@ -193,7 +193,7 @@ func UnarmorDecryptPrivKey(armorStr string, passphrase string) (privKey cryptoty return privKey, header[headerType], err } -func decryptPrivKey(saltBytes []byte, encBytes []byte, passphrase string) (privKey cryptotypes.PrivKey, err error) { +func decryptPrivKey(saltBytes, encBytes []byte, passphrase string) (privKey cryptotypes.PrivKey, err error) { key, err := bcrypt.GenerateFromPassword(saltBytes, []byte(passphrase), BcryptSecurityParameter) if err != nil { return privKey, errorsmod.Wrap(err, "error generating bcrypt key from passphrase") diff --git a/crypto/armor_test.go b/crypto/armor_test.go index 60ed5a495aee..23c5e629cf2b 100644 --- a/crypto/armor_test.go +++ b/crypto/armor_test.go @@ -50,7 +50,7 @@ func TestArmorUnarmorPrivKey(t *testing.T) { require.Contains(t, err.Error(), "unrecognized armor type") // armor key manually - encryptPrivKeyFn := func(privKey cryptotypes.PrivKey, passphrase string) (saltBytes []byte, encBytes []byte) { + encryptPrivKeyFn := func(privKey cryptotypes.PrivKey, passphrase string) (saltBytes, encBytes []byte) { saltBytes = cmtcrypto.CRandBytes(16) key, err := bcrypt.GenerateFromPassword(saltBytes, []byte(passphrase), crypto.BcryptSecurityParameter) require.NoError(t, err) diff --git a/crypto/hd/algo.go b/crypto/hd/algo.go index 0feb4ff49b47..58a5d4534240 100644 --- a/crypto/hd/algo.go +++ b/crypto/hd/algo.go @@ -26,12 +26,12 @@ const ( var Secp256k1 = secp256k1Algo{} type ( - DeriveFn func(mnemonic string, bip39Passphrase, hdPath string) ([]byte, error) + DeriveFn func(mnemonic, bip39Passphrase, hdPath string) ([]byte, error) GenerateFn func(bz []byte) types.PrivKey ) type WalletGenerator interface { - Derive(mnemonic string, bip39Passphrase, hdPath string) ([]byte, error) + Derive(mnemonic, bip39Passphrase, hdPath string) ([]byte, error) Generate(bz []byte) types.PrivKey } @@ -43,7 +43,7 @@ func (s secp256k1Algo) Name() PubKeyType { // Derive derives and returns the secp256k1 private key for the given seed and HD path. func (s secp256k1Algo) Derive() DeriveFn { - return func(mnemonic string, bip39Passphrase, hdPath string) ([]byte, error) { + return func(mnemonic, bip39Passphrase, hdPath string) ([]byte, error) { seed, err := bip39.NewSeedWithErrorChecking(mnemonic, bip39Passphrase) if err != nil { return nil, err diff --git a/crypto/hd/hdpath.go b/crypto/hd/hdpath.go index 4813053d0f63..7873ea0a2c0b 100644 --- a/crypto/hd/hdpath.go +++ b/crypto/hd/hdpath.go @@ -156,7 +156,7 @@ func (p BIP44Params) String() string { } // ComputeMastersFromSeed returns the master secret key's, and chain code. -func ComputeMastersFromSeed(seed []byte) (secret [32]byte, chainCode [32]byte) { +func ComputeMastersFromSeed(seed []byte) (secret, chainCode [32]byte) { curveIdentifier := []byte("Bitcoin seed") secret, chainCode = i64(curveIdentifier, seed) @@ -216,7 +216,7 @@ func DerivePrivateKeyForPath(privKeyBytes, chainCode [32]byte, path string) ([]b // It returns the new private key and new chain code. // For more information on hardened keys see: // - https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki -func derivePrivateKey(privKeyBytes [32]byte, chainCode [32]byte, index uint32, harden bool) ([32]byte, [32]byte) { +func derivePrivateKey(privKeyBytes, chainCode [32]byte, index uint32, harden bool) ([32]byte, [32]byte) { var data []byte if harden { @@ -244,7 +244,7 @@ func derivePrivateKey(privKeyBytes [32]byte, chainCode [32]byte, index uint32, h } // modular big endian addition -func addScalars(a []byte, b []byte) [32]byte { +func addScalars(a, b []byte) [32]byte { aInt := new(big.Int).SetBytes(a) bInt := new(big.Int).SetBytes(b) sInt := new(big.Int).Add(aInt, bInt) @@ -263,7 +263,7 @@ func uint32ToBytes(i uint32) []byte { } // i64 returns the two halfs of the SHA512 HMAC of key and data. -func i64(key []byte, data []byte) (il [32]byte, ir [32]byte) { +func i64(key, data []byte) (il, ir [32]byte) { mac := hmac.New(sha512.New, key) // sha512 does not err _, _ = mac.Write(data) diff --git a/crypto/keyring/keyring_test.go b/crypto/keyring/keyring_test.go index 451e900f0bd0..e89b0ff24652 100644 --- a/crypto/keyring/keyring_test.go +++ b/crypto/keyring/keyring_test.go @@ -1978,7 +1978,7 @@ func TestChangeBcrypt(t *testing.T) { require.NoError(t, err) } -func requireEqualRenamedKey(t *testing.T, key *Record, mnemonic *Record, nameMatch bool) { +func requireEqualRenamedKey(t *testing.T, key, mnemonic *Record, nameMatch bool) { if nameMatch { require.Equal(t, key.Name, mnemonic.Name) } diff --git a/crypto/keys/bcrypt/bcrypt.go b/crypto/keys/bcrypt/bcrypt.go index ab0ad4708eae..7e2b0d0dc190 100644 --- a/crypto/keys/bcrypt/bcrypt.go +++ b/crypto/keys/bcrypt/bcrypt.go @@ -85,7 +85,7 @@ type hashed struct { // cost. If the cost given is less than MinCost, the cost will be set to // DefaultCost, instead. Use CompareHashAndPassword, as defined in this package, // to compare the returned hashed password with its cleartext version. -func GenerateFromPassword(salt []byte, password []byte, cost uint32) ([]byte, error) { +func GenerateFromPassword(salt, password []byte, cost uint32) ([]byte, error) { if len(salt) != maxSaltSize { return nil, fmt.Errorf("salt len must be %v", maxSaltSize) } @@ -129,7 +129,7 @@ func Cost(hashedPassword []byte) (uint32, error) { return p.cost, nil } -func newFromPassword(salt []byte, password []byte, cost uint32) (*hashed, error) { +func newFromPassword(salt, password []byte, cost uint32) (*hashed, error) { if cost < MinCost { cost = DefaultCost } diff --git a/crypto/keys/ed25519/ed25519.go b/crypto/keys/ed25519/ed25519.go index d2dc54a32d94..37603f20f4d6 100644 --- a/crypto/keys/ed25519/ed25519.go +++ b/crypto/keys/ed25519/ed25519.go @@ -176,7 +176,7 @@ func (pubKey *PubKey) Bytes() []byte { return pubKey.Key } -func (pubKey *PubKey) VerifySignature(msg []byte, sig []byte) bool { +func (pubKey *PubKey) VerifySignature(msg, sig []byte) bool { // make sure we use the same algorithm to sign if len(sig) != SignatureSize { return false diff --git a/crypto/keys/internal/ecdsa/privkey.go b/crypto/keys/internal/ecdsa/privkey.go index 2aeedb1c4ddc..1d642ab9a498 100644 --- a/crypto/keys/internal/ecdsa/privkey.go +++ b/crypto/keys/internal/ecdsa/privkey.go @@ -39,7 +39,7 @@ func NormalizeS(sigS *big.Int) *big.Int { // signatureRaw will serialize signature to R || S. // R, S are padded to 32 bytes respectively. // code roughly copied from secp256k1_nocgo.go -func signatureRaw(r *big.Int, s *big.Int) []byte { +func signatureRaw(r, s *big.Int) []byte { rBytes := r.Bytes() sBytes := s.Bytes() sigBytes := make([]byte, 64) diff --git a/crypto/keys/internal/ecdsa/pubkey.go b/crypto/keys/internal/ecdsa/pubkey.go index a0b5df4401c7..1141baebec02 100644 --- a/crypto/keys/internal/ecdsa/pubkey.go +++ b/crypto/keys/internal/ecdsa/pubkey.go @@ -61,7 +61,7 @@ func (pk *PubKey) Bytes() []byte { // where the s integer component of the signature is in the // lower half of the curve order // 7/21/21 - expects raw encoded signature (fixed-width 64-bytes, R || S) -func (pk *PubKey) VerifySignature(msg []byte, sig []byte) bool { +func (pk *PubKey) VerifySignature(msg, sig []byte) bool { // check length for raw signature // which is two 32-byte padded big.Ints // concatenated diff --git a/crypto/keys/multisig/multisig.go b/crypto/keys/multisig/multisig.go index 892ae3b7b895..10f7d2e04000 100644 --- a/crypto/keys/multisig/multisig.go +++ b/crypto/keys/multisig/multisig.go @@ -100,7 +100,7 @@ func (m *LegacyAminoPubKey) VerifyMultisignature(getSignBytes multisigtypes.GetS // VerifySignature implements cryptotypes.PubKey VerifySignature method, // it panics because it can't handle MultiSignatureData // cf. https://github.com/cosmos/cosmos-sdk/issues/7109#issuecomment-686329936 -func (m *LegacyAminoPubKey) VerifySignature(msg []byte, sig []byte) bool { +func (m *LegacyAminoPubKey) VerifySignature(msg, sig []byte) bool { panic("not implemented") } diff --git a/crypto/keys/secp256k1/internal/secp256k1/secp256.go b/crypto/keys/secp256k1/internal/secp256k1/secp256.go index c9c01b3209af..d4e574da0d2b 100644 --- a/crypto/keys/secp256k1/internal/secp256k1/secp256.go +++ b/crypto/keys/secp256k1/internal/secp256k1/secp256.go @@ -67,7 +67,7 @@ var ( // The caller is responsible for ensuring that msg cannot be chosen // directly by an attacker. It is usually preferable to use a cryptographic // hash function on any input before handing it to this function. -func Sign(msg []byte, seckey []byte) ([]byte, error) { +func Sign(msg, seckey []byte) ([]byte, error) { if len(msg) != 32 { return nil, ErrInvalidMsgLen } @@ -102,7 +102,7 @@ func Sign(msg []byte, seckey []byte) ([]byte, error) { // msg must be the 32-byte hash of the message to be signed. // sig must be a 65-byte compact ECDSA signature containing the // recovery id as the last element. -func RecoverPubkey(msg []byte, sig []byte) ([]byte, error) { +func RecoverPubkey(msg, sig []byte) ([]byte, error) { if len(msg) != 32 { return nil, ErrInvalidMsgLen } diff --git a/crypto/keys/secp256k1/secp256k1_nocgo.go b/crypto/keys/secp256k1/secp256k1_nocgo.go index 4d7c21280df2..db66325f0bf4 100644 --- a/crypto/keys/secp256k1/secp256k1_nocgo.go +++ b/crypto/keys/secp256k1/secp256k1_nocgo.go @@ -24,7 +24,7 @@ func (privKey *PrivKey) Sign(msg []byte) ([]byte, error) { // VerifyBytes verifies a signature of the form R || S. // It rejects signatures which are not in lower-S form. -func (pubKey *PubKey) VerifySignature(msg []byte, sigStr []byte) bool { +func (pubKey *PubKey) VerifySignature(msg, sigStr []byte) bool { if len(sigStr) != 64 { return false } diff --git a/crypto/keys/secp256r1/pubkey.go b/crypto/keys/secp256r1/pubkey.go index 3b02e8b2e7be..cacec514c3d7 100644 --- a/crypto/keys/secp256r1/pubkey.go +++ b/crypto/keys/secp256r1/pubkey.go @@ -41,7 +41,7 @@ func (m *PubKey) Type() string { } // VerifySignature implements SDK PubKey interface. -func (m *PubKey) VerifySignature(msg []byte, sig []byte) bool { +func (m *PubKey) VerifySignature(msg, sig []byte) bool { return m.Key.VerifySignature(msg, sig) } diff --git a/crypto/ledger/encode_test.go b/crypto/ledger/encode_test.go index 2cc496198532..f9ce2418fd8b 100644 --- a/crypto/ledger/encode_test.go +++ b/crypto/ledger/encode_test.go @@ -9,7 +9,7 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" ) -func checkAminoJSON(t *testing.T, src interface{}, dst interface{}, isNil bool) { +func checkAminoJSON(t *testing.T, src, dst interface{}, isNil bool) { // Marshal to JSON bytes. js, err := cdc.MarshalJSON(src) require.Nil(t, err, "%+v", err) diff --git a/crypto/types/types.go b/crypto/types/types.go index 17d7acc94fd5..12fc6e39541f 100644 --- a/crypto/types/types.go +++ b/crypto/types/types.go @@ -11,7 +11,7 @@ type PubKey interface { Address() Address Bytes() []byte - VerifySignature(msg []byte, sig []byte) bool + VerifySignature(msg, sig []byte) bool Equals(PubKey) bool Type() string } diff --git a/crypto/xsalsa20symmetric/symmetric.go b/crypto/xsalsa20symmetric/symmetric.go index 0a2814e81737..e2ead2e2f58f 100644 --- a/crypto/xsalsa20symmetric/symmetric.go +++ b/crypto/xsalsa20symmetric/symmetric.go @@ -19,7 +19,7 @@ var ErrCiphertextDecrypt = errors.New("ciphertext decryption failed") // secret must be 32 bytes long. Use something like Sha256(Bcrypt(passphrase)) // The ciphertext is (secretbox.Overhead + 24) bytes longer than the plaintext. -func EncryptSymmetric(plaintext []byte, secret []byte) (ciphertext []byte) { +func EncryptSymmetric(plaintext, secret []byte) (ciphertext []byte) { if len(secret) != secretLen { panic(fmt.Sprintf("Secret must be 32 bytes long, got len %v", len(secret))) } @@ -36,7 +36,7 @@ func EncryptSymmetric(plaintext []byte, secret []byte) (ciphertext []byte) { // secret must be 32 bytes long. Use something like Sha256(Bcrypt(passphrase)) // The ciphertext is (secretbox.Overhead + 24) bytes longer than the plaintext. -func DecryptSymmetric(ciphertext []byte, secret []byte) (plaintext []byte, err error) { +func DecryptSymmetric(ciphertext, secret []byte) (plaintext []byte, err error) { if len(secret) != secretLen { panic(fmt.Sprintf("Secret must be 32 bytes long, got len %v", len(secret))) } diff --git a/internal/util.go b/internal/util.go index bcbcf821638d..97e3b4d1654f 100644 --- a/internal/util.go +++ b/internal/util.go @@ -4,7 +4,7 @@ import ( "fmt" ) -func CombineErrors(ret error, also error, desc string) error { +func CombineErrors(ret, also error, desc string) error { if also != nil { if ret != nil { ret = fmt.Errorf("%w; %v: %v", ret, desc, also) diff --git a/runtime/store.go b/runtime/store.go index ec86f99964ba..9374fb0c199f 100644 --- a/runtime/store.go +++ b/runtime/store.go @@ -136,14 +136,14 @@ func (s kvStoreAdapter) Has(key []byte) bool { return has } -func (s kvStoreAdapter) Set(key []byte, value []byte) { +func (s kvStoreAdapter) Set(key, value []byte) { err := s.store.Set(key, value) if err != nil { panic(err) } } -func (s kvStoreAdapter) Iterator(start []byte, end []byte) dbm.Iterator { +func (s kvStoreAdapter) Iterator(start, end []byte) dbm.Iterator { it, err := s.store.Iterator(start, end) if err != nil { panic(err) @@ -151,7 +151,7 @@ func (s kvStoreAdapter) Iterator(start []byte, end []byte) dbm.Iterator { return it } -func (s kvStoreAdapter) ReverseIterator(start []byte, end []byte) dbm.Iterator { +func (s kvStoreAdapter) ReverseIterator(start, end []byte) dbm.Iterator { it, err := s.store.ReverseIterator(start, end) if err != nil { panic(err) diff --git a/runtime/types.go b/runtime/types.go index c363d083abb7..db5ab446c32e 100644 --- a/runtime/types.go +++ b/runtime/types.go @@ -34,7 +34,7 @@ type AppI interface { LoadHeight(height int64) error // Exports the state of the application for a genesis file. - ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAddrs []string, modulesToExport []string) (types.ExportedApp, error) + ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAddrs, modulesToExport []string) (types.ExportedApp, error) // Helper for the simulation framework. SimulationManager() *module.SimulationManager diff --git a/server/api/server_test.go b/server/api/server_test.go index ca906dccdd48..34b51bf48990 100644 --- a/server/api/server_test.go +++ b/server/api/server_test.go @@ -126,7 +126,7 @@ func serializeProtoMessages(messages []proto.Message) [][]byte { } func (s *GRPCWebTestSuite) makeRequest( - verb string, method string, headers http.Header, body io.Reader, isText bool, + verb, method string, headers http.Header, body io.Reader, isText bool, ) (*http.Response, error) { val := s.network.Validators[0] contentType := "application/grpc-web" diff --git a/server/cmd/execute.go b/server/cmd/execute.go index c7842c690cb0..e42429cf9938 100644 --- a/server/cmd/execute.go +++ b/server/cmd/execute.go @@ -17,7 +17,7 @@ import ( // server context object with the appropriate server and client objects injected // into the underlying stdlib Context. It also handles adding core CLI flags, // specifically the logging flags. It returns an error upon execution failure. -func Execute(rootCmd *cobra.Command, envPrefix string, defaultHome string) error { +func Execute(rootCmd *cobra.Command, envPrefix, defaultHome string) error { // Create and set a client.Context on the command's Context. During the pre-run // of the root command, a default initialized client.Context is provided to // seed child command execution with values such as AccountRetriever, Keyring, diff --git a/server/mock/tx.go b/server/mock/tx.go index f9f1c394dc99..8201504095ec 100644 --- a/server/mock/tx.go +++ b/server/mock/tx.go @@ -37,7 +37,7 @@ func (t testPubKey) Address() cryptotypes.Address { return t.address.Bytes() } func (t testPubKey) Bytes() []byte { panic("not implemented") } -func (t testPubKey) VerifySignature(msg []byte, sig []byte) bool { panic("not implemented") } +func (t testPubKey) VerifySignature(msg, sig []byte) bool { panic("not implemented") } func (t testPubKey) Equals(key cryptotypes.PubKey) bool { panic("not implemented") } @@ -53,7 +53,7 @@ func (msg *KVStoreTx) GetSignaturesV2() (res []txsigning.SignatureV2, err error) return res, nil } -func (msg *KVStoreTx) VerifySignature(msgByte []byte, sig []byte) bool { +func (msg *KVStoreTx) VerifySignature(msgByte, sig []byte) bool { panic("implement me") } diff --git a/server/util_test.go b/server/util_test.go index ce5dfd521a80..0f60877508ff 100644 --- a/server/util_test.go +++ b/server/util_test.go @@ -294,7 +294,7 @@ func newPrecedenceCommon(t *testing.T) precedenceCommon { return retval } -func (v precedenceCommon) setAll(t *testing.T, setFlag *string, setEnvVar *string, setConfigFile *string) { +func (v precedenceCommon) setAll(t *testing.T, setFlag, setEnvVar, setConfigFile *string) { if setFlag != nil { if err := v.cmd.Flags().Set(v.flagName, *setFlag); err != nil { t.Fatalf("Failed setting flag %q", v.flagName) diff --git a/testutil/context.go b/testutil/context.go index 47753a773b36..3be3b2d9a4d8 100644 --- a/testutil/context.go +++ b/testutil/context.go @@ -17,7 +17,7 @@ import ( ) // DefaultContext creates a sdk.Context with a fresh MemDB that can be used in tests. -func DefaultContext(key storetypes.StoreKey, tkey storetypes.StoreKey) sdk.Context { +func DefaultContext(key, tkey storetypes.StoreKey) sdk.Context { db := dbm.NewMemDB() cms := store.NewCommitMultiStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics()) cms.MountStoreWithDB(key, storetypes.StoreTypeIAVL, db) @@ -37,7 +37,7 @@ type TestContext struct { CMS store.CommitMultiStore } -func DefaultContextWithDB(t *testing.T, key storetypes.StoreKey, tkey storetypes.StoreKey) TestContext { +func DefaultContextWithDB(t *testing.T, key, tkey storetypes.StoreKey) TestContext { db := dbm.NewMemDB() cms := store.NewCommitMultiStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics()) cms.MountStoreWithDB(key, storetypes.StoreTypeIAVL, db) diff --git a/testutil/network/util.go b/testutil/network/util.go index 247a7ffccf92..be118ef9512f 100644 --- a/testutil/network/util.go +++ b/testutil/network/util.go @@ -196,7 +196,7 @@ func initGenFiles(cfg Config, genAccounts []authtypes.GenesisAccount, genBalance return nil } -func writeFile(name string, dir string, contents []byte) error { +func writeFile(name, dir string, contents []byte) error { file := filepath.Join(dir, name) if err := os.MkdirAll(dir, 0o755); err != nil { diff --git a/testutil/rest.go b/testutil/rest.go index b3c52e3adbc3..93608482d195 100644 --- a/testutil/rest.go +++ b/testutil/rest.go @@ -60,7 +60,7 @@ func GetRequest(url string) ([]byte, error) { // PostRequest defines a wrapper around an HTTP POST request with a provided URL and data. // An error is returned if the request or reading the body fails. -func PostRequest(url string, contentType string, data []byte) ([]byte, error) { +func PostRequest(url, contentType string, data []byte) ([]byte, error) { res, err := http.Post(url, contentType, bytes.NewBuffer(data)) //nolint:gosec if err != nil { return nil, fmt.Errorf("error while sending post request: %w", err) diff --git a/testutil/sims/address_helpers.go b/testutil/sims/address_helpers.go index 8157d30586f6..52f1db8faffe 100644 --- a/testutil/sims/address_helpers.go +++ b/testutil/sims/address_helpers.go @@ -100,7 +100,7 @@ func CreateRandomAccounts(accNum int) []sdk.AccAddress { return testAddrs } -func TestAddr(addr string, bech string) (sdk.AccAddress, error) { +func TestAddr(addr, bech string) (sdk.AccAddress, error) { res, err := sdk.AccAddressFromHexUnsafe(addr) if err != nil { return nil, err diff --git a/testutil/sims/simulation_helpers.go b/testutil/sims/simulation_helpers.go index 055ba1439642..152703bf11ae 100644 --- a/testutil/sims/simulation_helpers.go +++ b/testutil/sims/simulation_helpers.go @@ -131,7 +131,7 @@ func GetSimulationLog(storeName string, sdr simtypes.StoreDecoderRegistry, kvAs, // DiffKVStores compares two KVstores and returns all the key/value pairs // that differ from one another. It also skips value comparison for a set of provided prefixes. -func DiffKVStores(a storetypes.KVStore, b storetypes.KVStore, prefixesToSkip [][]byte) (kvAs, kvBs []kv.Pair) { +func DiffKVStores(a, b storetypes.KVStore, prefixesToSkip [][]byte) (kvAs, kvBs []kv.Pair) { iterA := a.Iterator(nil, nil) defer iterA.Close() diff --git a/types/address/hash.go b/types/address/hash.go index 994bf722d6c1..ee7398518fb2 100644 --- a/types/address/hash.go +++ b/types/address/hash.go @@ -88,6 +88,6 @@ func Module(moduleName string, derivationKeys ...[]byte) []byte { // Derive derives a new address from the main `address` and a derivation `key`. // This function is used to create a sub accounts. To create a module accounts use the // `Module` function. -func Derive(address []byte, key []byte) []byte { +func Derive(address, key []byte) []byte { return Hash(conv.UnsafeBytesToStr(address), key) } diff --git a/types/address_test.go b/types/address_test.go index c463af85373a..c03cd733e3b1 100644 --- a/types/address_test.go +++ b/types/address_test.go @@ -44,7 +44,7 @@ var invalidStrs = []string{ types.Bech32PrefixConsPub + "6789", } -func (s *addressTestSuite) testMarshal(original interface{}, res interface{}, marshal func() ([]byte, error), unmarshal func([]byte) error) { +func (s *addressTestSuite) testMarshal(original, res interface{}, marshal func() ([]byte, error), unmarshal func([]byte) error) { bz, err := marshal() s.Require().Nil(err) s.Require().Nil(unmarshal(bz)) diff --git a/types/coin_benchmark_test.go b/types/coin_benchmark_test.go index 9730284c9b3d..8d8abaf14fc3 100644 --- a/types/coin_benchmark_test.go +++ b/types/coin_benchmark_test.go @@ -11,7 +11,7 @@ func coinName(suffix int) string { func BenchmarkCoinsAdditionIntersect(b *testing.B) { b.ReportAllocs() - benchmarkingFunc := func(numCoinsA int, numCoinsB int) func(b *testing.B) { + benchmarkingFunc := func(numCoinsA, numCoinsB int) func(b *testing.B) { return func(b *testing.B) { b.ReportAllocs() coinsA := Coins(make([]Coin, numCoinsA)) @@ -42,7 +42,7 @@ func BenchmarkCoinsAdditionIntersect(b *testing.B) { func BenchmarkCoinsAdditionNoIntersect(b *testing.B) { b.ReportAllocs() - benchmarkingFunc := func(numCoinsA int, numCoinsB int) func(b *testing.B) { + benchmarkingFunc := func(numCoinsA, numCoinsB int) func(b *testing.B) { return func(b *testing.B) { b.ReportAllocs() coinsA := Coins(make([]Coin, numCoinsA)) diff --git a/types/mempool/mempool_test.go b/types/mempool/mempool_test.go index 2d544192b87c..302b9a1e57b7 100644 --- a/types/mempool/mempool_test.go +++ b/types/mempool/mempool_test.go @@ -36,7 +36,7 @@ func (t testPubKey) Address() cryptotypes.Address { return t.address.Bytes() } func (t testPubKey) Bytes() []byte { panic("not implemented") } -func (t testPubKey) VerifySignature(msg []byte, sig []byte) bool { panic("not implemented") } +func (t testPubKey) VerifySignature(msg, sig []byte) bool { panic("not implemented") } func (t testPubKey) Equals(key cryptotypes.PubKey) bool { panic("not implemented") } diff --git a/types/mempool/priority_nonce_test.go b/types/mempool/priority_nonce_test.go index 12913998aa2b..6a3a62e13d86 100644 --- a/types/mempool/priority_nonce_test.go +++ b/types/mempool/priority_nonce_test.go @@ -464,7 +464,7 @@ func (s *MempoolTestSuite) TestRandomWalkTxs() { seed, s.iterations, duration.Milliseconds()) } -func genRandomTxs(seed int64, countTx int, countAccount int) (res []testTx) { +func genRandomTxs(seed int64, countTx, countAccount int) (res []testTx) { maxPriority := 100 r := rand.New(rand.NewSource(seed)) accounts := simtypes.RandomAccounts(r, countAccount) @@ -491,7 +491,7 @@ func genRandomTxs(seed int64, countTx int, countAccount int) (res []testTx) { // since there are multiple valid ordered graph traversals for a given set of txs strict // validation against the ordered txs generated from this function is not possible as written -func genOrderedTxs(seed int64, maxTx int, numAcc int) (ordered []testTx, shuffled []testTx) { +func genOrderedTxs(seed int64, maxTx, numAcc int) (ordered, shuffled []testTx) { r := rand.New(rand.NewSource(seed)) accountNonces := make(map[string]uint64) prange := 10 diff --git a/types/module/configurator.go b/types/module/configurator.go index c756d38af981..58c9747442d4 100644 --- a/types/module/configurator.go +++ b/types/module/configurator.go @@ -85,7 +85,7 @@ func (c *configurator) Error() error { } // NewConfigurator returns a new Configurator instance -func NewConfigurator(cdc codec.Codec, msgServer grpc.Server, queryServer grpc.Server) Configurator { +func NewConfigurator(cdc codec.Codec, msgServer, queryServer grpc.Server) Configurator { return &configurator{ cdc: cdc, msgServer: msgServer, diff --git a/types/query/collections_pagination.go b/types/query/collections_pagination.go index 633efa8ff3fe..065564e3e30e 100644 --- a/types/query/collections_pagination.go +++ b/types/query/collections_pagination.go @@ -258,7 +258,7 @@ func encodeCollKey[K, V any, C Collection[K, V]](coll C, key K) ([]byte, error) return buffer, err } -func getCollIter[K, V any, C Collection[K, V]](ctx context.Context, coll C, prefix []byte, start []byte, reverse bool) (collections.Iterator[K, V], error) { +func getCollIter[K, V any, C Collection[K, V]](ctx context.Context, coll C, prefix, start []byte, reverse bool) (collections.Iterator[K, V], error) { var end []byte if prefix != nil { start = append(prefix, start...) diff --git a/types/query/collections_pagination_test.go b/types/query/collections_pagination_test.go index ebb086453913..cf38540e9d36 100644 --- a/types/query/collections_pagination_test.go +++ b/types/query/collections_pagination_test.go @@ -48,7 +48,7 @@ func TestCollectionPagination(t *testing.T) { type test struct { req *PageRequest expResp *PageResponse - filter func(key uint64, value uint64) bool + filter func(key, value uint64) bool expResults []collections.KeyValue[uint64, uint64] wantErr error } @@ -101,7 +101,7 @@ func TestCollectionPagination(t *testing.T) { expResp: &PageResponse{ NextKey: encodeKey(5), }, - filter: func(key uint64, value uint64) bool { + filter: func(key, value uint64) bool { return key%2 == 0 }, expResults: []collections.KeyValue[uint64, uint64]{ @@ -118,7 +118,7 @@ func TestCollectionPagination(t *testing.T) { expResp: &PageResponse{ NextKey: encodeKey(7), }, - filter: func(key uint64, value uint64) bool { + filter: func(key, value uint64) bool { return key%2 == 0 }, expResults: []collections.KeyValue[uint64, uint64]{ diff --git a/types/query/filtered_pagination.go b/types/query/filtered_pagination.go index 108aab03fae8..dcb35530395c 100644 --- a/types/query/filtered_pagination.go +++ b/types/query/filtered_pagination.go @@ -20,7 +20,7 @@ import ( func FilteredPaginate( prefixStore types.KVStore, pageRequest *PageRequest, - onResult func(key []byte, value []byte, accumulate bool) (bool, error), + onResult func(key, value []byte, accumulate bool) (bool, error), ) (*PageResponse, error) { // if the PageRequest is nil, use default PageRequest if pageRequest == nil { diff --git a/types/query/filtered_pagination_test.go b/types/query/filtered_pagination_test.go index 69db71d2b169..81bc0d1f78bb 100644 --- a/types/query/filtered_pagination_test.go +++ b/types/query/filtered_pagination_test.go @@ -195,7 +195,7 @@ func (s *paginationTestSuite) TestFilteredPaginate() { accountStore := prefix.NewStore(balancesStore, address.MustLengthPrefix(addr1)) var balResult sdk.Coins - pageRes, err := query.FilteredPaginate(accountStore, pageReq, func(key []byte, value []byte, accumulate bool) (bool, error) { + pageRes, err := query.FilteredPaginate(accountStore, pageReq, func(key, value []byte, accumulate bool) (bool, error) { var amount math.Int err := amount.Unmarshal(value) if err != nil { @@ -226,7 +226,7 @@ func execFilterPaginate(store storetypes.KVStore, pageReq *query.PageRequest, ap accountStore := prefix.NewStore(balancesStore, address.MustLengthPrefix(addr1)) var balResult sdk.Coins - res, err = query.FilteredPaginate(accountStore, pageReq, func(key []byte, value []byte, accumulate bool) (bool, error) { + res, err = query.FilteredPaginate(accountStore, pageReq, func(key, value []byte, accumulate bool) (bool, error) { var amount math.Int err := amount.Unmarshal(value) if err != nil { @@ -268,7 +268,7 @@ func (s *paginationTestSuite) TestFilteredPaginationsNextKey() { accountStore := prefix.NewStore(balancesStore, address.MustLengthPrefix(addr1)) var balResult sdk.Coins - res, err = query.FilteredPaginate(accountStore, pageReq, func(key []byte, value []byte, accumulate bool) (bool, error) { + res, err = query.FilteredPaginate(accountStore, pageReq, func(key, value []byte, accumulate bool) (bool, error) { var amount math.Int err := amount.Unmarshal(value) if err != nil { diff --git a/types/query/fuzz_test.go b/types/query/fuzz_test.go index fda80367b408..e41afd1c1df3 100644 --- a/types/query/fuzz_test.go +++ b/types/query/fuzz_test.go @@ -85,7 +85,7 @@ func FuzzPagination(f *testing.F) { authStore := suite.ctx.KVStore(suite.app.UnsafeFindStoreKey(types.StoreKey)) balancesStore := prefix.NewStore(authStore, types.BalancesPrefix) accountStore := prefix.NewStore(balancesStore, address.MustLengthPrefix(addr1)) - _, _ = query.Paginate(accountStore, req.Pagination, func(key []byte, value []byte) error { + _, _ = query.Paginate(accountStore, req.Pagination, func(key, value []byte) error { var amount math.Int err := amount.Unmarshal(value) if err != nil { diff --git a/types/query/pagination.go b/types/query/pagination.go index 676f5bc2a36e..3eeb3a297aec 100644 --- a/types/query/pagination.go +++ b/types/query/pagination.go @@ -52,7 +52,7 @@ func ParsePagination(pageReq *PageRequest) (page, limit int, err error) { func Paginate( prefixStore types.KVStore, pageRequest *PageRequest, - onResult func(key []byte, value []byte) error, + onResult func(key, value []byte) error, ) (*PageResponse, error) { // if the PageRequest is nil, use default PageRequest if pageRequest == nil { diff --git a/types/query/pagination_test.go b/types/query/pagination_test.go index 025806e05b88..bfb745586596 100644 --- a/types/query/pagination_test.go +++ b/types/query/pagination_test.go @@ -354,7 +354,7 @@ func (s *paginationTestSuite) TestPaginate() { authStore := s.ctx.KVStore(s.app.UnsafeFindStoreKey(types.StoreKey)) balancesStore := prefix.NewStore(authStore, types.BalancesPrefix) accountStore := prefix.NewStore(balancesStore, address.MustLengthPrefix(addr1)) - pageRes, err := query.Paginate(accountStore, request.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(accountStore, request.Pagination, func(key, value []byte) error { var amount math.Int err := amount.Unmarshal(value) if err != nil { diff --git a/types/result.go b/types/result.go index 3d5e20080e4a..56e3ef7879ed 100644 --- a/types/result.go +++ b/types/result.go @@ -230,7 +230,7 @@ func WrapServiceResult(ctx Context, res proto.Message, err error) (*Result, erro } // calculate total pages in an overflow safe manner -func calcTotalPages(totalCount int64, limit int64) int64 { +func calcTotalPages(totalCount, limit int64) int64 { totalPages := int64(0) if totalCount != 0 && limit != 0 { if totalCount%limit > 0 { diff --git a/types/staking.go b/types/staking.go index 44053ca30fb5..38019d46a422 100644 --- a/types/staking.go +++ b/types/staking.go @@ -25,7 +25,7 @@ var ( ) // TokensToConsensusPower - convert input tokens to potential consensus-engine power -func TokensToConsensusPower(tokens sdkmath.Int, powerReduction sdkmath.Int) int64 { +func TokensToConsensusPower(tokens, powerReduction sdkmath.Int) int64 { return (tokens.Quo(powerReduction)).Int64() } diff --git a/types/utils.go b/types/utils.go index 340014009039..84963809382b 100644 --- a/types/utils.go +++ b/types/utils.go @@ -127,7 +127,7 @@ func AppendLengthPrefixedBytes(args ...[]byte) []byte { } // ParseLengthPrefixedBytes panics when store key length is not equal to the given length. -func ParseLengthPrefixedBytes(key []byte, startIndex int, sliceLength int) ([]byte, int) { +func ParseLengthPrefixedBytes(key []byte, startIndex, sliceLength int) ([]byte, int) { neededLength := startIndex + sliceLength endIndex := neededLength - 1 kv.AssertKeyAtLeastLength(key, neededLength) diff --git a/x/auth/ante/testutil_test.go b/x/auth/ante/testutil_test.go index c6207c39aea7..76cf9d39c9dd 100644 --- a/x/auth/ante/testutil_test.go +++ b/x/auth/ante/testutil_test.go @@ -192,7 +192,7 @@ func (suite *AnteTestSuite) RunTestCase(t *testing.T, tc TestCase, args TestCase // CreateTestTx is a helper function to create a tx given multiple inputs. func (suite *AnteTestSuite) CreateTestTx( ctx sdk.Context, privs []cryptotypes.PrivKey, - accNums []uint64, accSeqs []uint64, + accNums, accSeqs []uint64, chainID string, signMode signing.SignMode, ) (xauthsigning.Tx, error) { // First round: we gather all the signer infos. We use the "set empty diff --git a/x/auth/client/testutil/helpers.go b/x/auth/client/testutil/helpers.go index cbaff7f77a0f..106c4a76d7b4 100644 --- a/x/auth/client/testutil/helpers.go +++ b/x/auth/client/testutil/helpers.go @@ -54,7 +54,7 @@ func TxValidateSignaturesExec(clientCtx client.Context, filename string) (testut return clitestutil.ExecTestCLICmd(clientCtx, cli.GetValidateSignaturesCommand(), args) } -func TxMultiSignExec(clientCtx client.Context, from string, filename string, extraArgs ...string) (testutil.BufferWriter, error) { +func TxMultiSignExec(clientCtx client.Context, from, filename string, extraArgs ...string) (testutil.BufferWriter, error) { args := []string{ fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID), filename, @@ -97,7 +97,7 @@ func QueryAccountExec(clientCtx client.Context, address fmt.Stringer, extraArgs return clitestutil.ExecTestCLICmd(clientCtx, cli.GetAccountCmd(), append(args, extraArgs...)) } -func TxMultiSignBatchExec(clientCtx client.Context, filename string, from string, sigFile1 string, sigFile2 string, extraArgs ...string) (testutil.BufferWriter, error) { +func TxMultiSignBatchExec(clientCtx client.Context, filename, from, sigFile1, sigFile2 string, extraArgs ...string) (testutil.BufferWriter, error) { args := []string{ fmt.Sprintf("--%s=%s", flags.FlagKeyringBackend, keyring.BackendTest), filename, diff --git a/x/auth/keeper/keeper.go b/x/auth/keeper/keeper.go index a59785039623..a758a70eb0a3 100644 --- a/x/auth/keeper/keeper.go +++ b/x/auth/keeper/keeper.go @@ -80,7 +80,7 @@ var _ AccountKeeperI = &AccountKeeper{} // may use auth.Keeper to access the accounts permissions map. func NewAccountKeeper( cdc codec.BinaryCodec, storeService store.KVStoreService, proto func() sdk.AccountI, - maccPerms map[string][]string, bech32Prefix string, authority string, + maccPerms map[string][]string, bech32Prefix, authority string, ) AccountKeeper { permAddrs := make(map[string]types.PermissionsForAddress) for name, perms := range maccPerms { diff --git a/x/auth/migrations/v2/store_test.go b/x/auth/migrations/v2/store_test.go index 803a33f337eb..d543be922b4c 100644 --- a/x/auth/migrations/v2/store_test.go +++ b/x/auth/migrations/v2/store_test.go @@ -641,7 +641,7 @@ func TestMigrateVestingAccounts(t *testing.T) { } } -func trackingCorrected(ctx sdk.Context, t *testing.T, ak keeper.AccountKeeper, addr sdk.AccAddress, expDelVesting sdk.Coins, expDelFree sdk.Coins) { +func trackingCorrected(ctx sdk.Context, t *testing.T, ak keeper.AccountKeeper, addr sdk.AccAddress, expDelVesting, expDelFree sdk.Coins) { t.Helper() baseAccount := ak.GetAccount(ctx, addr) vDA, ok := baseAccount.(exported.VestingAccount) diff --git a/x/auth/testutil/util.go b/x/auth/testutil/util.go index 93cd30355eb2..b144a7f5d80d 100644 --- a/x/auth/testutil/util.go +++ b/x/auth/testutil/util.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" ) -func AssertError(t *testing.T, err error, expectedErr error, expectedErrMsg string) { +func AssertError(t *testing.T, err, expectedErr error, expectedErrMsg string) { switch { case expectedErr != nil: require.ErrorIs(t, err, expectedErr) diff --git a/x/auth/types/credentials.go b/x/auth/types/credentials.go index 6d37c98b30d2..83cd63dd2982 100644 --- a/x/auth/types/credentials.go +++ b/x/auth/types/credentials.go @@ -55,7 +55,7 @@ func (m *ModuleCredential) Bytes() []byte { } // VerifySignature returns always false, making the account unclaimable -func (m *ModuleCredential) VerifySignature(_ []byte, _ []byte) bool { +func (m *ModuleCredential) VerifySignature(_, _ []byte) bool { return false } diff --git a/x/auth/vesting/types/expected_keepers.go b/x/auth/vesting/types/expected_keepers.go index 5705eea30baf..6818f5094bb9 100644 --- a/x/auth/vesting/types/expected_keepers.go +++ b/x/auth/vesting/types/expected_keepers.go @@ -8,6 +8,6 @@ import ( // for creating vesting accounts with funds. type BankKeeper interface { IsSendEnabledCoins(ctx sdk.Context, coins ...sdk.Coin) error - SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error + SendCoins(ctx sdk.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error BlockedAddr(addr sdk.AccAddress) bool } diff --git a/x/authz/keeper/keeper.go b/x/authz/keeper/keeper.go index 501da89035e9..4ca846406048 100644 --- a/x/authz/keeper/keeper.go +++ b/x/authz/keeper/keeper.go @@ -58,7 +58,7 @@ func (k Keeper) getGrant(ctx sdk.Context, skey []byte) (grant authz.Grant, found return grant, true } -func (k Keeper) update(ctx sdk.Context, grantee sdk.AccAddress, granter sdk.AccAddress, updated authz.Authorization) error { +func (k Keeper) update(ctx sdk.Context, grantee, granter sdk.AccAddress, updated authz.Authorization) error { skey := grantStoreKey(grantee, granter, updated.MsgTypeURL()) grant, found := k.getGrant(ctx, skey) if !found { @@ -205,7 +205,7 @@ func (k Keeper) SaveGrant(ctx sdk.Context, grantee, granter sdk.AccAddress, auth // DeleteGrant revokes any authorization for the provided message type granted to the grantee // by the granter. -func (k Keeper) DeleteGrant(ctx sdk.Context, grantee sdk.AccAddress, granter sdk.AccAddress, msgType string) error { +func (k Keeper) DeleteGrant(ctx sdk.Context, grantee, granter sdk.AccAddress, msgType string) error { store := ctx.KVStore(k.storeKey) skey := grantStoreKey(grantee, granter, msgType) grant, found := k.getGrant(ctx, skey) @@ -230,7 +230,7 @@ func (k Keeper) DeleteGrant(ctx sdk.Context, grantee sdk.AccAddress, granter sdk } // GetAuthorizations Returns list of `Authorizations` granted to the grantee by the granter. -func (k Keeper) GetAuthorizations(ctx sdk.Context, grantee sdk.AccAddress, granter sdk.AccAddress) ([]authz.Authorization, error) { +func (k Keeper) GetAuthorizations(ctx sdk.Context, grantee, granter sdk.AccAddress) ([]authz.Authorization, error) { store := ctx.KVStore(k.storeKey) key := grantStoreKey(grantee, granter, "") iter := storetypes.KVStorePrefixIterator(store, key) @@ -259,7 +259,7 @@ func (k Keeper) GetAuthorizations(ctx sdk.Context, grantee sdk.AccAddress, grant // - No grant is found. // - A grant is found, but it is expired. // - There was an error getting the authorization from the grant. -func (k Keeper) GetAuthorization(ctx sdk.Context, grantee sdk.AccAddress, granter sdk.AccAddress, msgType string) (authz.Authorization, *time.Time) { +func (k Keeper) GetAuthorization(ctx sdk.Context, grantee, granter sdk.AccAddress, msgType string) (authz.Authorization, *time.Time) { grant, found := k.getGrant(ctx, grantStoreKey(grantee, granter, msgType)) if !found || (grant.Expiration != nil && grant.Expiration.Before(ctx.BlockHeader().Time)) { return nil, nil @@ -278,7 +278,7 @@ func (k Keeper) GetAuthorization(ctx sdk.Context, grantee sdk.AccAddress, grante // It should not be used in query or msg services without charging additional gas. // The iteration stops when the handler function returns true or the iterator exhaust. func (k Keeper) IterateGrants(ctx sdk.Context, - handler func(granterAddr sdk.AccAddress, granteeAddr sdk.AccAddress, grant authz.Grant) bool, + handler func(granterAddr, granteeAddr sdk.AccAddress, grant authz.Grant) bool, ) { store := ctx.KVStore(k.storeKey) iter := storetypes.KVStorePrefixIterator(store, GrantKey) @@ -308,7 +308,7 @@ func (k Keeper) getGrantQueueItem(ctx sdk.Context, expiration time.Time, granter } func (k Keeper) setGrantQueueItem(ctx sdk.Context, expiration time.Time, - granter sdk.AccAddress, grantee sdk.AccAddress, queueItems *authz.GrantQueueItem, + granter, grantee sdk.AccAddress, queueItems *authz.GrantQueueItem, ) error { store := ctx.KVStore(k.storeKey) bz, err := k.cdc.Marshal(queueItems) diff --git a/x/authz/keeper/keys.go b/x/authz/keeper/keys.go index 27aec0b5e029..83eabef777e7 100644 --- a/x/authz/keeper/keys.go +++ b/x/authz/keeper/keys.go @@ -29,7 +29,7 @@ const StoreKey = authz.ModuleName // Items are stored with the following key: values // // - 0x01: Grant -func grantStoreKey(grantee sdk.AccAddress, granter sdk.AccAddress, msgType string) []byte { +func grantStoreKey(grantee, granter sdk.AccAddress, msgType string) []byte { m := conv.UnsafeStrToBytes(msgType) granter = address.MustLengthPrefix(granter) grantee = address.MustLengthPrefix(grantee) @@ -79,7 +79,7 @@ func parseGrantQueueKey(key []byte) (time.Time, sdk.AccAddress, sdk.AccAddress, // Key format is: // // 0x02: GrantQueueItem -func GrantQueueKey(expiration time.Time, granter sdk.AccAddress, grantee sdk.AccAddress) []byte { +func GrantQueueKey(expiration time.Time, granter, grantee sdk.AccAddress) []byte { exp := sdk.FormatTimeBytes(expiration) granter = address.MustLengthPrefix(granter) grantee = address.MustLengthPrefix(grantee) diff --git a/x/authz/migrations/v2/keys.go b/x/authz/migrations/v2/keys.go index fceced95f1c9..328edf3c88c6 100644 --- a/x/authz/migrations/v2/keys.go +++ b/x/authz/migrations/v2/keys.go @@ -23,7 +23,7 @@ var ( // Key format is // // - 0x02: GrantQueueItem -func GrantQueueKey(expiration time.Time, granter sdk.AccAddress, grantee sdk.AccAddress) []byte { +func GrantQueueKey(expiration time.Time, granter, grantee sdk.AccAddress) []byte { exp := sdk.FormatTimeBytes(expiration) granter = address.MustLengthPrefix(granter) grantee = address.MustLengthPrefix(grantee) @@ -41,7 +41,7 @@ func GrantQueueKey(expiration time.Time, granter sdk.AccAddress, grantee sdk.Acc // Items are stored with the following key: values // // - 0x01: Grant -func GrantStoreKey(grantee sdk.AccAddress, granter sdk.AccAddress, msgType string) []byte { +func GrantStoreKey(grantee, granter sdk.AccAddress, msgType string) []byte { m := conv.UnsafeStrToBytes(msgType) granter = address.MustLengthPrefix(granter) grantee = address.MustLengthPrefix(grantee) diff --git a/x/authz/msgs.go b/x/authz/msgs.go index 792120d6de71..32a598f127d0 100644 --- a/x/authz/msgs.go +++ b/x/authz/msgs.go @@ -30,7 +30,7 @@ var ( // NewMsgGrant creates a new MsgGrant // //nolint:interfacer -func NewMsgGrant(granter sdk.AccAddress, grantee sdk.AccAddress, a Authorization, expiration *time.Time) (*MsgGrant, error) { +func NewMsgGrant(granter, grantee sdk.AccAddress, a Authorization, expiration *time.Time) (*MsgGrant, error) { m := &MsgGrant{ Granter: granter.String(), Grantee: grantee.String(), @@ -111,7 +111,7 @@ func (msg MsgGrant) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { // NewMsgRevoke creates a new MsgRevoke // //nolint:interfacer -func NewMsgRevoke(granter sdk.AccAddress, grantee sdk.AccAddress, msgTypeURL string) MsgRevoke { +func NewMsgRevoke(granter, grantee sdk.AccAddress, msgTypeURL string) MsgRevoke { return MsgRevoke{ Granter: granter.String(), Grantee: grantee.String(), diff --git a/x/bank/keeper/grpc_query.go b/x/bank/keeper/grpc_query.go index 49fa628090c7..c6e3b6437ed6 100644 --- a/x/bank/keeper/grpc_query.go +++ b/x/bank/keeper/grpc_query.go @@ -244,7 +244,7 @@ func (k BaseKeeper) DenomOwners( pageRes, err := query.FilteredPaginate( denomPrefixStore, req.Pagination, - func(key []byte, _ []byte, accumulate bool) (bool, error) { + func(key, _ []byte, accumulate bool) (bool, error) { if accumulate { address, _, err := types.AddressAndDenomFromBalancesStore(key) if err != nil { diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index 69e0584ed8f5..28bf17fe8093 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -78,11 +78,11 @@ func newIbcCoin(amt int64) sdk.Coin { return sdk.NewInt64Coin(getIBCDenom(ibcPath, ibcBaseDenom), amt) } -func getIBCDenom(path string, baseDenom string) string { +func getIBCDenom(path, baseDenom string) string { return fmt.Sprintf("%s/%s", "ibc", hex.EncodeToString(getIBCHash(path, baseDenom))) } -func getIBCHash(path string, baseDenom string) []byte { +func getIBCHash(path, baseDenom string) []byte { hash := sha256.Sum256([]byte(path + "/" + baseDenom)) return hash[:] } @@ -173,7 +173,7 @@ func (suite *KeeperTestSuite) mockBurnCoins(moduleAcc *authtypes.ModuleAccount) suite.authKeeper.EXPECT().GetAccount(suite.ctx, moduleAcc.GetAddress()).Return(moduleAcc) } -func (suite *KeeperTestSuite) mockSendCoinsFromModuleToModule(sender *authtypes.ModuleAccount, receiver *authtypes.ModuleAccount) { +func (suite *KeeperTestSuite) mockSendCoinsFromModuleToModule(sender, receiver *authtypes.ModuleAccount) { suite.authKeeper.EXPECT().GetModuleAddress(sender.Name).Return(sender.GetAddress()) suite.authKeeper.EXPECT().GetModuleAccount(suite.ctx, receiver.Name).Return(receiver) suite.authKeeper.EXPECT().GetAccount(suite.ctx, sender.GetAddress()).Return(sender) @@ -213,7 +213,7 @@ func (suite *KeeperTestSuite) mockSpendableCoins(ctx sdk.Context, acc sdk.Accoun suite.authKeeper.EXPECT().GetAccount(ctx, acc.GetAddress()).Return(acc) } -func (suite *KeeperTestSuite) mockDelegateCoins(ctx sdk.Context, acc sdk.AccountI, mAcc sdk.AccountI) { +func (suite *KeeperTestSuite) mockDelegateCoins(ctx sdk.Context, acc, mAcc sdk.AccountI) { vacc, ok := acc.(banktypes.VestingAccount) if ok { suite.authKeeper.EXPECT().SetAccount(ctx, vacc) @@ -222,7 +222,7 @@ func (suite *KeeperTestSuite) mockDelegateCoins(ctx sdk.Context, acc sdk.Account suite.authKeeper.EXPECT().GetAccount(ctx, mAcc.GetAddress()).Return(mAcc) } -func (suite *KeeperTestSuite) mockUnDelegateCoins(ctx sdk.Context, acc sdk.AccountI, mAcc sdk.AccountI) { +func (suite *KeeperTestSuite) mockUnDelegateCoins(ctx sdk.Context, acc, mAcc sdk.AccountI) { vacc, ok := acc.(banktypes.VestingAccount) if ok { suite.authKeeper.EXPECT().SetAccount(ctx, vacc) diff --git a/x/bank/keeper/send.go b/x/bank/keeper/send.go index 3903cf482f05..153ee65c7c44 100644 --- a/x/bank/keeper/send.go +++ b/x/bank/keeper/send.go @@ -21,7 +21,7 @@ type SendKeeper interface { ViewKeeper InputOutputCoins(ctx sdk.Context, inputs types.Input, outputs []types.Output) error - SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error + SendCoins(ctx sdk.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error GetParams(ctx sdk.Context) types.Params SetParams(ctx sdk.Context, params types.Params) error @@ -171,7 +171,7 @@ func (k BaseSendKeeper) InputOutputCoins(ctx sdk.Context, input types.Input, out // SendCoins transfers amt coins from a sending account to a receiving account. // An error is returned upon failure. -func (k BaseSendKeeper) SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error { +func (k BaseSendKeeper) SendCoins(ctx sdk.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error { err := k.subUnlockedCoins(ctx, fromAddr, amt) if err != nil { return err diff --git a/x/bank/types/keys.go b/x/bank/types/keys.go index fbe24f19f3df..1340d437ac11 100644 --- a/x/bank/types/keys.go +++ b/x/bank/types/keys.go @@ -58,7 +58,7 @@ func AddressAndDenomFromBalancesStore(key []byte) (sdk.AccAddress, string, error // CreatePrefixedAccountStoreKey returns the key for the given account and denomination. // This method can be used when performing an ABCI query for the balance of an account. -func CreatePrefixedAccountStoreKey(addr []byte, denom []byte) []byte { +func CreatePrefixedAccountStoreKey(addr, denom []byte) []byte { return append(CreateAccountBalancesPrefix(addr), denom...) } diff --git a/x/bank/types/keys_test.go b/x/bank/types/keys_test.go index ba0dd5c63ee4..351b54255bea 100644 --- a/x/bank/types/keys_test.go +++ b/x/bank/types/keys_test.go @@ -12,7 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank/types" ) -func cloneAppend(bz []byte, tail []byte) (res []byte) { +func cloneAppend(bz, tail []byte) (res []byte) { res = make([]byte, len(bz)+len(tail)) copy(res, bz) copy(res[len(bz):], tail) diff --git a/x/crisis/keeper/keeper.go b/x/crisis/keeper/keeper.go index 28f9c5d47da0..35268e2c65e2 100644 --- a/x/crisis/keeper/keeper.go +++ b/x/crisis/keeper/keeper.go @@ -32,7 +32,7 @@ type Keeper struct { // NewKeeper creates a new Keeper object func NewKeeper( cdc codec.BinaryCodec, storeKey storetypes.StoreKey, invCheckPeriod uint, - supplyKeeper types.SupplyKeeper, feeCollectorName string, authority string, + supplyKeeper types.SupplyKeeper, feeCollectorName, authority string, ) *Keeper { return &Keeper{ storeKey: storeKey, diff --git a/x/distribution/keeper/genesis.go b/x/distribution/keeper/genesis.go index 497a732753f6..e615fa71a1f2 100644 --- a/x/distribution/keeper/genesis.go +++ b/x/distribution/keeper/genesis.go @@ -104,7 +104,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { params := k.GetParams(ctx) dwi := make([]types.DelegatorWithdrawInfo, 0) - k.IterateDelegatorWithdrawAddrs(ctx, func(del sdk.AccAddress, addr sdk.AccAddress) (stop bool) { + k.IterateDelegatorWithdrawAddrs(ctx, func(del, addr sdk.AccAddress) (stop bool) { dwi = append(dwi, types.DelegatorWithdrawInfo{ DelegatorAddress: del.String(), WithdrawAddress: addr.String(), diff --git a/x/distribution/keeper/keeper.go b/x/distribution/keeper/keeper.go index ab80c8aeb7d7..8969d6478de0 100644 --- a/x/distribution/keeper/keeper.go +++ b/x/distribution/keeper/keeper.go @@ -31,7 +31,7 @@ type Keeper struct { func NewKeeper( cdc codec.BinaryCodec, key storetypes.StoreKey, ak types.AccountKeeper, bk types.BankKeeper, sk types.StakingKeeper, - feeCollectorName string, authority string, + feeCollectorName, authority string, ) Keeper { // ensure distribution module account is set if addr := ak.GetModuleAddress(types.ModuleName); addr == nil { @@ -60,7 +60,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { } // SetWithdrawAddr sets a new address that will receive the rewards upon withdrawal -func (k Keeper) SetWithdrawAddr(ctx sdk.Context, delegatorAddr sdk.AccAddress, withdrawAddr sdk.AccAddress) error { +func (k Keeper) SetWithdrawAddr(ctx sdk.Context, delegatorAddr, withdrawAddr sdk.AccAddress) error { if k.bankKeeper.BlockedAddr(withdrawAddr) { return errorsmod.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive external funds", withdrawAddr) } diff --git a/x/distribution/keeper/store.go b/x/distribution/keeper/store.go index 636c994a2027..ae5ef44507bc 100644 --- a/x/distribution/keeper/store.go +++ b/x/distribution/keeper/store.go @@ -32,7 +32,7 @@ func (k Keeper) DeleteDelegatorWithdrawAddr(ctx sdk.Context, delAddr, withdrawAd } // iterate over delegator withdraw addrs -func (k Keeper) IterateDelegatorWithdrawAddrs(ctx sdk.Context, handler func(del sdk.AccAddress, addr sdk.AccAddress) (stop bool)) { +func (k Keeper) IterateDelegatorWithdrawAddrs(ctx sdk.Context, handler func(del, addr sdk.AccAddress) (stop bool)) { store := ctx.KVStore(k.storeKey) iter := storetypes.KVStorePrefixIterator(store, types.DelegatorWithdrawAddrPrefix) defer iter.Close() @@ -332,7 +332,7 @@ func (k Keeper) SetValidatorSlashEvent(ctx sdk.Context, val sdk.ValAddress, heig } // iterate over slash events between heights, inclusive -func (k Keeper) IterateValidatorSlashEventsBetween(ctx sdk.Context, val sdk.ValAddress, startingHeight uint64, endingHeight uint64, +func (k Keeper) IterateValidatorSlashEventsBetween(ctx sdk.Context, val sdk.ValAddress, startingHeight, endingHeight uint64, handler func(height uint64, event types.ValidatorSlashEvent) (stop bool), ) { store := ctx.KVStore(k.storeKey) diff --git a/x/distribution/types/expected_keepers.go b/x/distribution/types/expected_keepers.go index 3360b83f156b..ca497e56be22 100644 --- a/x/distribution/types/expected_keepers.go +++ b/x/distribution/types/expected_keepers.go @@ -24,7 +24,7 @@ type BankKeeper interface { SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins - SendCoinsFromModuleToModule(ctx sdk.Context, senderModule string, recipientModule string, amt sdk.Coins) error + SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error diff --git a/x/distribution/types/querier.go b/x/distribution/types/querier.go index fb9fd4677dca..46f3039c1ce7 100644 --- a/x/distribution/types/querier.go +++ b/x/distribution/types/querier.go @@ -49,7 +49,7 @@ type QueryValidatorSlashesParams struct { } // creates a new instance of QueryValidatorSlashesParams -func NewQueryValidatorSlashesParams(validatorAddr sdk.ValAddress, startingHeight uint64, endingHeight uint64) QueryValidatorSlashesParams { +func NewQueryValidatorSlashesParams(validatorAddr sdk.ValAddress, startingHeight, endingHeight uint64) QueryValidatorSlashesParams { return QueryValidatorSlashesParams{ ValidatorAddress: validatorAddr, StartingHeight: startingHeight, diff --git a/x/gov/keeper/grpc_query.go b/x/gov/keeper/grpc_query.go index a3dfc4da87b3..24e79cde19c2 100644 --- a/x/gov/keeper/grpc_query.go +++ b/x/gov/keeper/grpc_query.go @@ -143,7 +143,7 @@ func (q Keeper) Votes(c context.Context, req *v1.QueryVotesRequest) (*v1.QueryVo store := ctx.KVStore(q.storeKey) votesStore := prefix.NewStore(store, types.VotesKey(req.ProposalId)) - pageRes, err := query.Paginate(votesStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(votesStore, req.Pagination, func(key, value []byte) error { var vote v1.Vote if err := q.cdc.Unmarshal(value, &vote); err != nil { return err @@ -239,7 +239,7 @@ func (q Keeper) Deposits(c context.Context, req *v1.QueryDepositsRequest) (*v1.Q store := ctx.KVStore(q.storeKey) depositStore := prefix.NewStore(store, types.DepositsKey(req.ProposalId)) - pageRes, err := query.Paginate(depositStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(depositStore, req.Pagination, func(key, value []byte) error { var deposit v1.Deposit if err := q.cdc.Unmarshal(value, &deposit); err != nil { return err diff --git a/x/gov/keeper/tally.go b/x/gov/keeper/tally.go index 37c1b2af1a9f..30bb459c3041 100644 --- a/x/gov/keeper/tally.go +++ b/x/gov/keeper/tally.go @@ -11,7 +11,7 @@ import ( // Tally iterates over the votes and updates the tally of a proposal based on the voting power of the // voters -func (keeper Keeper) Tally(ctx sdk.Context, proposal v1.Proposal) (passes bool, burnDeposits bool, tallyResults v1.TallyResult) { +func (keeper Keeper) Tally(ctx sdk.Context, proposal v1.Proposal) (passes, burnDeposits bool, tallyResults v1.TallyResult) { results := make(map[v1.VoteOption]sdk.Dec) results[v1.OptionYes] = math.LegacyZeroDec() results[v1.OptionAbstain] = math.LegacyZeroDec() diff --git a/x/group/internal/math/dec.go b/x/group/internal/math/dec.go index bdf19691c2bc..650acf337880 100644 --- a/x/group/internal/math/dec.go +++ b/x/group/internal/math/dec.go @@ -105,7 +105,7 @@ func (x Dec) IsNegative() bool { } // Add adds x and y -func Add(x Dec, y Dec) (Dec, error) { +func Add(x, y Dec) (Dec, error) { return x.Add(y) } @@ -130,7 +130,7 @@ func (x Dec) IsZero() bool { // SubNonNegative subtracts the value of y from x and returns the result with // arbitrary precision. Returns an error if the result is negative. -func SubNonNegative(x Dec, y Dec) (Dec, error) { +func SubNonNegative(x, y Dec) (Dec, error) { z, err := x.Sub(y) if err != nil { return Dec{}, err diff --git a/x/group/internal/orm/auto_uint64.go b/x/group/internal/orm/auto_uint64.go index bb081f0a3dd0..98b924f5533a 100644 --- a/x/group/internal/orm/auto_uint64.go +++ b/x/group/internal/orm/auto_uint64.go @@ -112,7 +112,7 @@ func (a AutoUInt64Table) PrefixScan(store storetypes.KVStore, start, end uint64) // this as an endpoint to the public without further limits. See `LimitIterator` // // CONTRACT: No writes may happen within a domain while an iterator exists over it. -func (a AutoUInt64Table) ReversePrefixScan(store storetypes.KVStore, start uint64, end uint64) (Iterator, error) { +func (a AutoUInt64Table) ReversePrefixScan(store storetypes.KVStore, start, end uint64) (Iterator, error) { return a.table.ReversePrefixScan(store, EncodeSequence(start), EncodeSequence(end)) } diff --git a/x/group/internal/orm/auto_uint64_test.go b/x/group/internal/orm/auto_uint64_test.go index 2296c86d021f..079b137c46c1 100644 --- a/x/group/internal/orm/auto_uint64_test.go +++ b/x/group/internal/orm/auto_uint64_test.go @@ -52,7 +52,7 @@ func TestAutoUInt64PrefixScan(t *testing.T) { expResult []testdata.TableModel expRowIDs []RowID expError *errorsmod.Error - method func(store storetypes.KVStore, start uint64, end uint64) (Iterator, error) + method func(store storetypes.KVStore, start, end uint64) (Iterator, error) }{ "first element": { start: 1, diff --git a/x/group/internal/orm/index.go b/x/group/internal/orm/index.go index b5ab7d95898a..7564f4705bec 100644 --- a/x/group/internal/orm/index.go +++ b/x/group/internal/orm/index.go @@ -134,7 +134,7 @@ func (i MultiKeyIndex) GetPaginated(store types.KVStore, searchKey interface{}, // it = LimitIterator(it, defaultLimit) // // CONTRACT: No writes may happen within a domain while an iterator exists over it. -func (i MultiKeyIndex) PrefixScan(store types.KVStore, startI interface{}, endI interface{}) (Iterator, error) { +func (i MultiKeyIndex) PrefixScan(store types.KVStore, startI, endI interface{}) (Iterator, error) { start, end, err := getStartEndBz(startI, endI) if err != nil { return nil, err @@ -154,7 +154,7 @@ func (i MultiKeyIndex) PrefixScan(store types.KVStore, startI interface{}, endI // this as an endpoint to the public without further limits. See `LimitIterator` // // CONTRACT: No writes may happen within a domain while an iterator exists over it. -func (i MultiKeyIndex) ReversePrefixScan(store types.KVStore, startI interface{}, endI interface{}) (Iterator, error) { +func (i MultiKeyIndex) ReversePrefixScan(store types.KVStore, startI, endI interface{}) (Iterator, error) { start, end, err := getStartEndBz(startI, endI) if err != nil { return nil, err @@ -167,7 +167,7 @@ func (i MultiKeyIndex) ReversePrefixScan(store types.KVStore, startI interface{} // getStartEndBz gets the start and end bytes to be passed into the SDK store // iterator. -func getStartEndBz(startI interface{}, endI interface{}) ([]byte, []byte, error) { +func getStartEndBz(startI, endI interface{}) ([]byte, []byte, error) { start, err := getPrefixScanKeyBytes(startI) if err != nil { return nil, nil, err diff --git a/x/group/internal/orm/indexer.go b/x/group/internal/orm/indexer.go index 6dcdf4e519e4..a3600c6c8b4d 100644 --- a/x/group/internal/orm/indexer.go +++ b/x/group/internal/orm/indexer.go @@ -177,7 +177,7 @@ func multiKeyAddFunc(store storetypes.KVStore, secondaryIndexKey interface{}, ro } // difference returns the list of elements that are in a but not in b. -func difference(a []interface{}, b []interface{}) ([]interface{}, error) { +func difference(a, b []interface{}) ([]interface{}, error) { set := make(map[interface{}]struct{}, len(b)) for _, v := range b { bt, err := keyPartBytes(v, true) diff --git a/x/group/internal/orm/iterator.go b/x/group/internal/orm/iterator.go index c83d588064a1..7f96b6a4b907 100644 --- a/x/group/internal/orm/iterator.go +++ b/x/group/internal/orm/iterator.go @@ -273,7 +273,7 @@ func ReadAll(it Iterator, dest ModelSlicePtr) ([]RowID, error) { // assertDest checks that the provided dest is not nil and a pointer to a slice. // It also verifies that the slice elements implement *codec.ProtoMarshaler. // It overwrites destRef and tmpSlice using reflection. -func assertDest(dest ModelSlicePtr, destRef *reflect.Value, tmpSlice *reflect.Value) (reflect.Type, error) { +func assertDest(dest ModelSlicePtr, destRef, tmpSlice *reflect.Value) (reflect.Type, error) { if dest == nil { return nil, errorsmod.Wrap(errors.ErrORMInvalidArgument, "destination must not be nil") } diff --git a/x/group/internal/orm/types.go b/x/group/internal/orm/types.go index c3f357a6a3d7..da6f2c6a1ba9 100644 --- a/x/group/internal/orm/types.go +++ b/x/group/internal/orm/types.go @@ -64,7 +64,7 @@ type Index interface { // it = LimitIterator(it, defaultLimit) // // CONTRACT: No writes may happen within a domain while an iterator exists over it. - PrefixScan(store storetypes.KVStore, startI interface{}, endI interface{}) (Iterator, error) + PrefixScan(store storetypes.KVStore, startI, endI interface{}) (Iterator, error) // ReversePrefixScan returns an Iterator over a domain of keys in descending order. End is exclusive. // Start is an MultiKeyIndex key or prefix. It must be less than end, or the Iterator is invalid and error is returned. @@ -75,7 +75,7 @@ type Index interface { // this as an endpoint to the public without further limits. See `LimitIterator` // // CONTRACT: No writes may happen within a domain while an iterator exists over it. - ReversePrefixScan(store storetypes.KVStore, startI interface{}, endI interface{}) (Iterator, error) + ReversePrefixScan(store storetypes.KVStore, startI, endI interface{}) (Iterator, error) } // Iterator allows iteration through a sequence of key value pairs diff --git a/x/group/keeper/genesis_test.go b/x/group/keeper/genesis_test.go index 33a59cb52312..4b3a4107fd44 100644 --- a/x/group/keeper/genesis_test.go +++ b/x/group/keeper/genesis_test.go @@ -210,7 +210,7 @@ func (s *GenesisTestSuite) TestInitExportGenesis() { s.Require().Equal(genesisState.ProposalSeq, exportedGenesisState.ProposalSeq) } -func (s *GenesisTestSuite) assertGroupPoliciesEqual(g *group.GroupPolicyInfo, other *group.GroupPolicyInfo) { +func (s *GenesisTestSuite) assertGroupPoliciesEqual(g, other *group.GroupPolicyInfo) { require := s.Require() require.Equal(g.Address, other.Address) require.Equal(g.GroupId, other.GroupId) @@ -224,7 +224,7 @@ func (s *GenesisTestSuite) assertGroupPoliciesEqual(g *group.GroupPolicyInfo, ot require.Equal(dp1, dp2) } -func (s *GenesisTestSuite) assertProposalsEqual(g *group.Proposal, other *group.Proposal) { +func (s *GenesisTestSuite) assertProposalsEqual(g, other *group.Proposal) { require := s.Require() require.Equal(g.Id, other.Id) require.Equal(g.GroupPolicyAddress, other.GroupPolicyAddress) diff --git a/x/group/keeper/msg_server.go b/x/group/keeper/msg_server.go index 94feeaed3ee8..999fbfe4f3de 100644 --- a/x/group/keeper/msg_server.go +++ b/x/group/keeper/msg_server.go @@ -897,7 +897,7 @@ type ( // doUpdateGroupPolicy first makes sure that the group policy admin initiated the group policy update, // before performing the group policy update and emitting an event. -func (k Keeper) doUpdateGroupPolicy(ctx sdk.Context, groupPolicy string, admin string, action groupPolicyActionFn, note string) error { +func (k Keeper) doUpdateGroupPolicy(ctx sdk.Context, groupPolicy, admin string, action groupPolicyActionFn, note string) error { groupPolicyInfo, err := k.getGroupPolicyInfo(ctx, groupPolicy) if err != nil { return errorsmod.Wrap(err, "load group policy") @@ -975,7 +975,7 @@ func (k Keeper) doAuthenticated(ctx sdk.Context, req authNGroupReq, action actio // assertMetadataLength returns an error if given metadata length // is greater than a pre-defined maxMetadataLen. -func (k Keeper) assertMetadataLength(metadata string, description string) error { +func (k Keeper) assertMetadataLength(metadata, description string) error { if metadata != "" && uint64(len(metadata)) > k.config.MaxMetadataLen { return errorsmod.Wrapf(errors.ErrMaxLimit, description) } diff --git a/x/group/msgs.go b/x/group/msgs.go index 426105c11393..e96a5e3eac00 100644 --- a/x/group/msgs.go +++ b/x/group/msgs.go @@ -191,7 +191,7 @@ var ( ) // NewMsgCreateGroupWithPolicy creates a new MsgCreateGroupWithPolicy. -func NewMsgCreateGroupWithPolicy(admin string, members []MemberRequest, groupMetadata string, groupPolicyMetadata string, groupPolicyAsAdmin bool, decisionPolicy DecisionPolicy) (*MsgCreateGroupWithPolicy, error) { +func NewMsgCreateGroupWithPolicy(admin string, members []MemberRequest, groupMetadata, groupPolicyMetadata string, groupPolicyAsAdmin bool, decisionPolicy DecisionPolicy) (*MsgCreateGroupWithPolicy, error) { m := &MsgCreateGroupWithPolicy{ Admin: admin, Members: members, @@ -344,7 +344,7 @@ var ( ) // NewMsgUpdateGroupPolicyDecisionPolicy creates a new MsgUpdateGroupPolicyDecisionPolicy. -func NewMsgUpdateGroupPolicyDecisionPolicy(admin sdk.AccAddress, address sdk.AccAddress, decisionPolicy DecisionPolicy) (*MsgUpdateGroupPolicyDecisionPolicy, error) { +func NewMsgUpdateGroupPolicyDecisionPolicy(admin, address sdk.AccAddress, decisionPolicy DecisionPolicy) (*MsgUpdateGroupPolicyDecisionPolicy, error) { m := &MsgUpdateGroupPolicyDecisionPolicy{ Admin: admin.String(), GroupPolicyAddress: address.String(), diff --git a/x/group/types.go b/x/group/types.go index 9b0a84f35982..ff18cc0eeb60 100644 --- a/x/group/types.go +++ b/x/group/types.go @@ -51,7 +51,7 @@ type DecisionPolicy interface { var _ DecisionPolicy = &ThresholdDecisionPolicy{} // NewThresholdDecisionPolicy creates a threshold DecisionPolicy -func NewThresholdDecisionPolicy(threshold string, votingPeriod time.Duration, minExecutionPeriod time.Duration) DecisionPolicy { +func NewThresholdDecisionPolicy(threshold string, votingPeriod, minExecutionPeriod time.Duration) DecisionPolicy { return &ThresholdDecisionPolicy{threshold, &DecisionPolicyWindows{votingPeriod, minExecutionPeriod}} } @@ -156,7 +156,7 @@ func (p *ThresholdDecisionPolicy) Validate(g GroupInfo, config Config) error { var _ DecisionPolicy = &PercentageDecisionPolicy{} // NewPercentageDecisionPolicy creates a new percentage DecisionPolicy -func NewPercentageDecisionPolicy(percentage string, votingPeriod time.Duration, executionPeriod time.Duration) DecisionPolicy { +func NewPercentageDecisionPolicy(percentage string, votingPeriod, executionPeriod time.Duration) DecisionPolicy { return &PercentageDecisionPolicy{percentage, &DecisionPolicyWindows{votingPeriod, executionPeriod}} } diff --git a/x/params/simulation/operations.go b/x/params/simulation/operations.go index fe6a5069e6b7..ae83d32c3468 100644 --- a/x/params/simulation/operations.go +++ b/x/params/simulation/operations.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/params/types/proposal" ) -func min(a int, b int) int { +func min(a, b int) int { if a <= b { return a } diff --git a/x/params/types/subspace.go b/x/params/types/subspace.go index b53bff85b757..bc577480107b 100644 --- a/x/params/types/subspace.go +++ b/x/params/types/subspace.go @@ -32,7 +32,7 @@ type Subspace struct { } // NewSubspace constructs a store with namestore -func NewSubspace(cdc codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key storetypes.StoreKey, tkey storetypes.StoreKey, name string) Subspace { +func NewSubspace(cdc codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey, name string) Subspace { return Subspace{ cdc: cdc, legacyAmino: legacyAmino, diff --git a/x/simulation/operation.go b/x/simulation/operation.go index 7aab48e9fbec..5594fd3f5822 100644 --- a/x/simulation/operation.go +++ b/x/simulation/operation.go @@ -73,7 +73,7 @@ func NewOperationQueue() OperationQueue { } // queueOperations adds all future operations into the operation queue. -func queueOperations(queuedOps OperationQueue, queuedTimeOps []simulation.FutureOperation, futureOps []simulation.FutureOperation) { +func queueOperations(queuedOps OperationQueue, queuedTimeOps, futureOps []simulation.FutureOperation) { if futureOps == nil { return } diff --git a/x/slashing/keeper/grpc_query.go b/x/slashing/keeper/grpc_query.go index 986fac8159e1..f39fd9f71fc4 100644 --- a/x/slashing/keeper/grpc_query.go +++ b/x/slashing/keeper/grpc_query.go @@ -62,7 +62,7 @@ func (k Keeper) SigningInfos(c context.Context, req *types.QuerySigningInfosRequ var signInfos []types.ValidatorSigningInfo sigInfoStore := prefix.NewStore(store, types.ValidatorSigningInfoKeyPrefix) - pageRes, err := query.Paginate(sigInfoStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(sigInfoStore, req.Pagination, func(key, value []byte) error { var info types.ValidatorSigningInfo err := k.cdc.Unmarshal(value, &info) if err != nil { diff --git a/x/staking/keeper/grpc_query.go b/x/staking/keeper/grpc_query.go index 135242001706..5b550e8e2da8 100644 --- a/x/staking/keeper/grpc_query.go +++ b/x/staking/keeper/grpc_query.go @@ -150,7 +150,7 @@ func (k Querier) ValidatorUnbondingDelegations(c context.Context, req *types.Que srcValPrefix := types.GetUBDsByValIndexKey(valAddr) ubdStore := prefix.NewStore(store, srcValPrefix) - pageRes, err := query.Paginate(ubdStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(ubdStore, req.Pagination, func(key, value []byte) error { storeKey := types.GetUBDKeyFromValIndexKey(append(srcValPrefix, key...)) storeValue := store.Get(storeKey) @@ -266,7 +266,7 @@ func (k Querier) DelegatorDelegations(c context.Context, req *types.QueryDelegat store := ctx.KVStore(k.storeKey) delStore := prefix.NewStore(store, types.GetDelegationsKey(delAddr)) - pageRes, err := query.Paginate(delStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(delStore, req.Pagination, func(key, value []byte) error { delegation, err := types.UnmarshalDelegation(k.cdc, value) if err != nil { return err @@ -337,7 +337,7 @@ func (k Querier) DelegatorUnbondingDelegations(c context.Context, req *types.Que } unbStore := prefix.NewStore(store, types.GetUBDsKey(delAddr)) - pageRes, err := query.Paginate(unbStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(unbStore, req.Pagination, func(key, value []byte) error { unbond, err := types.UnmarshalUBD(k.cdc, value) if err != nil { return err @@ -422,7 +422,7 @@ func (k Querier) DelegatorValidators(c context.Context, req *types.QueryDelegato } delStore := prefix.NewStore(store, types.GetDelegationsKey(delAddr)) - pageRes, err := query.Paginate(delStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(delStore, req.Pagination, func(key, value []byte) error { delegation, err := types.UnmarshalDelegation(k.cdc, value) if err != nil { return err @@ -502,7 +502,7 @@ func queryRedelegationsFromSrcValidator(store storetypes.KVStore, k Querier, req srcValPrefix := types.GetREDsFromValSrcIndexKey(valAddr) redStore := prefix.NewStore(store, srcValPrefix) - res, err = query.Paginate(redStore, req.Pagination, func(key []byte, value []byte) error { + res, err = query.Paginate(redStore, req.Pagination, func(key, value []byte) error { storeKey := types.GetREDKeyFromValSrcIndexKey(append(srcValPrefix, key...)) storeValue := store.Get(storeKey) red, err := types.UnmarshalRED(k.cdc, storeValue) @@ -523,7 +523,7 @@ func queryAllRedelegations(store storetypes.KVStore, k Querier, req *types.Query } redStore := prefix.NewStore(store, types.GetREDsKey(delAddr)) - res, err = query.Paginate(redStore, req.Pagination, func(key []byte, value []byte) error { + res, err = query.Paginate(redStore, req.Pagination, func(key, value []byte) error { redelegation, err := types.UnmarshalRED(k.cdc, value) if err != nil { return err diff --git a/x/staking/keeper/slash.go b/x/staking/keeper/slash.go index e5b4e1f87e61..58cda25091ee 100644 --- a/x/staking/keeper/slash.go +++ b/x/staking/keeper/slash.go @@ -30,7 +30,7 @@ import ( // // Infraction was committed at the current height or at a past height, // not at a height in the future -func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeight int64, power int64, slashFactor sdk.Dec) math.Int { +func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeight, power int64, slashFactor sdk.Dec) math.Int { logger := k.Logger(ctx) if slashFactor.IsNegative() { @@ -157,7 +157,7 @@ func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeigh } // SlashWithInfractionReason implementation doesn't require the infraction (types.Infraction) to work but is required by Interchain Security. -func (k Keeper) SlashWithInfractionReason(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeight int64, power int64, slashFactor sdk.Dec, _ types.Infraction) math.Int { +func (k Keeper) SlashWithInfractionReason(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeight, power int64, slashFactor sdk.Dec, _ types.Infraction) math.Int { return k.Slash(ctx, consAddr, infractionHeight, power, slashFactor) } diff --git a/x/staking/types/authz.go b/x/staking/types/authz.go index f30dfe018bc2..911974c1e376 100644 --- a/x/staking/types/authz.go +++ b/x/staking/types/authz.go @@ -15,7 +15,7 @@ const gasCostPerIteration = uint64(10) var _ authz.Authorization = &StakeAuthorization{} // NewStakeAuthorization creates a new StakeAuthorization object. -func NewStakeAuthorization(allowed []sdk.ValAddress, denied []sdk.ValAddress, authzType AuthorizationType, amount *sdk.Coin) (*StakeAuthorization, error) { +func NewStakeAuthorization(allowed, denied []sdk.ValAddress, authzType AuthorizationType, amount *sdk.Coin) (*StakeAuthorization, error) { allowedValidators, deniedValidators, err := validateAllowAndDenyValidators(allowed, denied) if err != nil { return nil, err @@ -150,7 +150,7 @@ func (a StakeAuthorization) Accept(ctx sdk.Context, msg sdk.Msg) (authz.AcceptRe }, nil } -func validateAllowAndDenyValidators(allowed []sdk.ValAddress, denied []sdk.ValAddress) ([]string, []string, error) { +func validateAllowAndDenyValidators(allowed, denied []sdk.ValAddress) ([]string, []string, error) { if len(allowed) == 0 && len(denied) == 0 { return nil, nil, sdkerrors.ErrInvalidRequest.Wrap("both allowed & deny list cannot be empty") }