[ENG-613]: Linting fixes (#32)

Co-authored-by: Aleksandr Bezobchuk <aleks.bezobchuk@gmail.com>
This commit is contained in:
David Terpay 2023-03-20 12:58:19 -04:00 committed by GitHub
parent 99b4bc2da2
commit 9e350bc7f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 18 additions and 29 deletions

View File

@ -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

View File

@ -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)

View File

@ -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
}

View File

@ -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 {

View File

@ -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)

View File

@ -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

View File

@ -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()
}

View File

@ -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.

View File

@ -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 {