From caef9a1372cf2557970ac21600d95d59c8ecf2e2 Mon Sep 17 00:00:00 2001 From: trestin Date: Mon, 2 Sep 2024 13:54:45 +0800 Subject: [PATCH] fix lint err --- app/ante/cosmos/fees.go | 16 ++++++---------- precompiles/delegation/tx.go | 2 ++ x/assets/keeper/client_chain.go | 4 ++-- x/avs/client/cli/query.go | 1 + x/avs/keeper/avs.go | 1 + x/avs/keeper/query.go | 1 + x/avs/keeper/task.go | 2 ++ x/operator/client/cli/query.go | 1 + x/operator/keeper/grpc_query.go | 1 + 9 files changed, 17 insertions(+), 12 deletions(-) diff --git a/app/ante/cosmos/fees.go b/app/ante/cosmos/fees.go index 3346d0b0b..e3dd9b341 100644 --- a/app/ante/cosmos/fees.go +++ b/app/ante/cosmos/fees.go @@ -217,17 +217,13 @@ func checkFeeCoinsAgainstMinGasPrices(ctx sdk.Context, feeCoins sdk.Coins, gas u // provided in a transaction. // NOTE: This implementation should be used with a great consideration as it opens potential attack vectors // where txs with multiple coins could not be prioritized as expected. -// getTxPriority returns a naive tx priority based on the amount of the smallest denomination of the gas price -// provided in a transaction. -// NOTE: This implementation should be used with a great consideration as it opens potential attack vectors -// where txs with multiple coins could not be prioritized as expected. -func getTxPriority(fees sdk.Coins, gas uint64) uint64 { - var priority uint64 +func getTxPriority(fees sdk.Coins, gas int64) int64 { + var priority int64 for _, c := range fees { - p := uint64(math.MaxUint64) - gasPrice := c.Amount.QuoRaw(int64(gas)) - if gasPrice.IsUint64() { - p = gasPrice.Uint64() + p := int64(math.MaxInt64) + gasPrice := c.Amount.QuoRaw(gas) + if gasPrice.IsInt64() { + p = gasPrice.Int64() } if priority == 0 || p < priority { priority = p diff --git a/precompiles/delegation/tx.go b/precompiles/delegation/tx.go index 458d63115..14c83a05d 100644 --- a/precompiles/delegation/tx.go +++ b/precompiles/delegation/tx.go @@ -125,6 +125,7 @@ func (p Precompile) AssociateOperatorWithStaker( if !ok || staker == nil { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "[]byte", args[1]) } + // #nosec G115 if uint32(len(staker)) < clientChainAddrLength { return nil, fmt.Errorf(exocmn.ErrInvalidAddrLength, len(staker), clientChainAddrLength) } @@ -176,6 +177,7 @@ func (p Precompile) DissociateOperatorFromStaker( if !ok || staker == nil { return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "[]byte", args[1]) } + // #nosec G115 if uint32(len(staker)) < clientChainAddrLength { return nil, fmt.Errorf(exocmn.ErrInvalidAddrLength, len(staker), clientChainAddrLength) } diff --git a/x/assets/keeper/client_chain.go b/x/assets/keeper/client_chain.go index 37770f3cb..ebd3ff573 100644 --- a/x/assets/keeper/client_chain.go +++ b/x/assets/keeper/client_chain.go @@ -71,8 +71,8 @@ func (k Keeper) GetAllClientChainInfo(ctx sdk.Context) (infos []assetstype.Clien return ret, nil } -func (k Keeper) GetAllClientChainID(ctx sdk.Context) ([]uint64, error) { - ret := make([]uint64, 0) +func (k Keeper) GetAllClientChainID(ctx sdk.Context) ([]uint32, error) { + ret := make([]uint32, 0) opFunc := func(clientChain *assetstype.ClientChainInfo) error { // #nosec G115 ret = append(ret, uint32(clientChain.LayerZeroChainID)) diff --git a/x/avs/client/cli/query.go b/x/avs/client/cli/query.go index 5f6ecd274..185e7bdaa 100644 --- a/x/avs/client/cli/query.go +++ b/x/avs/client/cli/query.go @@ -156,6 +156,7 @@ func QuerySubmitTaskResult() *cobra.Command { flags.AddQueryFlagsToCmd(cmd) return cmd } + func QueryChallengeInfo() *cobra.Command { cmd := &cobra.Command{ Use: "ChallengeInfo ", diff --git a/x/avs/keeper/avs.go b/x/avs/keeper/avs.go index 20258132a..45535caae 100644 --- a/x/avs/keeper/avs.go +++ b/x/avs/keeper/avs.go @@ -111,6 +111,7 @@ func (k *Keeper) GetTaskStatisticalEpochEndAVSs(ctx sdk.Context, epochIdentifier }) return taskResList } + // RegisterAVSWithChainID registers an AVS by its chainID. // It is responsible for generating an AVS address based on the chainID. // The following bare minimum parameters must be supplied: diff --git a/x/avs/keeper/query.go b/x/avs/keeper/query.go index 808c2a6a6..49f6b4dac 100644 --- a/x/avs/keeper/query.go +++ b/x/avs/keeper/query.go @@ -29,6 +29,7 @@ func (k Keeper) QueryAVSAddrByChainID(ctx context.Context, req *types.QueryAVSAd } return &types.QueryAVSAddrByChainIDResponse{AVSAddress: avsAddr.String()}, nil } + func (k Keeper) QuerySubmitTaskResult(ctx context.Context, req *types.QuerySubmitTaskResultReq) (*types.QuerySubmitTaskResultResponse, error) { c := sdk.UnwrapSDKContext(ctx) id, err := strconv.ParseUint(req.TaskId, 10, 64) diff --git a/x/avs/keeper/task.go b/x/avs/keeper/task.go index 641543c17..273ea6a60 100644 --- a/x/avs/keeper/task.go +++ b/x/avs/keeper/task.go @@ -193,6 +193,7 @@ func (k *Keeper) SetTaskResultInfo( ) } // check epoch,The first stage submission must be within the response window period + // #nosec G115 if epoch.CurrentEpoch > int64(task.StartingEpoch)+int64(task.TaskResponsePeriod) { return errorsmod.Wrap( types.ErrSubmitTooLateError, @@ -228,6 +229,7 @@ func (k *Keeper) SetTaskResultInfo( ) } // check epoch,The second stage submission must be within the statistical window period + // #nosec G115 if epoch.CurrentEpoch <= int64(task.StartingEpoch)+int64(task.TaskResponsePeriod) || epoch.CurrentEpoch > int64(task.StartingEpoch)+int64(task.TaskResponsePeriod)+int64(task.TaskStatisticalPeriod) { return errorsmod.Wrap( diff --git a/x/operator/client/cli/query.go b/x/operator/client/cli/query.go index c682204d0..a11372f39 100644 --- a/x/operator/client/cli/query.go +++ b/x/operator/client/cli/query.go @@ -2,6 +2,7 @@ package cli import ( "context" + "github.com/ExocoreNetwork/exocore/x/avs/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" diff --git a/x/operator/keeper/grpc_query.go b/x/operator/keeper/grpc_query.go index 288f3aae2..c65bd03cf 100644 --- a/x/operator/keeper/grpc_query.go +++ b/x/operator/keeper/grpc_query.go @@ -225,6 +225,7 @@ func (k *Keeper) QueryOperatorSlashInfo(goCtx context.Context, req *types.QueryO Pagination: pageRes, }, nil } + func (k *Keeper) QueryAllOperatorsWithOptInAVS(goCtx context.Context, req *types.QueryAllOperatorsWithOptInAVSRequest) (*types.QueryAllOperatorsWithOptInAVSResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) operatorList, err := k.GetOptedInOperatorListByAVS(ctx, req.Avs)