From e58c0fe34b428e4ecc427d5f18767a72bf14b19b Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 9 May 2024 19:08:57 -0600 Subject: [PATCH 01/12] update ci --- .github/workflows/build.yml | 2 +- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/gosec.yml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/test.yml | 1 + 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fc7f84c7a097..1af317b4379b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,7 +5,7 @@ on: merge_group: push: branches: - - main + - osmo** - release/** permissions: contents: read diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 109423d8cf27..dc6f24b30f87 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -6,7 +6,7 @@ on: - "**.go" push: branches: - - main + - osmo** - release/** paths: - "**.go" diff --git a/.github/workflows/gosec.yml b/.github/workflows/gosec.yml index f626970ae3ed..5595c78643c2 100644 --- a/.github/workflows/gosec.yml +++ b/.github/workflows/gosec.yml @@ -7,7 +7,7 @@ on: - "go.sum" push: branches: - - main + - osmo** paths: - "**/*.go" - "go.mod" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 93247f7a1b9b..c2c004c791f3 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,7 +2,7 @@ name: Lint on: push: branches: - - main + - osmo** - release/** pull_request: merge_group: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 24ca58bfb2a4..cb72595f7000 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,6 +4,7 @@ on: merge_group: push: branches: + - osmo** - release/v0.50.x permissions: From 739a2a3d4ddb70d30add4c337f068bdd7748ef61 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 9 May 2024 19:35:56 -0600 Subject: [PATCH 02/12] test trigger --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index aebce021c8ea..c498d3612e0a 100644 --- a/Makefile +++ b/Makefile @@ -52,6 +52,8 @@ whitespace += $(whitespace) comma := , build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags)) +# test + # process linker flags ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=sim \ From ed4d31a8654a6b4023f9a5170d0d6291ddcc9092 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 9 May 2024 20:19:54 -0600 Subject: [PATCH 03/12] fix lint --- tests/e2e/auth/vesting/suite.go | 3 ++- .../auth/keeper/vesting_account_test.go | 15 +++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/e2e/auth/vesting/suite.go b/tests/e2e/auth/vesting/suite.go index 6b5f0816fe2f..3dd77cbb00e0 100644 --- a/tests/e2e/auth/vesting/suite.go +++ b/tests/e2e/auth/vesting/suite.go @@ -3,10 +3,11 @@ package testutil import ( "fmt" - "cosmossdk.io/math" "github.com/cosmos/gogoproto/proto" "github.com/stretchr/testify/suite" + "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec/address" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" diff --git a/tests/integration/auth/keeper/vesting_account_test.go b/tests/integration/auth/keeper/vesting_account_test.go index 6080dd6e27c4..3c7203cf1737 100644 --- a/tests/integration/auth/keeper/vesting_account_test.go +++ b/tests/integration/auth/keeper/vesting_account_test.go @@ -4,24 +4,23 @@ import ( "testing" "time" - "cosmossdk.io/math" - "cosmossdk.io/simapp" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + tmtime "github.com/cometbft/cometbft/types/time" "github.com/stretchr/testify/require" + "cosmossdk.io/math" + "cosmossdk.io/simapp" + + addresscodec "github.com/cosmos/cosmos-sdk/codec/address" "github.com/cosmos/cosmos-sdk/runtime" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" banktestutil "github.com/cosmos/cosmos-sdk/x/bank/testutil" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - tmtime "github.com/cometbft/cometbft/types/time" - addresscodec "github.com/cosmos/cosmos-sdk/codec/address" - "github.com/cosmos/cosmos-sdk/testutil/testdata" ) var ( @@ -216,7 +215,7 @@ func createValidator(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers i addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, valTokens) valAddrs := simtestutil.ConvertAddrsToValAddrs(addrs) pks := simtestutil.CreateTestPubKeys(1) - cdc := app.AppCodec() //simapp.MakeTestEncodingConfig().Marshaler + cdc := app.AppCodec() authority := types.NewModuleAddress("gov") app.StakingKeeper = stakingkeeper.NewKeeper(cdc, runtime.NewKVStoreService(app.GetKey(stakingtypes.StoreKey)), app.AccountKeeper, app.BankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr)) From 9a01e7e29167571966e319126f6f128025c7524d Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 9 May 2024 20:28:16 -0600 Subject: [PATCH 04/12] fix unncessary conversion --- store/rootmulti/store_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/store/rootmulti/store_test.go b/store/rootmulti/store_test.go index 97d4ae0c9899..bbdf9888bbdc 100644 --- a/store/rootmulti/store_test.go +++ b/store/rootmulti/store_test.go @@ -588,7 +588,7 @@ func TestMultiStore_Pruning_SameHeightsTwice(t *testing.T) { require.Error(t, err, "expected error when loading pruned height: %d", v) } - for v := int64(numVersions - int64(keepRecent)); v < numVersions; v++ { + for v := numVersions - int64(keepRecent); v < numVersions; v++ { err := ms.LoadVersion(v) require.NoError(t, err, "expected no error when loading height: %d", v) } From 506235e246b2d93c31b44fe7b504896fa7c09ccc Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 9 May 2024 20:54:15 -0600 Subject: [PATCH 05/12] lints --- types/coin.go | 4 +-- types/dec_coin.go | 6 ++-- x/auth/vesting/client/cli/tx.go | 3 +- x/auth/vesting/types/period.go | 4 +-- x/auth/vesting/types/vesting_account.go | 47 ++++++++++++------------- x/bank/hooks_test.go | 9 ++++- x/bank/keeper/keeper_test.go | 1 - 7 files changed, 38 insertions(+), 36 deletions(-) diff --git a/types/coin.go b/types/coin.go index 2382a4f3fbc1..cd18cc4d123d 100644 --- a/types/coin.go +++ b/types/coin.go @@ -851,11 +851,11 @@ func SetCoinDenomRegex(reFn func() string) { // ValidateDenom is the default validation function for Coin.Denom. func ValidateDenom(denom string) error { - if reDnm == nil || reDecCoin == nil { //nolint:gocritic + if reDnm == nil || reDecCoin == nil { // Convert the string to a byte slice as required by the Ragel-generated function. // Call the Ragel-generated function. - if !MatchDenom(denom) { //nolint:gocritic + if !MatchDenom(denom) { return fmt.Errorf("invalid denom: %s", denom) } } else if !reDnm.MatchString(denom) { // If reDnm has been initialized, use it for matching. diff --git a/types/dec_coin.go b/types/dec_coin.go index b78c687c140b..256d0596c73c 100644 --- a/types/dec_coin.go +++ b/types/dec_coin.go @@ -627,7 +627,7 @@ func (coins DecCoins) Sort() DecCoins { func ParseDecCoin(coinStr string) (coin DecCoin, err error) { var amountStr, denomStr string // if custom parsing has not been set, use default coin regex - if reDecCoin == nil { //nolint:gocritic + if reDecCoin == nil { amountStr, denomStr, err = ParseDecAmount(coinStr) if err != nil { return DecCoin{}, err @@ -665,8 +665,8 @@ func ParseDecAmount(coinStr string) (string, string, error) { parsingAmount := true for _, r := range strings.TrimSpace(coinStr) { - if parsingAmount { //nolint:gocritic - if unicode.IsDigit(r) || r == '.' { //nolint:gocritic + if parsingAmount { + if unicode.IsDigit(r) || r == '.' { amountRune = append(amountRune, r) } else if unicode.IsSpace(r) { // if space is seen, indicates that we have finished parsing amount parsingAmount = false diff --git a/x/auth/vesting/client/cli/tx.go b/x/auth/vesting/client/cli/tx.go index c8c9b0050134..d00e9681230c 100644 --- a/x/auth/vesting/client/cli/tx.go +++ b/x/auth/vesting/client/cli/tx.go @@ -4,7 +4,6 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" "os" "strconv" "time" @@ -227,7 +226,7 @@ func NewMsgCreatePeriodicVestingAccountCmd(ac address.Codec) *cobra.Command { // readScheduleFile reads the file at path and unmarshals it to get the schedule. // Returns start time, periods, and error. func readScheduleFile(path string) (int64, []types.Period, error) { - contents, err := ioutil.ReadFile(path) + contents, err := os.ReadFile(path) if err != nil { return 0, nil, err } diff --git a/x/auth/vesting/types/period.go b/x/auth/vesting/types/period.go index ea7330f076e2..9f051413d5ca 100644 --- a/x/auth/vesting/types/period.go +++ b/x/auth/vesting/types/period.go @@ -246,7 +246,7 @@ func ConjunctPeriods(startP, startQ int64, periodsP, periodsQ []Period) (startTi } // consumeBoth processes simultaneous events in P and Q and emits an - // event if the minumum of P and Q changes + // event if the minimum of P and Q changes consumeBoth := func(nextTime int64) { amountP = amountP.Add(periodsP[iP].Amount...) amountQ = amountQ.Add(periodsQ[iQ].Amount...) @@ -289,7 +289,7 @@ func ConjunctPeriods(startP, startQ int64, periodsP, periodsQ []Period) (startTi } endTime = time - return + return startTime, endTime, merged } // AlignSchedules rewrites the first period length to align the two arguments to the same start time, diff --git a/x/auth/vesting/types/vesting_account.go b/x/auth/vesting/types/vesting_account.go index 8a12816650cb..9e54a775e792 100644 --- a/x/auth/vesting/types/vesting_account.go +++ b/x/auth/vesting/types/vesting_account.go @@ -7,13 +7,10 @@ import ( errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" - "gopkg.in/yaml.v3" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" vestexported "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" ) @@ -525,24 +522,24 @@ func (plva PermanentLockedAccount) Validate() error { return plva.BaseVestingAccount.Validate() } -type getPK interface { - GetPubKey() cryptotypes.PubKey -} +// type getPK interface { +// GetPubKey() cryptotypes.PubKey +// } -func getPKString(g getPK) string { - if pk := g.GetPubKey(); pk != nil { - return pk.String() - } - return "" -} +// func getPKString(g getPK) string { +// if pk := g.GetPubKey(); pk != nil { +// return pk.String() +// } +// return "" +// } -func marshalYaml(i interface{}) (interface{}, error) { - bz, err := yaml.Marshal(i) - if err != nil { - return nil, err - } - return string(bz), nil -} +// func marshalYaml(i interface{}) (interface{}, error) { +// bz, err := yaml.Marshal(i) +// if err != nil { +// return nil, err +// } +// return string(bz), nil +// } // Clawback Vesting Account @@ -683,7 +680,7 @@ func NewClawbackGrantAction( grantStartTime int64, grantLockupPeriods, grantVestingPeriods []Period, grantCoins sdk.Coins, -) exported.AddGrantAction { +) vestexported.AddGrantAction { return clawbackGrantAction{ funderAddress: funderAddress, grantStartTime: grantStartTime, @@ -693,7 +690,7 @@ func NewClawbackGrantAction( } } -func (cga clawbackGrantAction) AddToAccount(ctx sdk.Context, rawAccount exported.VestingAccount) error { +func (cga clawbackGrantAction) AddToAccount(ctx sdk.Context, rawAccount vestexported.VestingAccount) error { cva, ok := rawAccount.(*ClawbackVestingAccount) if !ok { return fmt.Errorf("expected *ClawbackVestingAccount, got %T", rawAccount) @@ -710,7 +707,7 @@ func (cga clawbackGrantAction) AddToAccount(ctx sdk.Context, rawAccount exported } -func (va *ClawbackVestingAccount) AddGrant(ctx sdk.Context, action exported.AddGrantAction) error { +func (va *ClawbackVestingAccount) AddGrant(ctx sdk.Context, action vestexported.AddGrantAction) error { return action.AddToAccount(ctx, va) } @@ -794,7 +791,7 @@ type clawbackAction struct { bk BankKeeper } -func NewClawbackAction(requestor, dest sdk.AccAddress, ak AccountKeeper, bk BankKeeper) exported.ClawbackAction { +func NewClawbackAction(requestor, dest sdk.AccAddress, ak AccountKeeper, bk BankKeeper) vestexported.ClawbackAction { return clawbackAction{ requestor: requestor, dest: dest, @@ -803,7 +800,7 @@ func NewClawbackAction(requestor, dest sdk.AccAddress, ak AccountKeeper, bk Bank } } -func (ca clawbackAction) TakeFromAccount(ctx sdk.Context, rawAccount exported.VestingAccount) error { +func (ca clawbackAction) TakeFromAccount(ctx sdk.Context, rawAccount vestexported.VestingAccount) error { cva, ok := rawAccount.(*ClawbackVestingAccount) if !ok { return fmt.Errorf("clawback expects *ClawbackVestingAccount, got %T", rawAccount) @@ -814,7 +811,7 @@ func (ca clawbackAction) TakeFromAccount(ctx sdk.Context, rawAccount exported.Ve return cva.clawback(ctx, ca.dest, ca.ak, ca.bk) } -func (va *ClawbackVestingAccount) Clawback(ctx sdk.Context, action exported.ClawbackAction) error { +func (va *ClawbackVestingAccount) Clawback(ctx sdk.Context, action vestexported.ClawbackAction) error { return action.TakeFromAccount(ctx, va) } diff --git a/x/bank/hooks_test.go b/x/bank/hooks_test.go index efb4aad722c7..ee9f22d11abc 100644 --- a/x/bank/hooks_test.go +++ b/x/bank/hooks_test.go @@ -43,7 +43,7 @@ var ( func (h *MockBankHooksReceiver) TrackBeforeSend(ctx context.Context, from, to sdk.AccAddress, amount sdk.Coins) { for _, coin := range amount { if coin.Amount.Equal(math.NewInt(50)) { - countTrackBeforeSend += 1 + countTrackBeforeSend++ } } } @@ -96,6 +96,7 @@ func TestHooks(t *testing.T) { require.Error(t, err) err = app.BankKeeper.SendManyCoins(ctx, addr1, []sdk.AccAddress{addr1, addr2}, []sdk.Coins{triggerTrackSendAmount, validSendAmount}) + require.NoError(t, err) require.Equal(t, countTrackBeforeSend, expNextCount) expNextCount++ @@ -105,6 +106,7 @@ func TestHooks(t *testing.T) { err = app.BankKeeper.SendCoinsFromAccountToModule(ctx, addr1, stakingtypes.BondedPoolName, invalidBlockSendAmount) require.Error(t, err) err = app.BankKeeper.SendCoinsFromAccountToModule(ctx, addr1, stakingtypes.BondedPoolName, triggerTrackSendAmount) + require.NoError(t, err) require.Equal(t, countTrackBeforeSend, expNextCount) expNextCount++ @@ -114,6 +116,7 @@ func TestHooks(t *testing.T) { err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, stakingtypes.BondedPoolName, addr1, invalidBlockSendAmount) require.Error(t, err) err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, stakingtypes.BondedPoolName, addr1, triggerTrackSendAmount) + require.NoError(t, err) require.Equal(t, countTrackBeforeSend, expNextCount) expNextCount++ @@ -124,6 +127,7 @@ func TestHooks(t *testing.T) { // there should be no error since module to module does not call block before send hooks require.NoError(t, err) err = app.BankKeeper.SendCoinsFromModuleToModule(ctx, stakingtypes.BondedPoolName, stakingtypes.NotBondedPoolName, triggerTrackSendAmount) + require.NoError(t, err) require.Equal(t, countTrackBeforeSend, expNextCount) expNextCount++ @@ -133,6 +137,7 @@ func TestHooks(t *testing.T) { err = app.BankKeeper.SendCoinsFromModuleToManyAccounts(ctx, stakingtypes.BondedPoolName, []sdk.AccAddress{addr1, addr2}, []sdk.Coins{validSendAmount, invalidBlockSendAmount}) require.Error(t, err) err = app.BankKeeper.SendCoinsFromModuleToManyAccounts(ctx, stakingtypes.BondedPoolName, []sdk.AccAddress{addr1, addr2}, []sdk.Coins{validSendAmount, triggerTrackSendAmount}) + require.NoError(t, err) require.Equal(t, countTrackBeforeSend, expNextCount) expNextCount++ @@ -142,6 +147,7 @@ func TestHooks(t *testing.T) { err = app.BankKeeper.DelegateCoins(ctx, addr1, app.AccountKeeper.GetModuleAddress(stakingtypes.BondedPoolName), invalidBlockSendAmount) require.Error(t, err) err = app.BankKeeper.DelegateCoins(ctx, addr1, app.AccountKeeper.GetModuleAddress(stakingtypes.BondedPoolName), triggerTrackSendAmount) + require.NoError(t, err) require.Equal(t, countTrackBeforeSend, expNextCount) expNextCount++ @@ -152,6 +158,7 @@ func TestHooks(t *testing.T) { require.Error(t, err) err = app.BankKeeper.UndelegateCoins(ctx, app.AccountKeeper.GetModuleAddress(stakingtypes.BondedPoolName), addr1, triggerTrackSendAmount) + require.NoError(t, err) require.Equal(t, countTrackBeforeSend, expNextCount) expNextCount++ } diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index 6ec549c45798..ac8a30b84f25 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -238,7 +238,6 @@ func (suite *KeeperTestSuite) mockDelegateCoins(ctx context.Context, acc, mAcc s if ok { suite.authKeeper.EXPECT().SetAccount(ctx, vacc) } - //suite.authKeeper.EXPECT().GetAccount(ctx, acc.GetAddress()).Return(acc) suite.authKeeper.EXPECT().GetAccount(ctx, acc.GetAddress()).Return(acc).Times(2) suite.authKeeper.EXPECT().GetAccount(ctx, mAcc.GetAddress()).Return(mAcc) } From 7108d11e614534589a14e02ce31640f5d3b7eecc Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 9 May 2024 21:00:03 -0600 Subject: [PATCH 06/12] more test fixes --- .github/workflows/test.yml | 6 ------ store/rootmulti/store_test.go | 6 ++++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cb72595f7000..f4f76aa41834 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -184,12 +184,6 @@ jobs: with: name: "${{ github.sha }}-e2e-coverage" continue-on-error: true - - name: sonarcloud - if: ${{ env.GIT_DIFF && !github.event.pull_request.draft }} - uses: SonarSource/sonarcloud-github-action@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} liveness-test: runs-on: ubuntu-latest diff --git a/store/rootmulti/store_test.go b/store/rootmulti/store_test.go index bbdf9888bbdc..dc95a545cd3e 100644 --- a/store/rootmulti/store_test.go +++ b/store/rootmulti/store_test.go @@ -618,12 +618,14 @@ func TestMultiStore_PruningRestart(t *testing.T) { // commit one more block and ensure the heights have been pruned ms.Commit() - time.Sleep(150 * time.Millisecond) - ms.Commit() actualHeightToPrune = ms.pruningManager.GetPruningHeight(ms.LatestVersion()) require.Equal(t, int64(8), actualHeightToPrune) + // Ensure async pruning is done + time.Sleep(500 * time.Millisecond) + ms.Commit() + for v := int64(1); v <= actualHeightToPrune; v++ { _, err := ms.CacheMultiStoreWithVersion(v) require.Error(t, err, "expected error when loading height: %d", v) From 00723bf1310a7371df13a5582bf559bb2be3fda3 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 9 May 2024 21:29:04 -0600 Subject: [PATCH 07/12] more lints... --- baseapp/abci_utils.go | 2 +- types/coin.go | 1 - x/auth/vesting/types/period.go | 2 +- x/auth/vesting/types/vesting_account.go | 8 ++++---- x/auth/vesting/types/vesting_account_internal_test.go | 3 ++- x/auth/vesting/types/vesting_account_test.go | 3 ++- x/bank/hooks_test.go | 4 ++-- x/bank/keeper/grpc_query_test.go | 2 +- x/bank/keeper/send.go | 6 +++--- x/bank/keeper/supply_offset.go | 2 +- x/bank/migrations/v4/gen_state_test.go | 2 +- x/staking/keeper/delegation.go | 2 -- 12 files changed, 18 insertions(+), 19 deletions(-) diff --git a/baseapp/abci_utils.go b/baseapp/abci_utils.go index 4cfadbbdca5a..db58a1b3eb35 100644 --- a/baseapp/abci_utils.go +++ b/baseapp/abci_utils.go @@ -4,7 +4,6 @@ import ( "bytes" "context" "fmt" - "slices" "github.com/cockroachdb/errors" abci "github.com/cometbft/cometbft/abci/types" @@ -13,6 +12,7 @@ import ( cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" protoio "github.com/cosmos/gogoproto/io" "github.com/cosmos/gogoproto/proto" + "slices" "cosmossdk.io/core/comet" diff --git a/types/coin.go b/types/coin.go index cd18cc4d123d..5c3518433bf8 100644 --- a/types/coin.go +++ b/types/coin.go @@ -7,7 +7,6 @@ import ( "regexp" "sort" "strings" - "unicode" "cosmossdk.io/math" diff --git a/x/auth/vesting/types/period.go b/x/auth/vesting/types/period.go index 9f051413d5ca..862c4e1bc5a1 100644 --- a/x/auth/vesting/types/period.go +++ b/x/auth/vesting/types/period.go @@ -190,7 +190,7 @@ func DisjunctPeriods(startP, startQ int64, periodsP, periodsQ []Period) (int64, } // ConjunctPeriods returns the combination of two period schedules where the result is the minimum of the two schedules. -func ConjunctPeriods(startP, startQ int64, periodsP, periodsQ []Period) (startTime int64, endTime int64, merged []Period) { +func ConjunctPeriods(startP, startQ int64, periodsP, periodsQ []Period) (startTime, endTime int64, merged []Period) { timeP := startP timeQ := startQ iP := 0 diff --git a/x/auth/vesting/types/vesting_account.go b/x/auth/vesting/types/vesting_account.go index 9e54a775e792..5e35ee6f0a95 100644 --- a/x/auth/vesting/types/vesting_account.go +++ b/x/auth/vesting/types/vesting_account.go @@ -543,8 +543,10 @@ func (plva PermanentLockedAccount) Validate() error { // Clawback Vesting Account -var _ vestexported.VestingAccount = (*ClawbackVestingAccount)(nil) -var _ authtypes.GenesisAccount = (*ClawbackVestingAccount)(nil) +var ( + _ vestexported.VestingAccount = (*ClawbackVestingAccount)(nil) + _ authtypes.GenesisAccount = (*ClawbackVestingAccount)(nil) +) // NewClawbackVestingAccount returns a new ClawbackVestingAccount func NewClawbackVestingAccount( @@ -628,7 +630,6 @@ func CoinEq(a, b sdk.Coins) bool { func (va ClawbackVestingAccount) Validate() error { if va.GetStartTime() >= va.GetEndTime() { return errors.New("vesting start-time must be before end-time") - } lockupEnd := va.GetStartTime() @@ -704,7 +705,6 @@ func (cga clawbackGrantAction) AddToAccount(ctx sdk.Context, rawAccount vestexpo } cva.addGrant(ctx, cga.grantStartTime, cga.grantLockupPeriods, cga.grantVestingPeriods, cga.grantCoins) return nil - } func (va *ClawbackVestingAccount) AddGrant(ctx sdk.Context, action vestexported.AddGrantAction) error { diff --git a/x/auth/vesting/types/vesting_account_internal_test.go b/x/auth/vesting/types/vesting_account_internal_test.go index 520bfef50bcf..83ba35ce2122 100644 --- a/x/auth/vesting/types/vesting_account_internal_test.go +++ b/x/auth/vesting/types/vesting_account_internal_test.go @@ -5,10 +5,11 @@ import ( "time" tmtime "github.com/cometbft/cometbft/types/time" + "github.com/stretchr/testify/require" + "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/stretchr/testify/require" ) var ( diff --git a/x/auth/vesting/types/vesting_account_test.go b/x/auth/vesting/types/vesting_account_test.go index e72f44403773..05dfe9b79173 100644 --- a/x/auth/vesting/types/vesting_account_test.go +++ b/x/auth/vesting/types/vesting_account_test.go @@ -839,7 +839,8 @@ func TestGetVestedCoinsClawbackVestingAcc(t *testing.T) { vestedCoins = va.GetVestedCoins(now.Add(18 * time.Hour)) require.Equal(t, sdk.Coins{ - sdk.NewInt64Coin(feeDenom, 750), sdk.NewInt64Coin(stakeDenom, 75)}, vestedCoins) + sdk.NewInt64Coin(feeDenom, 750), sdk.NewInt64Coin(stakeDenom, 75), + }, vestedCoins) // require 100% of coins vested vestedCoins = va.GetVestedCoins(now.Add(48 * time.Hour)) diff --git a/x/bank/hooks_test.go b/x/bank/hooks_test.go index ee9f22d11abc..d52737de1523 100644 --- a/x/bank/hooks_test.go +++ b/x/bank/hooks_test.go @@ -5,16 +5,16 @@ import ( "fmt" "testing" - "cosmossdk.io/math" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/stretchr/testify/require" + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktestutil "github.com/cosmos/cosmos-sdk/x/bank/testutil" "github.com/cosmos/cosmos-sdk/x/bank/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) diff --git a/x/bank/keeper/grpc_query_test.go b/x/bank/keeper/grpc_query_test.go index 233a1fd1d451..e44cf2e2293a 100644 --- a/x/bank/keeper/grpc_query_test.go +++ b/x/bank/keeper/grpc_query_test.go @@ -6,6 +6,7 @@ import ( "time" "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" @@ -312,7 +313,6 @@ func (suite *KeeperTestSuite) TestQueryTotalSupply() { suite.Require().NotNil(res2) suite.Require().Equal(expectedTotalSupply, res2.Supply) - } func (suite *KeeperTestSuite) TestQueryTotalSupplyOf() { diff --git a/x/bank/keeper/send.go b/x/bank/keeper/send.go index ae092222f2e1..9bdb922618a3 100644 --- a/x/bank/keeper/send.go +++ b/x/bank/keeper/send.go @@ -217,13 +217,13 @@ func (k BaseSendKeeper) InputOutputCoins(ctx context.Context, input types.Input, } // SendCoinsWithoutBlockHook calls sendCoins without calling the `BlockBeforeSend` hook. -func (k BaseSendKeeper) SendCoinsWithoutBlockHook(ctx context.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error { +func (k BaseSendKeeper) SendCoinsWithoutBlockHook(ctx context.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error { return k.sendCoins(ctx, fromAddr, toAddr, amt) } // SendCoins transfers amt coins from a sending account to a receiving account. // An error is returned upon failure. -func (k BaseSendKeeper) SendCoins(ctx context.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error { +func (k BaseSendKeeper) SendCoins(ctx context.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error { // BlockBeforeSend hook should always be called before the TrackBeforeSend hook. err := k.BlockBeforeSend(ctx, fromAddr, toAddr, amt) if err != nil { @@ -234,7 +234,7 @@ func (k BaseSendKeeper) SendCoins(ctx context.Context, fromAddr sdk.AccAddress, } // sendCoins has the internal logic for sending coins. -func (k BaseSendKeeper) sendCoins(ctx context.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error { +func (k BaseSendKeeper) sendCoins(ctx context.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error { // call the TrackBeforeSend hooks k.TrackBeforeSend(ctx, fromAddr, toAddr, amt) diff --git a/x/bank/keeper/supply_offset.go b/x/bank/keeper/supply_offset.go index 7096b90bdd83..155a19fdc074 100644 --- a/x/bank/keeper/supply_offset.go +++ b/x/bank/keeper/supply_offset.go @@ -6,6 +6,7 @@ import ( "cosmossdk.io/math" "cosmossdk.io/store/prefix" + "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" @@ -90,7 +91,6 @@ func (k BaseKeeper) GetPaginatedTotalSupplyWithOffsets(ctx context.Context, pagi supply = supply.Add(sdk.NewCoin(denom, amount)) return nil }) - if err != nil { return nil, nil, err } diff --git a/x/bank/migrations/v4/gen_state_test.go b/x/bank/migrations/v4/gen_state_test.go index 1283e65b7842..1314ce8fd4b8 100644 --- a/x/bank/migrations/v4/gen_state_test.go +++ b/x/bank/migrations/v4/gen_state_test.go @@ -156,6 +156,6 @@ func TestMigrateGenState(t *testing.T) { }, } _ = v4.MigrateGenState(&origState) - assert.Len(t, origState.Params.SendEnabled, 2) //nolint:staticcheck // keep for test (linter sometimes fails) + assert.Len(t, origState.Params.SendEnabled, 2) }) } diff --git a/x/staking/keeper/delegation.go b/x/staking/keeper/delegation.go index 44c5e038d4bf..74aa180ea5c4 100644 --- a/x/staking/keeper/delegation.go +++ b/x/staking/keeper/delegation.go @@ -1157,7 +1157,6 @@ func (k Keeper) Undelegate( func (k Keeper) InstantUndelegate( ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, sharesAmount math.LegacyDec, ) (sdk.Coins, error) { - validator, err := k.GetValidator(ctx, valAddr) if err != nil { return nil, types.ErrNoDelegatorForAddress @@ -1186,7 +1185,6 @@ func (k Keeper) InstantUndelegate( return nil, err } return res, nil - } // CompleteUnbonding completes the unbonding of all mature entries in the From 968d6dec68b4c5b93935bb75ac99dc90fc5d85a2 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 9 May 2024 21:40:19 -0600 Subject: [PATCH 08/12] fmt --- baseapp/abci_utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/baseapp/abci_utils.go b/baseapp/abci_utils.go index db58a1b3eb35..4cfadbbdca5a 100644 --- a/baseapp/abci_utils.go +++ b/baseapp/abci_utils.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "fmt" + "slices" "github.com/cockroachdb/errors" abci "github.com/cometbft/cometbft/abci/types" @@ -12,7 +13,6 @@ import ( cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" protoio "github.com/cosmos/gogoproto/io" "github.com/cosmos/gogoproto/proto" - "slices" "cosmossdk.io/core/comet" From 3a116a064c4ecf0ac2da9b0bbb90a8e8e0d168f1 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 9 May 2024 22:22:58 -0600 Subject: [PATCH 09/12] fmt --- baseapp/abci_utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/baseapp/abci_utils.go b/baseapp/abci_utils.go index 4cfadbbdca5a..db58a1b3eb35 100644 --- a/baseapp/abci_utils.go +++ b/baseapp/abci_utils.go @@ -4,7 +4,6 @@ import ( "bytes" "context" "fmt" - "slices" "github.com/cockroachdb/errors" abci "github.com/cometbft/cometbft/abci/types" @@ -13,6 +12,7 @@ import ( cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" protoio "github.com/cosmos/gogoproto/io" "github.com/cosmos/gogoproto/proto" + "slices" "cosmossdk.io/core/comet" From bc500fb86887c4cb0888c28d610d912eb7a8a50a Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 9 May 2024 22:24:00 -0600 Subject: [PATCH 10/12] fmt --- baseapp/abci_utils.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/baseapp/abci_utils.go b/baseapp/abci_utils.go index db58a1b3eb35..827360a7eb44 100644 --- a/baseapp/abci_utils.go +++ b/baseapp/abci_utils.go @@ -5,6 +5,8 @@ import ( "context" "fmt" + "slices" + "github.com/cockroachdb/errors" abci "github.com/cometbft/cometbft/abci/types" cryptoenc "github.com/cometbft/cometbft/crypto/encoding" @@ -12,7 +14,6 @@ import ( cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" protoio "github.com/cosmos/gogoproto/io" "github.com/cosmos/gogoproto/proto" - "slices" "cosmossdk.io/core/comet" From 7dee208c8b1dfb25838f16391c46c9ba27c98b30 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 9 May 2024 22:31:24 -0600 Subject: [PATCH 11/12] skip lint this file --- .golangci.yml | 1 + baseapp/abci_utils.go | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index 3f61e47a961e..7dbf77f11411 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -8,6 +8,7 @@ run: - server/grpc/gogoreflection/fix_registration.go - "fix_registration.go" - "x/bank/migrations/v4/gen_state_test.go" + - "baseapp/abci_utils.go" - ".*\\.pb\\.go$" - ".*\\.pb\\.gw\\.go$" - ".*\\.pulsar\\.go$" diff --git a/baseapp/abci_utils.go b/baseapp/abci_utils.go index 827360a7eb44..4cfadbbdca5a 100644 --- a/baseapp/abci_utils.go +++ b/baseapp/abci_utils.go @@ -4,7 +4,6 @@ import ( "bytes" "context" "fmt" - "slices" "github.com/cockroachdb/errors" From 3e76cc4f87dbb74e09c1556169fe6475457875b0 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Fri, 10 May 2024 00:16:16 -0500 Subject: [PATCH 12/12] Update codeql-analysis.yml --- .github/workflows/codeql-analysis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index dc6f24b30f87..7a93f64cfe3c 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -6,7 +6,6 @@ on: - "**.go" push: branches: - - osmo** - release/** paths: - "**.go"