diff --git a/.circleci/config.yml b/.circleci/config.yml index a6f67a43c02b..99dade6a027c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -74,142 +74,10 @@ jobs: paths: - ".git" - test-sim-nondeterminism: - executor: golang - steps: - - make: - target: test-sim-nondeterminism - description: "Test individual module simulations" - - test-sim-import-export: - executor: golang - steps: - - make: - target: test-sim-import-export - description: "Test application import/export simulation" - - test-sim-after-import: - executor: golang - steps: - - make: - target: test-sim-after-import - description: "Test simulation after import" - - test-sim-multi-seed-long: - executor: golang - steps: - - make: - target: test-sim-multi-seed-long - description: "Test multi-seed simulation (long)" - - test-sim-multi-seed-short: - executor: golang - steps: - - make: - target: test-sim-multi-seed-short - description: "Test multi-seed simulation (short)" - - test-cover: - executor: golang - parallelism: 4 - steps: - - checkout - - restore_cache: - keys: - - go-mod-v2-{{ checksum "go.sum" }} - - run: - name: Run tests - command: | - export VERSION="$(git describe --tags --long | sed 's/v\(.*\)/\1/')" - export GO111MODULE=on - mkdir -p /tmp/logs /tmp/workspace/profiles - for pkg in $(go list ./... | grep -v '/simulation' | circleci tests split); do - id=$(echo "$pkg" | sed 's|[/.]|_|g') - go test -mod=readonly -timeout 8m -race -coverprofile=/tmp/workspace/profiles/$id.out -covermode=atomic -tags='ledger test_ledger_mock' "$pkg" | tee "/tmp/logs/$id-$RANDOM.log" - done - - persist_to_workspace: - root: /tmp/workspace - paths: - - "profiles/*" - - store_artifacts: - path: /tmp/logs - - upload-coverage: - executor: golang - steps: - - attach_workspace: - at: /tmp/workspace - - checkout - - run: - name: gather - command: | - echo "--> Concatenating profiles:" - ls /tmp/workspace/profiles/ - echo "mode: atomic" > coverage.txt - for prof in $(ls /tmp/workspace/profiles/); do - tail -n +2 /tmp/workspace/profiles/"$prof" >> coverage.txt - done - - run: - name: filter out DONTCOVER - command: | - excludelist="$(find ./ -type f -name '*.go' | xargs grep -l 'DONTCOVER')" - for filename in ${excludelist}; do - filename=$(echo $filename | sed 's/^./github.com\/cosmos\/cosmos-sdk/g') - echo "Excluding ${filename} from coverage report..." - sed -i.bak "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt - done - - run: - name: upload - command: bash <(curl -s https://codecov.io/bash) -f coverage.txt - - update-swagger-docs: - executor: golang - steps: - - make: - target: update-swagger-docs - description: "Check if statik.go is up-to-date" - workflows: version: 2 test-suite: jobs: - - update-swagger-docs: - requires: - - setup-dependencies - - setup-dependencies: - # This filter enables the job for tags - filters: - tags: - only: - - /^v.*/ - - test-sim-nondeterminism: - requires: - - setup-dependencies - - test-sim-import-export: - requires: - - setup-dependencies - - test-sim-after-import: - requires: - - setup-dependencies - - test-sim-multi-seed-short: - requires: - - setup-dependencies - - test-sim-multi-seed-long: - requires: - - setup-dependencies - # These filters ensure that the long sim only runs during release - filters: - branches: - ignore: /.*/ - tags: - only: - - /^v.*/ - - test-cover: - requires: - - setup-dependencies - - upload-coverage: - requires: - - test-cover - build-docs: context: docs-deployment-master filters: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000000..37f702ef6402 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,14 @@ +name: Lint +on: [pull_request] +jobs: + golangci: + name: golangci-lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: golangci/golangci-lint-action@master + with: + # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. + version: v1.27 + args: --timeout 10m + github-token: ${{ secrets.github_token }} diff --git a/.github/workflows/release-sims.yml b/.github/workflows/release-sims.yml new file mode 100644 index 000000000000..bc21f4372eb0 --- /dev/null +++ b/.github/workflows/release-sims.yml @@ -0,0 +1,46 @@ +name: Release Sims +on: + pull_request: + branches: + - "rc**" + +jobs: + cleanup-runs: + runs-on: ubuntu-latest + steps: + - uses: rokroskar/workflow-run-cleanup-action@master + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'" + + build: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, 'skip-sims')" + steps: + - uses: actions/checkout@v2 + - run: | + make build + install-runsim: + runs-on: ubuntu-latest + needs: build + steps: + - name: install runsim + run: | + export GO111MODULE="on" && go get github.com/cosmos/tools/cmd/runsim@v1.0.0 + - uses: actions/cache@v1 + with: + path: ~/go/bin + key: ${{ runner.os }}-go-runsim-binary + + test-sim-multi-seed-long: + runs-on: ubuntu-latest + needs: [build, install-runsim] + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v1 + with: + path: ~/go/bin + key: ${{ runner.os }}-go-runsim-binary + - name: test-sim-multi-seed-long + run: | + make test-sim-multi-seed-long diff --git a/.github/workflows/sims.yml b/.github/workflows/sims.yml new file mode 100644 index 000000000000..fb5020a7bf43 --- /dev/null +++ b/.github/workflows/sims.yml @@ -0,0 +1,122 @@ +name: Sims +on: [pull_request] +jobs: + cleanup-runs: + runs-on: ubuntu-latest + if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'" + steps: + - uses: rokroskar/workflow-run-cleanup-action@master + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + build: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, 'skip-sims')" + steps: + - uses: actions/checkout@v2 + - run: | + make build + install-runsim: + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/setup-go@v2-beta + - name: install runsim + run: | + export GO111MODULE="on" && go get github.com/cosmos/tools/cmd/runsim@v1.0.0 + - uses: actions/cache@v1 + with: + path: ~/go/bin + key: ${{ runner.os }}-go-runsim-binary + + test-sim-nondeterminism: + runs-on: ubuntu-latest + needs: [build, install-runsim] + steps: + - uses: actions/checkout@v2 + - uses: technote-space/get-diff-action@v1 + with: + SUFFIX_FILTER: | + .go + .mod + .sum + SET_ENV_NAME_INSERTIONS: 1 + SET_ENV_NAME_LINES: 1 + - uses: actions/cache@v1 + with: + path: ~/go/bin + key: ${{ runner.os }}-go-runsim-binary + if: "env.GIT_DIFF != ''" + - name: test-sim-nondeterminism + run: | + make test-sim-nondeterminism + if: "env.GIT_DIFF != ''" + + test-sim-import-export: + runs-on: ubuntu-latest + needs: [build, install-runsim] + steps: + - uses: actions/checkout@v2 + - uses: technote-space/get-diff-action@v1 + with: + SUFFIX_FILTER: | + .go + .mod + .sum + SET_ENV_NAME_INSERTIONS: 1 + SET_ENV_NAME_LINES: 1 + - uses: actions/cache@v1 + with: + path: ~/go/bin + key: ${{ runner.os }}-go-runsim-binary + if: "env.GIT_DIFF != ''" + - name: test-sim-import-export + run: | + make test-sim-import-export + if: "env.GIT_DIFF != ''" + + test-sim-after-import: + runs-on: ubuntu-latest + needs: [build, install-runsim] + steps: + - uses: actions/checkout@v2 + - uses: technote-space/get-diff-action@v1 + with: + SUFFIX_FILTER: | + .go + .mod + .sum + SET_ENV_NAME_INSERTIONS: 1 + SET_ENV_NAME_LINES: 1 + - uses: actions/cache@v1 + with: + path: ~/go/bin + key: ${{ runner.os }}-go-runsim-binary + if: "env.GIT_DIFF != ''" + - name: test-sim-after-import + run: | + make test-sim-after-import + if: "env.GIT_DIFF != ''" + + test-sim-multi-seed-short: + runs-on: ubuntu-latest + needs: [build, install-runsim] + steps: + - uses: actions/checkout@v2 + - uses: technote-space/get-diff-action@v1 + with: + SUFFIX_FILTER: | + .go + .mod + .sum + SET_ENV_NAME_INSERTIONS: 1 + SET_ENV_NAME_LINES: 1 + - uses: actions/cache@v1 + with: + path: ~/go/bin + key: ${{ runner.os }}-go-runsim-binary + if: "env.GIT_DIFF != ''" + - name: test-sim-multi-seed-short + run: | + make test-sim-multi-seed-short + if: "env.GIT_DIFF != ''" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000000..1a9f2103bbbe --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,52 @@ +name: Code Coverage +on: + pull_request: + push: + branches: + - master +jobs: + cleanup-runs: + runs-on: ubuntu-latest + steps: + - uses: rokroskar/workflow-run-cleanup-action@master + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'" + + test-coverage-upload: + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v2-beta + - uses: actions/checkout@v2 + - uses: technote-space/get-diff-action@v1 + id: git_diff + with: + SUFFIX_FILTER: | + .go + .mod + .sum + - name: build + run: | + make build + if: "env.GIT_DIFF != ''" + + - name: test & coverage report creation + run: | + go test ./... -mod=readonly -timeout 12m -race -coverprofile=coverage.txt -covermode=atomic -tags='ledger test_ledger_mock' + if: "env.GIT_DIFF != ''" + - name: filter out DONTCOVER + run: | + excludelist="$(find ./ -type f -name '*.go' | xargs grep -l 'DONTCOVER')" + excludelist+=" $(find ./ -type f -name '*.pb.go')" + excludelist+=" $(find ./ -type f -path './tests/mocks/*.go')" + for filename in ${excludelist}; do + filename=$(echo $filename | sed 's/^./github.com\/cosmos\/cosmos-sdk/g') + echo "Excluding ${filename} from coverage report..." + sed -i.bak "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt + done + if: "env.GIT_DIFF != ''" + - uses: codecov/codecov-action@v1 + with: + file: ./coverage.txt # optional + fail_ci_if_error: true + if: "env.GIT_DIFF != ''" diff --git a/client/input/input.go b/client/input/input.go index 95f32281edd5..73dd822fd369 100644 --- a/client/input/input.go +++ b/client/input/input.go @@ -66,7 +66,7 @@ func GetCheckPassword(prompt, prompt2 string, buf *bufio.Reader) (string, error) // If the input is not recognized, it returns false and a nil error. func GetConfirmation(prompt string, buf *bufio.Reader) (bool, error) { if inputIsTty() { - fmt.Print(fmt.Sprintf("%s [y/N]: ", prompt)) + fmt.Printf("%s [y/N]: ", prompt) } response, err := readLineFromBuf(buf) diff --git a/client/keys/import_test.go b/client/keys/import_test.go index faac935179bb..9e5cdc64ab43 100644 --- a/client/keys/import_test.go +++ b/client/keys/import_test.go @@ -42,7 +42,7 @@ HbP+c6JmeJy9JXe2rbbF1QtCX1gLqGcDQPBXiCtFvP7/8wTZtVOPj8vREzhZ9ElO =f3l4 -----END TENDERMINT PRIVATE KEY----- ` - require.NoError(t, ioutil.WriteFile(keyfile, []byte(armoredKey), 0644)) + require.NoError(t, ioutil.WriteFile(keyfile, []byte(armoredKey), 0600)) // Now enter password if runningUnattended { diff --git a/codec/codec.go b/codec/codec.go index 6cf2f623d7e4..b2d5c090df2b 100644 --- a/codec/codec.go +++ b/codec/codec.go @@ -54,7 +54,7 @@ func MustMarshalJSONIndent(cdc *Codec, obj interface{}) []byte { //__________________________________________________________________ -// generic sealed codec to be used throughout sdk +// Cdc generic sealed codec to be used throughout sdk var Cdc *Codec func init() { diff --git a/crypto/keys/keyring.go b/crypto/keys/keyring.go index 2135c3381719..976b386a579f 100644 --- a/crypto/keys/keyring.go +++ b/crypto/keys/keyring.go @@ -15,7 +15,6 @@ import ( "github.com/pkg/errors" "github.com/tendermint/crypto/bcrypt" - "github.com/tendermint/tendermint/crypto" tmcrypto "github.com/tendermint/tendermint/crypto" cryptoAmino "github.com/tendermint/tendermint/crypto/encoding/amino" @@ -592,7 +591,7 @@ func newRealPrompt(dir string, buf io.Reader) func(string) (string, error) { continue } - saltBytes := crypto.CRandBytes(16) + saltBytes := tmcrypto.CRandBytes(16) passwordHash, err := bcrypt.GenerateFromPassword(saltBytes, []byte(pass), 2) if err != nil { fmt.Fprintln(os.Stderr, err) diff --git a/crypto/keys/lazy_keybase_test.go b/crypto/keys/lazy_keybase_test.go index 1b5991dae724..19d5445297f2 100644 --- a/crypto/keys/lazy_keybase_test.go +++ b/crypto/keys/lazy_keybase_test.go @@ -425,7 +425,7 @@ func TestKeygenOverride(t *testing.T) { overrideCalled := false dummyFunc := func(bz []byte, algo SigningAlgo) (crypto.PrivKey, error) { overrideCalled = true - return testPriv(bz[:]), nil + return testPriv(bz), nil } kb := New("keybasename", dir, WithKeygenFunc(dummyFunc)) diff --git a/crypto/keys/mintkey/mintkey.go b/crypto/keys/mintkey/mintkey.go index 361c5d7f8c0a..83c0e0b91672 100644 --- a/crypto/keys/mintkey/mintkey.go +++ b/crypto/keys/mintkey/mintkey.go @@ -27,7 +27,7 @@ const ( headerType = "type" ) -// Make bcrypt security parameter var, so it can be changed within the lcd test +// BcryptSecurityParameter is a var so it can be changed within the lcd test // Making the bcrypt security parameter a var shouldn't be a security issue: // One can't verify an invalid key by maliciously changing the bcrypt // parameter during a runtime vulnerability. The main security diff --git a/crypto/keys/types_test.go b/crypto/keys/types_test.go index 1376c3bbb70f..3c18f4cf10ad 100644 --- a/crypto/keys/types_test.go +++ b/crypto/keys/types_test.go @@ -8,7 +8,6 @@ import ( "github.com/tendermint/tendermint/crypto/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/keys/hd" - "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -17,7 +16,7 @@ func Test_writeReadLedgerInfo(t *testing.T) { bz, _ := hex.DecodeString("035AD6810A47F073553FF30D2FCC7E0D3B1C0B74B61A1AAA2582344037151E143A") copy(tmpKey[:], bz) - lInfo := newLedgerInfo("some_name", tmpKey, *hd.NewFundraiserParams(5, types.CoinType, 1), Secp256k1) + lInfo := newLedgerInfo("some_name", tmpKey, *hd.NewFundraiserParams(5, sdk.CoinType, 1), Secp256k1) assert.Equal(t, TypeLedger, lInfo.GetType()) path, err := lInfo.GetPath() @@ -25,7 +24,7 @@ func Test_writeReadLedgerInfo(t *testing.T) { assert.Equal(t, "44'/118'/5'/0/1", path.String()) assert.Equal(t, "cosmospub1addwnpepqddddqg2glc8x4fl7vxjlnr7p5a3czm5kcdp4239sg6yqdc4rc2r5wmxv8p", - types.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeAccPub, lInfo.GetPubKey())) + sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeAccPub, lInfo.GetPubKey())) // Serialize and restore serialized := marshalInfo(lInfo) diff --git a/simapp/utils.go b/simapp/utils.go index bc3e889fe68c..b1bfda3a9790 100644 --- a/simapp/utils.go +++ b/simapp/utils.go @@ -81,7 +81,7 @@ func CheckExportSimulation( return err } - if err := ioutil.WriteFile(config.ExportStatePath, []byte(appState), 0644); err != nil { + if err := ioutil.WriteFile(config.ExportStatePath, []byte(appState), 0600); err != nil { return err } } @@ -93,7 +93,7 @@ func CheckExportSimulation( return err } - if err := ioutil.WriteFile(config.ExportParamsPath, paramsBz, 0644); err != nil { + if err := ioutil.WriteFile(config.ExportParamsPath, paramsBz, 0600); err != nil { return err } } diff --git a/store/prefix/store_test.go b/store/prefix/store_test.go index 427423340d8f..eb1f0a4d4433 100644 --- a/store/prefix/store_test.go +++ b/store/prefix/store_test.go @@ -17,11 +17,7 @@ import ( ) // copied from iavl/store_test.go -var ( - cacheSize = 100 - numRecent int64 = 5 - storeEvery int64 = 3 -) +var cacheSize = 100 func bz(s string) []byte { return []byte(s) } diff --git a/store/reexport.go b/store/reexport.go index 913a8c55a8b3..9e4dba0ed5f6 100644 --- a/store/reexport.go +++ b/store/reexport.go @@ -2,7 +2,6 @@ package store import ( "github.com/cosmos/cosmos-sdk/store/types" - stypes "github.com/cosmos/cosmos-sdk/store/types" ) // Import cosmos-sdk/types/store.go for convenience. @@ -27,9 +26,9 @@ type ( StoreType = types.StoreType Queryable = types.Queryable TraceContext = types.TraceContext - Gas = stypes.Gas + Gas = types.Gas GasMeter = types.GasMeter - GasConfig = stypes.GasConfig + GasConfig = types.GasConfig ) // nolint - reexport diff --git a/types/int.go b/types/int.go index caabdb11318c..0029dfaa4eb4 100644 --- a/types/int.go +++ b/types/int.go @@ -53,7 +53,7 @@ func max(i *big.Int, i2 *big.Int) *big.Int { } // MarshalAmino for custom encoding scheme -func marshalAmino(i *big.Int) (string, error) { +func marshalAmino(i *big.Int) (string, error) { // nolint:interfacer bz, err := i.MarshalText() return string(bz), err } @@ -77,7 +77,7 @@ func unmarshalAmino(i *big.Int, text string) (err error) { // MarshalJSON for custom encoding scheme // Must be encoded as a string for JSON precision -func marshalJSON(i *big.Int) ([]byte, error) { +func marshalJSON(i *big.Int) ([]byte, error) { // nolint:interfacer text, err := i.MarshalText() if err != nil { return nil, err diff --git a/types/module/simulation.go b/types/module/simulation.go index fab432c8a57e..d639f4c09621 100644 --- a/types/module/simulation.go +++ b/types/module/simulation.go @@ -50,7 +50,7 @@ func NewSimulationManager(modules ...AppModuleSimulation) *SimulationManager { // GetProposalContents returns each module's proposal content generator function // with their default operation weight and key. func (sm *SimulationManager) GetProposalContents(simState SimulationState) []simulation.WeightedProposalContent { - var wContents []simulation.WeightedProposalContent + var wContents []simulation.WeightedProposalContent //nolint:prealloc for _, module := range sm.Modules { wContents = append(wContents, module.ProposalContents(simState)...) } @@ -87,7 +87,7 @@ func (sm *SimulationManager) GenerateParamChanges(seed int64) (paramChanges []si // WeightedOperations returns all the modules' weighted operations of an application func (sm *SimulationManager) WeightedOperations(simState SimulationState) []simulation.WeightedOperation { - var wOps []simulation.WeightedOperation + var wOps []simulation.WeightedOperation //nolint:prealloc for _, module := range sm.Modules { wOps = append(wOps, module.WeightedOperations(simState)...) } diff --git a/types/rest/rest.go b/types/rest/rest.go index 65c1bc094e8a..4a0fe4e9f04d 100644 --- a/types/rest/rest.go +++ b/types/rest/rest.go @@ -20,8 +20,8 @@ import ( ) const ( - DefaultPage = 1 - DefaultLimit = 30 // should be consistent with tendermint/tendermint/rpc/core/pipe.go:19 + DefaultPage = 1 + DefaultLimit = 30 // should be consistent with tendermint/tendermint/rpc/core/pipe.go:19 TxMinHeightKey = "tx.minheight" // Inclusive minimum height filter TxMaxHeightKey = "tx.maxheight" // Inclusive maximum height filter ) @@ -337,13 +337,14 @@ func ParseHTTPArgsWithLimit(r *http.Request, defaultLimit int) (tags []string, p } var tag string - if key == types.TxHeightKey { + switch key { + case types.TxHeightKey: tag = fmt.Sprintf("%s=%s", key, value) - } else if key == TxMinHeightKey { + case TxMinHeightKey: tag = fmt.Sprintf("%s>=%s", types.TxHeightKey, value) - } else if key == TxMaxHeightKey { + case TxMaxHeightKey: tag = fmt.Sprintf("%s<=%s", types.TxHeightKey, value) - } else { + default: tag = fmt.Sprintf("%s='%s'", key, value) } tags = append(tags, tag) diff --git a/x/auth/ante/basic.go b/x/auth/ante/basic.go index 0e999a9d4781..57a41ec874e4 100644 --- a/x/auth/ante/basic.go +++ b/x/auth/ante/basic.go @@ -2,7 +2,6 @@ package ante import ( sdk "github.com/cosmos/cosmos-sdk/types" - err "github.com/cosmos/cosmos-sdk/types/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/tendermint/tendermint/crypto" @@ -67,7 +66,7 @@ func (vmd ValidateMemoDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate memoLength := len(memoTx.GetMemo()) if uint64(memoLength) > params.MaxMemoCharacters { - return ctx, err.Wrapf(err.ErrMemoTooLarge, + return ctx, sdkerrors.Wrapf(sdkerrors.ErrMemoTooLarge, "maximum number of characters is %d but received %d characters", params.MaxMemoCharacters, memoLength, ) diff --git a/x/bank/app_test.go b/x/bank/app_test.go index 7a9894aa8c3b..3f42eac4a7a1 100644 --- a/x/bank/app_test.go +++ b/x/bank/app_test.go @@ -49,7 +49,6 @@ var ( halfCoins = sdk.Coins{sdk.NewInt64Coin("foocoin", 5)} sendMsg1 = types.NewMsgSend(addr1, addr2, coins) - sendMsg2 = types.NewMsgSend(addr1, moduleAccAddr, coins) multiSendMsg1 = types.MsgMultiSend{ Inputs: []types.Input{types.NewInput(addr1, coins)}, diff --git a/x/bank/internal/types/codec.go b/x/bank/internal/types/codec.go index 6d4d49adc118..f9a1609a8256 100644 --- a/x/bank/internal/types/codec.go +++ b/x/bank/internal/types/codec.go @@ -10,7 +10,6 @@ func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(MsgMultiSend{}, "cosmos-sdk/MsgMultiSend", nil) } -// module codec var ModuleCdc *codec.Codec func init() { diff --git a/x/bank/simulation/operations.go b/x/bank/simulation/operations.go index 123e0b8eb45a..c088addf41c3 100644 --- a/x/bank/simulation/operations.go +++ b/x/bank/simulation/operations.go @@ -85,7 +85,7 @@ func SimulateMsgSend(ak types.AccountKeeper, bk keeper.Keeper) simulation.Operat // sendMsgSend sends a transaction with a MsgSend from a provided random account. func sendMsgSend( - r *rand.Rand, app *baseapp.BaseApp, ak types.AccountKeeper, + r *rand.Rand, app *baseapp.BaseApp, ak types.AccountKeeper, // nolint:interfacer msg types.MsgSend, ctx sdk.Context, chainID string, privkeys []crypto.PrivKey, ) error { @@ -219,7 +219,7 @@ func SimulateMsgMultiSend(ak types.AccountKeeper, bk keeper.Keeper) simulation.O // sendMsgMultiSend sends a transaction with a MsgMultiSend from a provided random // account. func sendMsgMultiSend( - r *rand.Rand, app *baseapp.BaseApp, ak types.AccountKeeper, + r *rand.Rand, app *baseapp.BaseApp, ak types.AccountKeeper, // nolint:interfacer msg types.MsgMultiSend, ctx sdk.Context, chainID string, privkeys []crypto.PrivKey, ) error { @@ -269,7 +269,7 @@ func sendMsgMultiSend( // randomSendFields returns the sender and recipient simulation accounts as well // as the transferred amount. func randomSendFields( - r *rand.Rand, ctx sdk.Context, accs []simulation.Account, ak types.AccountKeeper, + r *rand.Rand, ctx sdk.Context, accs []simulation.Account, ak types.AccountKeeper, // nolint:interfacer ) (simulation.Account, simulation.Account, sdk.Coins, bool, error) { simAccount, _ := simulation.RandomAcc(r, accs) diff --git a/x/crisis/internal/types/codec.go b/x/crisis/internal/types/codec.go index 92aeb130bce8..82136e7ef853 100644 --- a/x/crisis/internal/types/codec.go +++ b/x/crisis/internal/types/codec.go @@ -9,7 +9,7 @@ func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(MsgVerifyInvariant{}, "cosmos-sdk/MsgVerifyInvariant", nil) } -// generic sealed codec to be used throughout module +// ModuleCdc is a generic sealed codec to be used throughout module var ModuleCdc *codec.Codec func init() { diff --git a/x/distribution/types/codec.go b/x/distribution/types/codec.go index a2d4bf11eaae..4ad4632d5c6a 100644 --- a/x/distribution/types/codec.go +++ b/x/distribution/types/codec.go @@ -12,7 +12,7 @@ func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(CommunityPoolSpendProposal{}, "cosmos-sdk/CommunityPoolSpendProposal", nil) } -// generic sealed codec to be used throughout module +// ModuleCdc is a generic sealed codec to be used throughout module var ModuleCdc *codec.Codec func init() { diff --git a/x/genutil/client/cli/migrate_test.go b/x/genutil/client/cli/migrate_test.go index 423629efcb13..d0dbf94a4764 100644 --- a/x/genutil/client/cli/migrate_test.go +++ b/x/genutil/client/cli/migrate_test.go @@ -56,7 +56,7 @@ func TestMigrateGenesis(t *testing.T) { // Noop migration with minimal genesis emptyGenesis := []byte(`{"chain_id":"test","app_state":{}}`) - err = ioutil.WriteFile(genesisPath, emptyGenesis, 0644) + err = ioutil.WriteFile(genesisPath, emptyGenesis, 0600) require.Nil(t, err) cmd := setupCmd("", "test2") require.NoError(t, MigrateGenesisCmd(ctx, cdc).RunE(cmd, []string{target, genesisPath})) diff --git a/x/gov/types/codec.go b/x/gov/types/codec.go index fc3de0e3f30c..82ca3c38c02b 100644 --- a/x/gov/types/codec.go +++ b/x/gov/types/codec.go @@ -4,7 +4,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" ) -// module codec var ModuleCdc = codec.New() // RegisterCodec registers all the necessary types and interfaces for diff --git a/x/mint/internal/types/codec.go b/x/mint/internal/types/codec.go index 5787f242adfe..ff10e307cf60 100644 --- a/x/mint/internal/types/codec.go +++ b/x/mint/internal/types/codec.go @@ -4,7 +4,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" ) -// generic sealed codec to be used throughout this module +// ModuleCdc is a generic sealed codec to be used throughout this module var ModuleCdc *codec.Codec func init() { diff --git a/x/mint/internal/types/keys.go b/x/mint/internal/types/keys.go index cf395bc44ee3..0c7c71f78484 100644 --- a/x/mint/internal/types/keys.go +++ b/x/mint/internal/types/keys.go @@ -1,14 +1,14 @@ package types -// the one key to use for the keeper store +// MinterKey is used for the keeper store var MinterKey = []byte{0x00} // nolint const ( - // module name + // ModuleName ModuleName = "mint" - // default paramspace for params keeper + // DefaultParamspace params keeper DefaultParamspace = ModuleName // StoreKey is the default store key for mint diff --git a/x/params/client/proposal_handler.go b/x/params/client/proposal_handler.go index 040bebdf448f..d63f1ca3ffdc 100644 --- a/x/params/client/proposal_handler.go +++ b/x/params/client/proposal_handler.go @@ -6,5 +6,5 @@ import ( "github.com/cosmos/cosmos-sdk/x/params/client/rest" ) -// param change proposal handler +// ProposalHandler handles param change proposals var ProposalHandler = govclient.NewProposalHandler(cli.GetCmdSubmitProposal, rest.ProposalRESTHandler) diff --git a/x/params/types/codec.go b/x/params/types/codec.go index 525836346f90..2c45f5e0483c 100644 --- a/x/params/types/codec.go +++ b/x/params/types/codec.go @@ -4,7 +4,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" ) -// module codec var ModuleCdc *codec.Codec func init() { diff --git a/x/simulation/account_test.go b/x/simulation/account_test.go index adb28dcf984f..e5bda5e4f202 100644 --- a/x/simulation/account_test.go +++ b/x/simulation/account_test.go @@ -65,6 +65,7 @@ func TestRandomFees(t *testing.T) { {"0 coins", sdk.NewCoins(sdk.NewInt64Coin("aaa", 10), sdk.NewInt64Coin("bbb", 5)), false, false}, } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { got, err := simulation.RandomFees(r, sdk.Context{}, tt.spendableCoins) if (err != nil) != tt.wantErr { diff --git a/x/simulation/event_stats.go b/x/simulation/event_stats.go index 1a6201aaca77..0e4289fd243e 100644 --- a/x/simulation/event_stats.go +++ b/x/simulation/event_stats.go @@ -48,7 +48,7 @@ func (es EventStats) ExportJSON(path string) { panic(err) } - err = ioutil.WriteFile(path, bz, 0644) + err = ioutil.WriteFile(path, bz, 0600) if err != nil { panic(err) } diff --git a/x/simulation/rand_util_test.go b/x/simulation/rand_util_test.go index 2128de4050aa..9778dcb699b1 100644 --- a/x/simulation/rand_util_test.go +++ b/x/simulation/rand_util_test.go @@ -46,6 +46,7 @@ func TestRandStringOfLength(t *testing.T) { {"10-size", 1_000_000_000, 1_000_000_000}, } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { got := simulation.RandStringOfLength(r, tt.n) require.Equal(t, tt.want, len(got)) diff --git a/x/slashing/simulation/operations.go b/x/slashing/simulation/operations.go index f5e263b778dc..590513fd5b0b 100644 --- a/x/slashing/simulation/operations.go +++ b/x/slashing/simulation/operations.go @@ -43,7 +43,7 @@ func WeightedOperations( // SimulateMsgUnjail generates a MsgUnjail with random values // nolint: funlen -func SimulateMsgUnjail(ak types.AccountKeeper, k keeper.Keeper, sk stakingkeeper.Keeper) simulation.Operation { +func SimulateMsgUnjail(ak types.AccountKeeper, k keeper.Keeper, sk stakingkeeper.Keeper) simulation.Operation { // nolint:interfacer return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simulation.Account, chainID string, diff --git a/x/staking/simulation/operations.go b/x/staking/simulation/operations.go index b1a932270641..a8372dc922e5 100644 --- a/x/staking/simulation/operations.go +++ b/x/staking/simulation/operations.go @@ -93,7 +93,7 @@ func WeightedOperations( // SimulateMsgCreateValidator generates a MsgCreateValidator with random values // nolint: funlen -func SimulateMsgCreateValidator(ak types.AccountKeeper, k keeper.Keeper) simulation.Operation { +func SimulateMsgCreateValidator(ak types.AccountKeeper, k keeper.Keeper) simulation.Operation { // nolint:interfacer return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simulation.Account, chainID string, ) (simulation.OperationMsg, []simulation.FutureOperation, error) { @@ -171,7 +171,7 @@ func SimulateMsgCreateValidator(ak types.AccountKeeper, k keeper.Keeper) simulat // SimulateMsgEditValidator generates a MsgEditValidator with random values // nolint: funlen -func SimulateMsgEditValidator(ak types.AccountKeeper, k keeper.Keeper) simulation.Operation { +func SimulateMsgEditValidator(ak types.AccountKeeper, k keeper.Keeper) simulation.Operation { // nolint:interfacer return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simulation.Account, chainID string, ) (simulation.OperationMsg, []simulation.FutureOperation, error) { @@ -236,7 +236,7 @@ func SimulateMsgEditValidator(ak types.AccountKeeper, k keeper.Keeper) simulatio // SimulateMsgDelegate generates a MsgDelegate with random values // nolint: funlen -func SimulateMsgDelegate(ak types.AccountKeeper, k keeper.Keeper) simulation.Operation { +func SimulateMsgDelegate(ak types.AccountKeeper, k keeper.Keeper) simulation.Operation { // nolint:interfacer return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simulation.Account, chainID string, ) (simulation.OperationMsg, []simulation.FutureOperation, error) { @@ -303,7 +303,7 @@ func SimulateMsgDelegate(ak types.AccountKeeper, k keeper.Keeper) simulation.Ope // SimulateMsgUndelegate generates a MsgUndelegate with random values // nolint: funlen -func SimulateMsgUndelegate(ak types.AccountKeeper, k keeper.Keeper) simulation.Operation { +func SimulateMsgUndelegate(ak types.AccountKeeper, k keeper.Keeper) simulation.Operation { // nolint:interfacer return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simulation.Account, chainID string, ) (simulation.OperationMsg, []simulation.FutureOperation, error) { @@ -383,7 +383,7 @@ func SimulateMsgUndelegate(ak types.AccountKeeper, k keeper.Keeper) simulation.O // SimulateMsgBeginRedelegate generates a MsgBeginRedelegate with random values // nolint: funlen -func SimulateMsgBeginRedelegate(ak types.AccountKeeper, k keeper.Keeper) simulation.Operation { +func SimulateMsgBeginRedelegate(ak types.AccountKeeper, k keeper.Keeper) simulation.Operation { // nolint:interfacer return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simulation.Account, chainID string, ) (simulation.OperationMsg, []simulation.FutureOperation, error) { diff --git a/x/staking/types/codec.go b/x/staking/types/codec.go index 6fadfd9a68f9..91567ed51fd9 100644 --- a/x/staking/types/codec.go +++ b/x/staking/types/codec.go @@ -13,7 +13,7 @@ func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(MsgBeginRedelegate{}, "cosmos-sdk/MsgBeginRedelegate", nil) } -// generic sealed codec to be used throughout this module +// ModuleCdc is a generic sealed codec to be used throughout this module var ModuleCdc *codec.Codec func init() { diff --git a/x/upgrade/alias.go b/x/upgrade/alias.go index fe36f23097bc..04e748c9799e 100644 --- a/x/upgrade/alias.go +++ b/x/upgrade/alias.go @@ -32,7 +32,7 @@ var ( ) type ( - UpgradeHandler = types.UpgradeHandler + UpgradeHandler = types.UpgradeHandler //nolint:golint Plan = types.Plan SoftwareUpgradeProposal = types.SoftwareUpgradeProposal CancelSoftwareUpgradeProposal = types.CancelSoftwareUpgradeProposal