From ec15f9f45dfeed1573b91f425b1ce337d5e86026 Mon Sep 17 00:00:00 2001 From: Jan Olszak Date: Tue, 16 Jan 2024 11:54:28 +0100 Subject: [PATCH 1/2] Update golangci-lint --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 56a6054..a1a7d40 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,7 @@ $(BIN)/%: | $(BIN) ; $(info $(M) installing $(REPOSITORY)…) GOLANGCILINT = $(BIN)/golangci-lint $(BIN)/golangci-lint: - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.53.3 + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.55.2 GENTOOL = $(BIN)/gentool $(BIN)/gentool: REPOSITORY=gorm.io/gen/tools/gentool@latest From 0f3d8b9c51ea13ce9a3e3bc927d74644e7c9ea08 Mon Sep 17 00:00:00 2001 From: Jan Olszak Date: Tue, 16 Jan 2024 14:49:24 +0100 Subject: [PATCH 2/2] Fix linter errors --- app/export.go | 25 +++++++++++++++---- app/ibc.go | 5 ---- cmd/sequencerd/cmd/root.go | 5 +++- testutil/keeper/sequencer.go | 3 ++- .../tx_interaction_l2_signature_verify.go | 3 +-- ...tx_interaction_l2_signature_verify_test.go | 3 +-- .../keeper/msg_server_arweave_block_test.go | 3 +-- .../keeper/msg_server_data_item_test.go | 4 +-- x/sequencer/module/genesis.go | 5 +++- x/sequencer/module/simulation.go | 6 ++--- 10 files changed, 37 insertions(+), 25 deletions(-) diff --git a/app/export.go b/app/export.go index 21203b2..c9eaf5d 100644 --- a/app/export.go +++ b/app/export.go @@ -165,7 +165,7 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str /* Handle staking state. */ // iterate through redelegations, reset creation height - app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) { + err = app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) { for i := range red.Entries { red.Entries[i].CreationHeight = 0 } @@ -175,9 +175,12 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str } return false }) + if err != nil { + panic(fmt.Errorf("error when iterating through redelegations: %w", err)) + } // iterate through unbonding delegations, reset creation height - app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) { + err = app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) { for i := range ubd.Entries { ubd.Entries[i].CreationHeight = 0 } @@ -187,6 +190,9 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str } return false }) + if err != nil { + panic(fmt.Errorf("error when iterating through unbonding delegations: %w", err)) + } // Iterate through validators by power descending, reset bond heights, and // update bond intra-tx counters. @@ -206,7 +212,10 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str validator.Jailed = true } - app.StakingKeeper.SetValidator(ctx, validator) + err = app.StakingKeeper.SetValidator(ctx, validator) + if err != nil { + panic(fmt.Errorf("error when iterating through unbonding delegations: %w", err)) + } counter++ } @@ -223,12 +232,18 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str /* Handle slashing state. */ // reset start height on signing infos - app.SlashingKeeper.IterateValidatorSigningInfos( + err = app.SlashingKeeper.IterateValidatorSigningInfos( ctx, func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) { info.StartHeight = 0 - app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info) + err := app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info) + if err != nil { + panic(err) + } return false }, ) + if err != nil { + panic(err) + } } diff --git a/app/ibc.go b/app/ibc.go index 2b0bd56..2186e45 100644 --- a/app/ibc.go +++ b/app/ibc.go @@ -26,8 +26,6 @@ import ( ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" ibc "github.com/cosmos/ibc-go/v8/modules/core" - ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" - ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" @@ -53,9 +51,6 @@ func (app *App) registerIBCModules() { } // register the key tables for legacy param subspaces - keyTable := ibcclienttypes.ParamKeyTable() - keyTable.RegisterParamSet(&ibcconnectiontypes.Params{}) - app.ParamsKeeper.Subspace(ibcexported.ModuleName).WithKeyTable(keyTable) app.ParamsKeeper.Subspace(ibctransfertypes.ModuleName).WithKeyTable(ibctransfertypes.ParamKeyTable()) app.ParamsKeeper.Subspace(icacontrollertypes.SubModuleName).WithKeyTable(icacontrollertypes.ParamKeyTable()) app.ParamsKeeper.Subspace(icahosttypes.SubModuleName).WithKeyTable(icahosttypes.ParamKeyTable()) diff --git a/cmd/sequencerd/cmd/root.go b/cmd/sequencerd/cmd/root.go index 8c85dd0..0a4a74e 100644 --- a/cmd/sequencerd/cmd/root.go +++ b/cmd/sequencerd/cmd/root.go @@ -129,7 +129,10 @@ func overwriteFlagDefaults(c *cobra.Command, defaults map[string]string) { set := func(s *pflag.FlagSet, key, val string) { if f := s.Lookup(key); f != nil { f.DefValue = val - f.Value.Set(val) + err := f.Value.Set(val) + if err != nil { + panic(err) + } } } for key, val := range defaults { diff --git a/testutil/keeper/sequencer.go b/testutil/keeper/sequencer.go index 597ab95..9c78b9d 100644 --- a/testutil/keeper/sequencer.go +++ b/testutil/keeper/sequencer.go @@ -43,7 +43,8 @@ func SequencerKeeper(t testing.TB) (keeper.Keeper, sdk.Context) { ctx := sdk.NewContext(stateStore, cmtproto.Header{}, false, log.NewNopLogger()) // Initialize params - k.SetParams(ctx, types.DefaultParams()) + err := k.SetParams(ctx, types.DefaultParams()) + require.NoError(t, err) return k, ctx } diff --git a/x/sequencer/ante/tx_interaction_l2_signature_verify.go b/x/sequencer/ante/tx_interaction_l2_signature_verify.go index 0834a19..11c6706 100644 --- a/x/sequencer/ante/tx_interaction_l2_signature_verify.go +++ b/x/sequencer/ante/tx_interaction_l2_signature_verify.go @@ -11,7 +11,6 @@ import ( txsigning "github.com/cosmos/cosmos-sdk/types/tx/signing" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/cosmos/cosmos-sdk/x/auth/signing" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/warp-contracts/sequencer/x/sequencer/types" ) @@ -108,7 +107,7 @@ func verifyNonceAndIncreaseSequence(ctx sdk.Context, ak *authkeeper.AccountKeepe return nil } -func getOrCreateAccount(ctx sdk.Context, ak *authkeeper.AccountKeeper, addr sdk.AccAddress, dataItem *types.MsgDataItem) (authtypes.AccountI, error) { +func getOrCreateAccount(ctx sdk.Context, ak *authkeeper.AccountKeeper, addr sdk.AccAddress, dataItem *types.MsgDataItem) (sdk.AccountI, error) { acc := ak.GetAccount(ctx, addr) if acc != nil { diff --git a/x/sequencer/ante/tx_interaction_l2_signature_verify_test.go b/x/sequencer/ante/tx_interaction_l2_signature_verify_test.go index b400fde..9c65f50 100644 --- a/x/sequencer/ante/tx_interaction_l2_signature_verify_test.go +++ b/x/sequencer/ante/tx_interaction_l2_signature_verify_test.go @@ -14,7 +14,6 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/tx/signing" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/warp-contracts/sequencer/crypto/keys/arweave" "github.com/warp-contracts/sequencer/crypto/keys/ethereum" @@ -36,7 +35,7 @@ func appAndCtx(t *testing.T) (*simapp.SimApp, sdk.Context) { return app, ctx } -func addCreatorAccount(t *testing.T, app *simapp.SimApp, ctx sdk.Context, dataItem types.MsgDataItem) authtypes.AccountI { +func addCreatorAccount(t *testing.T, app *simapp.SimApp, ctx sdk.Context, dataItem types.MsgDataItem) sdk.AccountI { acc := app.AccountKeeper.NewAccountWithAddress(ctx, dataItem.GetSenderAddress()) err := acc.SetSequence(5) diff --git a/x/sequencer/keeper/msg_server_arweave_block_test.go b/x/sequencer/keeper/msg_server_arweave_block_test.go index 77b9377..05d6308 100644 --- a/x/sequencer/keeper/msg_server_arweave_block_test.go +++ b/x/sequencer/keeper/msg_server_arweave_block_test.go @@ -30,9 +30,8 @@ func keeperCtxAndSrv(t *testing.T) (*keeper.Keeper, sdk.Context, types.MsgServer func TestArweaveBlockMsgServer(t *testing.T) { expected := test.ArweaveBlock() k, ctx, srv := keeperCtxAndSrv(t) - wctx := sdk.WrapSDKContext(ctx) - _, err := srv.ArweaveBlock(wctx, &expected) + _, err := srv.ArweaveBlock(ctx, &expected) require.NoError(t, err) result, found := k.GetLastArweaveBlock(ctx) diff --git a/x/sequencer/keeper/msg_server_data_item_test.go b/x/sequencer/keeper/msg_server_data_item_test.go index a4a5870..b9dee1a 100644 --- a/x/sequencer/keeper/msg_server_data_item_test.go +++ b/x/sequencer/keeper/msg_server_data_item_test.go @@ -3,7 +3,6 @@ package keeper_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" "github.com/warp-contracts/sequencer/x/sequencer/test" @@ -13,9 +12,8 @@ func TestDataItemMsgServer(t *testing.T) { msg := test.ArweaveL2Interaction(t) msg.SortKey = "1,2,3" k, ctx, srv := keeperCtxAndSrv(t) - wctx := sdk.WrapSDKContext(ctx) - _, err := srv.DataItem(wctx, &msg) + _, err := srv.DataItem(ctx, &msg) require.NoError(t, err) result, found := k.GetPrevSortKey(ctx, "abc") diff --git a/x/sequencer/module/genesis.go b/x/sequencer/module/genesis.go index 8232730..f12f0e5 100644 --- a/x/sequencer/module/genesis.go +++ b/x/sequencer/module/genesis.go @@ -139,7 +139,10 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState, } // this line is used by starport scaffolding # genesis/module/init - k.SetParams(ctx, genState.Params) + err := k.SetParams(ctx, genState.Params) + if err != nil { + panic(err) + } } // ExportGenesis returns the module's exported genesis diff --git a/x/sequencer/module/simulation.go b/x/sequencer/module/simulation.go index a75c0f4..42f0192 100644 --- a/x/sequencer/module/simulation.go +++ b/x/sequencer/module/simulation.go @@ -23,10 +23,10 @@ var ( ) const ( - opWeightMsgDataItem = "op_weight_msg_data_item" + opWeightMsgDataItem = "op_weight_msg_data_item" defaultWeightMsgDataItem int = 100 - opWeightMsgArweaveBlock = "op_weight_msg_arweave_block" + opWeightMsgArweaveBlock = "op_weight_msg_arweave_block" defaultWeightMsgArweaveBlock int = 100 // this line is used by starport scaffolding # simapp/module/const @@ -49,7 +49,7 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { func (am AppModule) RegisterStoreDecoder(_ simtypes.StoreDecoderRegistry) {} // ProposalContents doesn't return any content functions for governance proposals. -func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { +func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalMsg { return nil }