diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d29b652..bcaff7f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -23,3 +23,4 @@ jobs: with: # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version version: latest + only-new-issues: true diff --git a/abci/abci.go b/abci/abci.go index 09ec02a..0b4f384 100644 --- a/abci/abci.go +++ b/abci/abci.go @@ -114,15 +114,15 @@ func (h *ProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHandler { selectedTxs = append(selectedTxs, refTxRaw) } - break selectBidTxLoop - } else { - h.logger.Info( - "failed to select auction bid tx; tx size is too large; skipping auction", - "tx_size", bidTxSize, - "max_size", req.MaxTxBytes, - ) break selectBidTxLoop } + + h.logger.Info( + "failed to select auction bid tx; tx size is too large; skipping auction", + "tx_size", bidTxSize, + "max_size", req.MaxTxBytes, + ) + break selectBidTxLoop } iterator := h.mempool.Select(ctx, req.Txs) diff --git a/x/auction/keeper/auction.go b/x/auction/keeper/auction.go index 6a01563..9757aed 100644 --- a/x/auction/keeper/auction.go +++ b/x/auction/keeper/auction.go @@ -30,7 +30,7 @@ func (k Keeper) ValidateAuctionMsg(ctx sdk.Context, bidder sdk.AccAddress, bid, } if protectionEnabled { - if err := k.ValidateAuctionBundle(ctx, bidder, transactions); err != nil { + if err := k.ValidateAuctionBundle(bidder, transactions); err != nil { return err } } @@ -88,7 +88,7 @@ func (k Keeper) ValidateAuctionBid(ctx sdk.Context, bidder sdk.AccAddress, bid, // 2. valid: [tx1, tx2, tx3, tx4] where tx1 - tx4 are signed by the bidder. // 3. invalid: [tx1, tx2, tx3] where tx1 and tx3 are signed by the bidder and tx2 is signed by some other signer. (possible sandwich attack) // 4. invalid: [tx1, tx2, tx3] where tx1 is signed by the bidder, and tx2 - tx3 are signed by some other signer. (possible front-running attack) -func (k Keeper) ValidateAuctionBundle(ctx sdk.Context, bidder sdk.AccAddress, transactions []sdk.Tx) error { +func (k Keeper) ValidateAuctionBundle(bidder sdk.AccAddress, transactions []sdk.Tx) error { if len(transactions) <= 1 { return nil } diff --git a/x/auction/keeper/auction_test.go b/x/auction/keeper/auction_test.go index ec73b37..b392cae 100644 --- a/x/auction/keeper/auction_test.go +++ b/x/auction/keeper/auction_test.go @@ -290,7 +290,7 @@ func (suite *KeeperTestSuite) TestValidateBundle() { } // Validate the bundle - err := suite.auctionKeeper.ValidateAuctionBundle(suite.ctx, bidder.Address, bundle) + err := suite.auctionKeeper.ValidateAuctionBundle(bidder.Address, bundle) if tc.pass { suite.Require().NoError(err) } else { diff --git a/x/auction/keeper/grpc_query.go b/x/auction/keeper/grpc_query.go index 9aee8df..8674452 100644 --- a/x/auction/keeper/grpc_query.go +++ b/x/auction/keeper/grpc_query.go @@ -20,7 +20,7 @@ func NewQueryServer(keeper Keeper) *QueryServer { } // Params queries all parameters of the auction module. -func (q QueryServer) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { +func (q QueryServer) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { ctx := sdk.UnwrapSDKContext(c) params, err := q.keeper.GetParams(ctx) diff --git a/x/auction/module.go b/x/auction/module.go index 68922a5..f47050e 100644 --- a/x/auction/module.go +++ b/x/auction/module.go @@ -52,7 +52,7 @@ func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { } // ValidateGenesis performs genesis state validation for the auction module. -func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { var genState types.GenesisState if err := cdc.UnmarshalJSON(bz, &genState); err != nil { return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) @@ -97,12 +97,12 @@ func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } // RegisterServices registers a the gRPC Query and Msg services for the x/auction // module. -func (am AppModule) RegisterServices(cfg module.Configurator) { +func (am AppModule) RegisterServices(_ module.Configurator) { // TODO: Define the gRPC querier service and register it with the auction module configurator // TODO: Define the gRPC Msg service and register it with the auction module configurator } -func (a AppModuleBasic) RegisterRESTRoutes(ctx client.Context, r *mux.Router) {} +func (a AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} // RegisterInvariants registers the invariants of the module. If an invariant // deviates from its predicted value, the InvariantRegistry triggers appropriate diff --git a/x/auction/types/genesis.go b/x/auction/types/genesis.go index 886b78b..274da8c 100644 --- a/x/auction/types/genesis.go +++ b/x/auction/types/genesis.go @@ -16,9 +16,5 @@ func DefaultGenesisState() *GenesisState { // Validate performs basic validation of the auction module genesis state. func (gs GenesisState) Validate() error { - if err := gs.Params.Validate(); err != nil { - return err - } - - return nil + return gs.Params.Validate() } diff --git a/x/auction/types/msgs.go b/x/auction/types/msgs.go index 3e044e8..3fb74ea 100644 --- a/x/auction/types/msgs.go +++ b/x/auction/types/msgs.go @@ -30,11 +30,7 @@ func (m MsgUpdateParams) ValidateBasic() error { return errors.Wrap(err, "invalid authority address") } - if err := m.Params.Validate(); err != nil { - return err - } - - return nil + return m.Params.Validate() } // GetSignBytes implements the LegacyMsg interface. diff --git a/x/auction/types/params.go b/x/auction/types/params.go index 4cc5157..bada567 100644 --- a/x/auction/types/params.go +++ b/x/auction/types/params.go @@ -67,11 +67,7 @@ func (p Params) Validate() error { return fmt.Errorf("invalid minimum bid increment (%s)", err) } - if err := validateProposerFee(p.ProposerFee); err != nil { - return err - } - - return nil + return validateProposerFee(p.ProposerFee) } func validateProposerFee(v sdk.Dec) error {