From 286c126c6bc77b3e138303e360631c9c3569a470 Mon Sep 17 00:00:00 2001 From: Ruslan Akhtariev Date: Thu, 10 Aug 2023 20:20:06 +0200 Subject: [PATCH 1/6] enable unused parameters linter --- .golangci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.golangci.yml b/.golangci.yml index 3e367e1e7ae..4e92b01dbea 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -40,6 +40,7 @@ linters: - unconvert - unused - whitespace + - unparam issues: exclude-rules: From f7c3cdcb2d4ba3539caf59f62515feed5221efad Mon Sep 17 00:00:00 2001 From: Ruslan Akhtariev Date: Thu, 10 Aug 2023 20:35:46 +0200 Subject: [PATCH 2/6] enable unparam linter and fix basic unparam warnings --- app/upgrades/v15/export_test.go | 4 ++-- app/upgrades/v15/upgrade_test.go | 3 +-- app/upgrades/v15/upgrades.go | 8 ++++---- simulation/executor/mock_tendermint.go | 5 ++--- tests/e2e/configurer/upgrade.go | 5 ++--- tests/e2e/initialization/chain.go | 4 ++-- tests/e2e/initialization/init.go | 11 ++--------- x/concentrated-liquidity/client/cli/tx.go | 1 - x/concentrated-liquidity/export_test.go | 10 +++++----- x/concentrated-liquidity/incentives.go | 2 +- x/concentrated-liquidity/pool.go | 16 ++++++++-------- x/concentrated-liquidity/simulation/sim_msgs.go | 4 ++-- x/gamm/simulation/sim_msgs.go | 4 ++-- x/incentives/client/cli/tx.go | 4 ++-- x/poolmanager/create_pool.go | 4 ++-- x/poolmanager/export_test.go | 2 +- x/protorev/keeper/rebalance.go | 5 ++--- x/superfluid/keeper/export_test.go | 2 +- x/superfluid/keeper/migrate.go | 8 +++----- x/superfluid/keeper/stake.go | 10 +++++----- x/tokenfactory/keeper/createdenom.go | 4 ++-- 21 files changed, 51 insertions(+), 65 deletions(-) diff --git a/app/upgrades/v15/export_test.go b/app/upgrades/v15/export_test.go index 8369670efc7..0049ed724d0 100644 --- a/app/upgrades/v15/export_test.go +++ b/app/upgrades/v15/export_test.go @@ -26,8 +26,8 @@ func SetICQParams(ctx sdk.Context, icqKeeper *icqkeeper.Keeper) { setICQParams(ctx, icqKeeper) } -func MigrateBalancerPoolToSolidlyStable(ctx sdk.Context, gammKeeper *gammkeeper.Keeper, poolmanager *poolmanager.Keeper, bankKeeper bankkeeper.Keeper, poolId uint64) { - migrateBalancerPoolToSolidlyStable(ctx, gammKeeper, poolmanager, bankKeeper, poolId) +func MigrateBalancerPoolToSolidlyStable(ctx sdk.Context, gammKeeper *gammkeeper.Keeper, bankKeeper bankkeeper.Keeper, poolId uint64) { + migrateBalancerPoolToSolidlyStable(ctx, gammKeeper, bankKeeper, poolId) } func SetRateLimits(ctx sdk.Context, accountKeeper *authkeeper.AccountKeeper, rateLimitingICS4Wrapper *ibcratelimit.ICS4Wrapper, wasmKeeper *wasmkeeper.Keeper) { diff --git a/app/upgrades/v15/upgrade_test.go b/app/upgrades/v15/upgrade_test.go index e3bea7929f7..effeb441dc8 100644 --- a/app/upgrades/v15/upgrade_test.go +++ b/app/upgrades/v15/upgrade_test.go @@ -90,7 +90,6 @@ func (suite *UpgradeTestSuite) TestMigrateBalancerToStablePools() { ctx := suite.Ctx gammKeeper := suite.App.GAMMKeeper - poolmanagerKeeper := suite.App.PoolManagerKeeper // bankKeeper := suite.App.BankKeeper testAccount := suite.TestAccs[0] @@ -138,7 +137,7 @@ func (suite *UpgradeTestSuite) TestMigrateBalancerToStablePools() { balancerBalances := suite.App.BankKeeper.GetAllBalances(ctx, balancerPool.GetAddress()) // test migrating the balancer pool to a stable pool - v15.MigrateBalancerPoolToSolidlyStable(ctx, gammKeeper, poolmanagerKeeper, suite.App.BankKeeper, poolID) + v15.MigrateBalancerPoolToSolidlyStable(ctx, gammKeeper, suite.App.BankKeeper, poolID) // check that the pool is now a stable pool stablepool, err := gammKeeper.GetCFMMPool(ctx, poolID) diff --git a/app/upgrades/v15/upgrades.go b/app/upgrades/v15/upgrades.go index 7e050a47974..1c3d036c87f 100644 --- a/app/upgrades/v15/upgrades.go +++ b/app/upgrades/v15/upgrades.go @@ -63,7 +63,7 @@ func CreateUpgradeHandler( // Stride stXXX/XXX pools are being migrated from the standard balancer curve to the // solidly stable curve. - migrateBalancerPoolsToSolidlyStable(ctx, keepers.GAMMKeeper, keepers.PoolManagerKeeper, keepers.BankKeeper) + migrateBalancerPoolsToSolidlyStable(ctx, keepers.GAMMKeeper, keepers.BankKeeper) setRateLimits(ctx, keepers.AccountKeeper, keepers.RateLimitingICS4Wrapper, keepers.WasmKeeper) @@ -79,15 +79,15 @@ func setICQParams(ctx sdk.Context, icqKeeper *icqkeeper.Keeper) { icqKeeper.SetParams(ctx, icqparams) } -func migrateBalancerPoolsToSolidlyStable(ctx sdk.Context, gammKeeper *gammkeeper.Keeper, poolmanagerKeeper *poolmanager.Keeper, bankKeeper bankkeeper.Keeper) { +func migrateBalancerPoolsToSolidlyStable(ctx sdk.Context, gammKeeper *gammkeeper.Keeper, bankKeeper bankkeeper.Keeper) { // migrate stOSMO_OSMOPoolId, stJUNO_JUNOPoolId, stSTARS_STARSPoolId pools := []uint64{stOSMO_OSMOPoolId, stJUNO_JUNOPoolId, stSTARS_STARSPoolId} for _, poolId := range pools { - migrateBalancerPoolToSolidlyStable(ctx, gammKeeper, poolmanagerKeeper, bankKeeper, poolId) + migrateBalancerPoolToSolidlyStable(ctx, gammKeeper, bankKeeper, poolId) } } -func migrateBalancerPoolToSolidlyStable(ctx sdk.Context, gammKeeper *gammkeeper.Keeper, poolmanagerKeeper *poolmanager.Keeper, bankKeeper bankkeeper.Keeper, poolId uint64) { +func migrateBalancerPoolToSolidlyStable(ctx sdk.Context, gammKeeper *gammkeeper.Keeper, bankKeeper bankkeeper.Keeper, poolId uint64) { // fetch the pool with the given poolId balancerPool, err := gammKeeper.GetCFMMPool(ctx, poolId) if err != nil { diff --git a/simulation/executor/mock_tendermint.go b/simulation/executor/mock_tendermint.go index 811859e8147..e324fb15885 100644 --- a/simulation/executor/mock_tendermint.go +++ b/simulation/executor/mock_tendermint.go @@ -181,7 +181,7 @@ func RandomRequestBeginBlock(r *rand.Rand, params Params, } voteInfos := randomVoteInfos(r, params, validators) - evidence := randomDoubleSignEvidence(r, params, validators, pastTimes, pastVoteInfos, event, header, voteInfos) + evidence := randomDoubleSignEvidence(r, params, pastTimes, pastVoteInfos, event, header, voteInfos) return abci.RequestBeginBlock{ Header: header, @@ -230,8 +230,7 @@ func randomVoteInfos(r *rand.Rand, simParams Params, validators mockValidators, return voteInfos } -func randomDoubleSignEvidence(r *rand.Rand, params Params, - validators mockValidators, pastTimes []time.Time, +func randomDoubleSignEvidence(r *rand.Rand, params Params, pastTimes []time.Time, pastVoteInfos [][]abci.VoteInfo, event func(route, op, evResult string), header tmproto.Header, voteInfos []abci.VoteInfo, ) []abci.Evidence { diff --git a/tests/e2e/configurer/upgrade.go b/tests/e2e/configurer/upgrade.go index f8d43db4ef2..4282dea7f25 100644 --- a/tests/e2e/configurer/upgrade.go +++ b/tests/e2e/configurer/upgrade.go @@ -332,7 +332,7 @@ func (uc *UpgradeConfigurer) RunSetup() error { func (uc *UpgradeConfigurer) RunUpgrade() error { var err error if uc.forkHeight > 0 { - err = uc.runForkUpgrade() + uc.runForkUpgrade() } else { err = uc.runProposalUpgrade() } @@ -413,13 +413,12 @@ func (uc *UpgradeConfigurer) runProposalUpgrade() error { return nil } -func (uc *UpgradeConfigurer) runForkUpgrade() error { +func (uc *UpgradeConfigurer) runForkUpgrade() { for _, chainConfig := range uc.chainConfigs { uc.t.Logf("waiting to reach fork height on chain %s", chainConfig.Id) chainConfig.WaitUntilHeight(uc.forkHeight) uc.t.Logf("fork height reached on chain %s", chainConfig.Id) } - return nil } func (uc *UpgradeConfigurer) upgradeContainers(chainConfig *chain.Config, propHeight int64) error { diff --git a/tests/e2e/initialization/chain.go b/tests/e2e/initialization/chain.go index 690503b78a5..d782f1401ae 100644 --- a/tests/e2e/initialization/chain.go +++ b/tests/e2e/initialization/chain.go @@ -12,14 +12,14 @@ type internalChain struct { nodes []*internalNode } -func new(id, dataDir string) (*internalChain, error) { +func new(id, dataDir string) *internalChain { chainMeta := ChainMeta{ Id: id, DataDir: dataDir, } return &internalChain{ chainMeta: chainMeta, - }, nil + } } func (c *internalChain) export() *Chain { diff --git a/tests/e2e/initialization/init.go b/tests/e2e/initialization/init.go index 570d2bed588..a69056835e6 100644 --- a/tests/e2e/initialization/init.go +++ b/tests/e2e/initialization/init.go @@ -10,10 +10,7 @@ import ( ) func InitChain(id, dataDir string, nodeConfigs []*NodeConfig, votingPeriod, expeditedVotingPeriod time.Duration, forkHeight int) (*Chain, error) { - chain, err := new(id, dataDir) - if err != nil { - return nil, err - } + chain := new(id, dataDir) for _, nodeConfig := range nodeConfigs { newNode, err := newNode(chain, nodeConfig) @@ -49,11 +46,7 @@ func InitSingleNode(chainId, dataDir string, existingGenesisDir string, nodeConf return nil, errors.New("creating individual validator nodes after starting up chain is not currently supported") } - chain, err := new(chainId, dataDir) - if err != nil { - return nil, err - } - + chain := new(chainId, dataDir) newNode, err := newNode(chain, nodeConfig) if err != nil { return nil, err diff --git a/x/concentrated-liquidity/client/cli/tx.go b/x/concentrated-liquidity/client/cli/tx.go index 97b838a0d75..dbffa66c0a8 100644 --- a/x/concentrated-liquidity/client/cli/tx.go +++ b/x/concentrated-liquidity/client/cli/tx.go @@ -302,7 +302,6 @@ func parsePoolRecords(cmd *cobra.Command) ([]types.PoolRecord, error) { if len(poolRecords)%4 != 0 { return nil, fmt.Errorf("poolRecords must be a list of denom0, denom1, tickSpacing, and spreadFactor") - } finalPoolRecords := []types.PoolRecord{} diff --git a/x/concentrated-liquidity/export_test.go b/x/concentrated-liquidity/export_test.go index fcb5dc56917..882d734f129 100644 --- a/x/concentrated-liquidity/export_test.go +++ b/x/concentrated-liquidity/export_test.go @@ -131,15 +131,15 @@ func AsConcentrated(poolI poolmanagertypes.PoolI) (types.ConcentratedPoolExtensi } func (k Keeper) ValidateSpreadFactor(ctx sdk.Context, params types.Params, spreadFactor sdk.Dec) bool { - return k.validateSpreadFactor(ctx, params, spreadFactor) + return k.validateSpreadFactor(params, spreadFactor) } func (k Keeper) ValidateTickSpacing(ctx sdk.Context, params types.Params, tickSpacing uint64) bool { - return k.validateTickSpacing(ctx, params, tickSpacing) + return k.validateTickSpacing(params, tickSpacing) } func (k Keeper) ValidateTickSpacingUpdate(ctx sdk.Context, pool types.ConcentratedPoolExtension, params types.Params, newTickSpacing uint64) bool { - return k.validateTickSpacingUpdate(ctx, pool, params, newTickSpacing) + return k.validateTickSpacingUpdate(pool, params, newTickSpacing) } func (k Keeper) FungifyChargedPosition(ctx sdk.Context, owner sdk.AccAddress, positionIds []uint64) (uint64, error) { @@ -319,7 +319,7 @@ func (k Keeper) GetListenersUnsafe() types.ConcentratedLiquidityListeners { } func ValidateAuthorizedQuoteDenoms(ctx sdk.Context, denom1 string, authorizedQuoteDenoms []string) bool { - return validateAuthorizedQuoteDenoms(ctx, denom1, authorizedQuoteDenoms) + return validateAuthorizedQuoteDenoms(denom1, authorizedQuoteDenoms) } func (k Keeper) ValidatePositionUpdateById(ctx sdk.Context, positionId uint64, updateInitiator sdk.AccAddress, lowerTickGiven int64, upperTickGiven int64, liquidityDeltaGiven sdk.Dec, joinTimeGiven time.Time, poolIdGiven uint64) error { @@ -331,7 +331,7 @@ func (k Keeper) GetLargestAuthorizedUptimeDuration(ctx sdk.Context) time.Duratio } func (k Keeper) GetLargestSupportedUptimeDuration(ctx sdk.Context) time.Duration { - return k.getLargestSupportedUptimeDuration(ctx) + return k.getLargestSupportedUptimeDuration() } func (k Keeper) SetupSwapStrategy(ctx sdk.Context, p types.ConcentratedPoolExtension, diff --git a/x/concentrated-liquidity/incentives.go b/x/concentrated-liquidity/incentives.go index 4fb66652250..c5868b9d868 100644 --- a/x/concentrated-liquidity/incentives.go +++ b/x/concentrated-liquidity/incentives.go @@ -1139,6 +1139,6 @@ func (k Keeper) getLargestAuthorizedUptimeDuration(ctx sdk.Context) time.Duratio // nolint: unused // getLargestSupportedUptimeDuration retrieves the largest supported uptime duration from the preset constant slice. -func (k Keeper) getLargestSupportedUptimeDuration(ctx sdk.Context) time.Duration { +func (k Keeper) getLargestSupportedUptimeDuration() time.Duration { return getLargestDuration(types.SupportedUptimes) } diff --git a/x/concentrated-liquidity/pool.go b/x/concentrated-liquidity/pool.go index 9edf0e46455..67eb7b5bb50 100644 --- a/x/concentrated-liquidity/pool.go +++ b/x/concentrated-liquidity/pool.go @@ -42,15 +42,15 @@ func (k Keeper) InitializePool(ctx sdk.Context, poolI poolmanagertypes.PoolI, cr poolId := concentratedPool.GetId() quoteAsset := concentratedPool.GetToken1() - if !k.validateTickSpacing(ctx, params, tickSpacing) { + if !k.validateTickSpacing(params, tickSpacing) { return types.UnauthorizedTickSpacingError{ProvidedTickSpacing: tickSpacing, AuthorizedTickSpacings: params.AuthorizedTickSpacing} } - if !k.validateSpreadFactor(ctx, params, spreadFactor) { + if !k.validateSpreadFactor(params, spreadFactor) { return types.UnauthorizedSpreadFactorError{ProvidedSpreadFactor: spreadFactor, AuthorizedSpreadFactors: params.AuthorizedSpreadFactors} } - if !validateAuthorizedQuoteDenoms(ctx, quoteAsset, params.AuthorizedQuoteDenoms) { + if !validateAuthorizedQuoteDenoms(quoteAsset, params.AuthorizedQuoteDenoms) { return types.UnauthorizedQuoteDenomError{ProvidedQuoteDenom: quoteAsset, AuthorizedQuoteDenoms: params.AuthorizedQuoteDenoms} } @@ -270,7 +270,7 @@ func (k Keeper) DecreaseConcentratedPoolTickSpacing(ctx sdk.Context, poolIdToTic } params := k.GetParams(ctx) - if !k.validateTickSpacingUpdate(ctx, pool, params, poolIdToTickSpacingRecord.NewTickSpacing) { + if !k.validateTickSpacingUpdate(pool, params, poolIdToTickSpacingRecord.NewTickSpacing) { return fmt.Errorf("tick spacing %d is not valid", poolIdToTickSpacingRecord.NewTickSpacing) } @@ -285,7 +285,7 @@ func (k Keeper) DecreaseConcentratedPoolTickSpacing(ctx sdk.Context, poolIdToTic // validateTickSpacing returns true if the given tick spacing is one of the authorized tick spacings set in the // params. False otherwise. -func (k Keeper) validateTickSpacing(ctx sdk.Context, params types.Params, tickSpacing uint64) bool { +func (k Keeper) validateTickSpacing(params types.Params, tickSpacing uint64) bool { for _, authorizedTick := range params.AuthorizedTickSpacing { if tickSpacing == authorizedTick { return true @@ -296,7 +296,7 @@ func (k Keeper) validateTickSpacing(ctx sdk.Context, params types.Params, tickSp // validateTickSpacingUpdate returns true if the given tick spacing is one of the authorized tick spacings set in the // params and is less than the current tick spacing. False otherwise. -func (k Keeper) validateTickSpacingUpdate(ctx sdk.Context, pool types.ConcentratedPoolExtension, params types.Params, newTickSpacing uint64) bool { +func (k Keeper) validateTickSpacingUpdate(pool types.ConcentratedPoolExtension, params types.Params, newTickSpacing uint64) bool { currentTickSpacing := pool.GetTickSpacing() for _, authorizedTick := range params.AuthorizedTickSpacing { // New tick spacing must be one of the authorized tick spacings and must be less than the current tick spacing @@ -309,7 +309,7 @@ func (k Keeper) validateTickSpacingUpdate(ctx sdk.Context, pool types.Concentrat // validateSpreadFactor returns true if the given spread factor is one of the authorized spread factors set in the // params. False otherwise. -func (k Keeper) validateSpreadFactor(ctx sdk.Context, params types.Params, spreadFactor sdk.Dec) bool { +func (k Keeper) validateSpreadFactor(params types.Params, spreadFactor sdk.Dec) bool { for _, authorizedSpreadFactor := range params.AuthorizedSpreadFactors { if spreadFactor.Equal(authorizedSpreadFactor) { return true @@ -328,7 +328,7 @@ func (k Keeper) validateSpreadFactor(ctx sdk.Context, params types.Params, sprea // // Returns: // - bool: A boolean indicating if the denom1 is authorized or not. -func validateAuthorizedQuoteDenoms(ctx sdk.Context, denom1 string, authorizedQuoteDenoms []string) bool { +func validateAuthorizedQuoteDenoms(denom1 string, authorizedQuoteDenoms []string) bool { for _, authorizedQuoteDenom := range authorizedQuoteDenoms { if denom1 == authorizedQuoteDenom { return true diff --git a/x/concentrated-liquidity/simulation/sim_msgs.go b/x/concentrated-liquidity/simulation/sim_msgs.go index c2c679db57c..e7f647eb22f 100644 --- a/x/concentrated-liquidity/simulation/sim_msgs.go +++ b/x/concentrated-liquidity/simulation/sim_msgs.go @@ -233,7 +233,7 @@ func RandMsgCollectIncentives(k clkeeper.Keeper, sim *osmosimtypes.SimCtx, ctx s } // createPoolRestriction creates specific restriction for the creation of a pool. -func createPoolRestriction(k clkeeper.Keeper, sim *osmosimtypes.SimCtx, ctx sdk.Context) osmosimtypes.SimAccountConstraint { +func createPoolRestriction(sim *osmosimtypes.SimCtx, ctx sdk.Context) osmosimtypes.SimAccountConstraint { return func(acc legacysimulationtype.Account) bool { accCoins := sim.BankKeeper().SpendableCoins(ctx, acc.Address) hasTwoCoins := len(accCoins) >= 3 @@ -329,7 +329,7 @@ func RandomPreparePoolFunc(sim *osmosimtypes.SimCtx, ctx sdk.Context, k clkeeper authorizedSpreadFactor := cltypes.AuthorizedSpreadFactors // find an address with two or more distinct denoms in their wallet - sender, senderExists := sim.RandomSimAccountWithConstraint(createPoolRestriction(k, sim, ctx)) + sender, senderExists := sim.RandomSimAccountWithConstraint(createPoolRestriction(sim, ctx)) if !senderExists { return nil, sdk.Coin{}, sdk.Coin{}, 0, sdk.Dec{}, fmt.Errorf("no sender with two different denoms & pool creation fee exists") } diff --git a/x/gamm/simulation/sim_msgs.go b/x/gamm/simulation/sim_msgs.go index 27c2fb4e235..ef2ae316ad4 100644 --- a/x/gamm/simulation/sim_msgs.go +++ b/x/gamm/simulation/sim_msgs.go @@ -87,7 +87,7 @@ func RandomExitPoolMsg(k keeper.Keeper, sim *simtypes.SimCtx, ctx sdk.Context) ( func RandomCreateUniV2Msg(k keeper.Keeper, sim *simtypes.SimCtx, ctx sdk.Context) (*balancertypes.MsgCreateBalancerPool, error) { var poolAssets []balancertypes.PoolAsset // find an address with two or more distinct denoms in their wallet - sender, senderExists := sim.RandomSimAccountWithConstraint(createPoolRestriction(k, sim, ctx)) + sender, senderExists := sim.RandomSimAccountWithConstraint(createPoolRestriction(sim, ctx)) if !senderExists { return nil, errors.New("no sender with two different denoms & pool creation fee exists") } @@ -405,7 +405,7 @@ func deriveRealMinShareOutAmt(ctx sdk.Context, tokenIn sdk.Coins, pool types.CFM return minShareOutAmt, nil } -func createPoolRestriction(k keeper.Keeper, sim *simtypes.SimCtx, ctx sdk.Context) simtypes.SimAccountConstraint { +func createPoolRestriction(sim *simtypes.SimCtx, ctx sdk.Context) simtypes.SimAccountConstraint { return func(acc legacysimulationtype.Account) bool { accCoins := sim.BankKeeper().SpendableCoins(ctx, acc.Address) hasTwoCoins := len(accCoins) >= 2 diff --git a/x/incentives/client/cli/tx.go b/x/incentives/client/cli/tx.go index 51edc1ab7f8..6df89bba287 100644 --- a/x/incentives/client/cli/tx.go +++ b/x/incentives/client/cli/tx.go @@ -88,8 +88,8 @@ func NewCreateGaugeCmd() *cobra.Command { } var distributeTo lockuptypes.QueryCondition - // if poolId is 0 it is a guranteed lock gauge - // if poolId is > 0 it is a guranteed no-lock gauge + // if poolId is 0 it is a guaranteed lock gauge + // if poolId is > 0 it is a guaranteed no-lock gauge if poolId == 0 { distributeTo = lockuptypes.QueryCondition{ LockQueryType: lockuptypes.ByDuration, diff --git a/x/poolmanager/create_pool.go b/x/poolmanager/create_pool.go index 49a6159284a..e2da8d9bb39 100644 --- a/x/poolmanager/create_pool.go +++ b/x/poolmanager/create_pool.go @@ -12,7 +12,7 @@ import ( ) // validateCreatedPool checks that the pool was created with the correct pool ID and address. -func (k Keeper) validateCreatedPool(ctx sdk.Context, poolId uint64, pool types.PoolI) error { +func (k Keeper) validateCreatedPool(poolId uint64, pool types.PoolI) error { if pool.GetId() != poolId { return types.IncorrectPoolIdError{ExpectedPoolId: poolId, ActualPoolId: pool.GetId()} } @@ -115,7 +115,7 @@ func (k Keeper) createPoolZeroLiquidityNoCreationFee(ctx sdk.Context, msg types. k.SetPoolRoute(ctx, poolId, msg.GetPoolType()) // Validates the pool address and pool ID stored match what was expected. - if err := k.validateCreatedPool(ctx, poolId, pool); err != nil { + if err := k.validateCreatedPool(poolId, pool); err != nil { return nil, err } diff --git a/x/poolmanager/export_test.go b/x/poolmanager/export_test.go index 2b22169c302..f4cb25eecf6 100644 --- a/x/poolmanager/export_test.go +++ b/x/poolmanager/export_test.go @@ -39,7 +39,7 @@ func (k Keeper) GetAllPoolRoutes(ctx sdk.Context) []types.ModuleRoute { } func (k Keeper) ValidateCreatedPool(ctx sdk.Context, poolId uint64, pool types.PoolI) error { - return k.validateCreatedPool(ctx, poolId, pool) + return k.validateCreatedPool(poolId, pool) } func (k Keeper) IsOsmoRoutedMultihop(ctx sdk.Context, route types.MultihopRoute, inDenom, outDenom string) (isRouted bool) { diff --git a/x/protorev/keeper/rebalance.go b/x/protorev/keeper/rebalance.go index 1be215948d8..084fabcc375 100644 --- a/x/protorev/keeper/rebalance.go +++ b/x/protorev/keeper/rebalance.go @@ -249,14 +249,14 @@ func (k Keeper) CalculateUpperBoundForSearch( // In the scenario where there are multiple CL pools in a route, we select the one that inputs // the smaller amount to ensure we do not overstep the max ticks moved. - intermidiateCoin, err = k.executeSafeSwap(ctx, pool.GetId(), intermidiateCoin, tokenInDenom, route.StepSize) + intermidiateCoin, err = k.executeSafeSwap(ctx, pool.GetId(), intermidiateCoin, tokenInDenom) if err != nil { return sdk.ZeroInt(), err } case !intermidiateCoin.IsNil(): // If we have already seen a CL pool in the route, then simply propagate the intermediate coin up // the route. - intermidiateCoin, err = k.executeSafeSwap(ctx, pool.GetId(), intermidiateCoin, tokenInDenom, route.StepSize) + intermidiateCoin, err = k.executeSafeSwap(ctx, pool.GetId(), intermidiateCoin, tokenInDenom) if err != nil { return sdk.ZeroInt(), err } @@ -284,7 +284,6 @@ func (k Keeper) executeSafeSwap( poolID uint64, outputCoin sdk.Coin, tokenInDenom string, - stepSize sdk.Int, ) (sdk.Coin, error) { liquidity, err := k.poolmanagerKeeper.GetTotalPoolLiquidity(ctx, poolID) if err != nil { diff --git a/x/superfluid/keeper/export_test.go b/x/superfluid/keeper/export_test.go index 6064cffa487..260d54dd531 100644 --- a/x/superfluid/keeper/export_test.go +++ b/x/superfluid/keeper/export_test.go @@ -40,7 +40,7 @@ func (k Keeper) ValidateSharesToMigrateUnlockAndExitBalancerPool(ctx sdk.Context } func (k Keeper) RouteMigration(ctx sdk.Context, sender sdk.AccAddress, lockId int64, sharesToMigrate sdk.Coin) (synthLockBeforeMigration lockuptypes.SyntheticLock, migrationType MigrationType, err error) { - return k.routeMigration(ctx, sender, lockId, sharesToMigrate) + return k.routeMigration(ctx, lockId, sharesToMigrate) } func (k Keeper) ValidateMigration(ctx sdk.Context, sender sdk.AccAddress, lockId uint64, sharesToMigrate sdk.Coin) (types.MigrationPoolIDs, *lockuptypes.PeriodLock, time.Duration, error) { diff --git a/x/superfluid/keeper/migrate.go b/x/superfluid/keeper/migrate.go index 58df10a8060..4cdfa19602f 100644 --- a/x/superfluid/keeper/migrate.go +++ b/x/superfluid/keeper/migrate.go @@ -47,7 +47,7 @@ const ( // // Errors if the lock is not found, if the lock is not a balancer pool lock, or if the lock is not owned by the sender. func (k Keeper) RouteLockedBalancerToConcentratedMigration(ctx sdk.Context, sender sdk.AccAddress, providedLockId int64, sharesToMigrate sdk.Coin, tokenOutMins sdk.Coins) (positionData cltypes.CreateFullRangePositionData, migratedPoolIDs types.MigrationPoolIDs, concentratedLockId uint64, err error) { - synthLockBeforeMigration, migrationType, err := k.routeMigration(ctx, sender, providedLockId, sharesToMigrate) + synthLockBeforeMigration, migrationType, err := k.routeMigration(ctx, providedLockId, sharesToMigrate) if err != nil { return cltypes.CreateFullRangePositionData{}, types.MigrationPoolIDs{}, 0, err } @@ -97,9 +97,7 @@ func (k Keeper) migrateSuperfluidBondedBalancerToConcentrated(ctx sdk.Context, // Superfluid undelegate the portion of shares the user is migrating from the superfluid delegated position. // If all shares are being migrated, this deletes the connection between the gamm lock and the intermediate account, deletes the synthetic lock, and burns the synthetic osmo. - intermediateAccount := types.SuperfluidIntermediaryAccount{} - - intermediateAccount, err = k.SuperfluidUndelegateToConcentratedPosition(ctx, sender.String(), originalLockId) + intermediateAccount, err := k.SuperfluidUndelegateToConcentratedPosition(ctx, sender.String(), originalLockId) if err != nil { return cltypes.CreateFullRangePositionData{}, 0, types.MigrationPoolIDs{}, err } @@ -219,7 +217,7 @@ func (k Keeper) migrateNonSuperfluidLockBalancerToConcentrated(ctx sdk.Context, // routeMigration determines the status of the provided lock which is used to determine the method for migration. // It also returns the underlying synthetic locks of the provided lock, if any exist. -func (k Keeper) routeMigration(ctx sdk.Context, sender sdk.AccAddress, providedLockId int64, sharesToMigrate sdk.Coin) (synthLockBeforeMigration lockuptypes.SyntheticLock, migrationType MigrationType, err error) { +func (k Keeper) routeMigration(ctx sdk.Context, providedLockId int64, sharesToMigrate sdk.Coin) (synthLockBeforeMigration lockuptypes.SyntheticLock, migrationType MigrationType, err error) { // As a hack around to get frontend working, we decided to allow negative values for the provided lock ID to indicate that the user wants to migrate shares that are not locked. if providedLockId <= 0 { return lockuptypes.SyntheticLock{}, Unlocked, nil diff --git a/x/superfluid/keeper/stake.go b/x/superfluid/keeper/stake.go index 7310c4f2c0c..9d19b96fff4 100644 --- a/x/superfluid/keeper/stake.go +++ b/x/superfluid/keeper/stake.go @@ -128,7 +128,7 @@ func (k Keeper) IncreaseSuperfluidDelegation(ctx sdk.Context, lockID uint64, amo // basic validation for locks to be eligible for superfluid delegation. This includes checking // - that the sender is the owner of the lock // - that the lock is consisted of single coin -func (k Keeper) validateLockForSF(ctx sdk.Context, lock *lockuptypes.PeriodLock, sender string) error { +func (k Keeper) validateLockForSF(lock *lockuptypes.PeriodLock, sender string) error { if lock.Owner != sender { return lockuptypes.ErrNotLockOwner } @@ -146,7 +146,7 @@ func (k Keeper) validateLockForSF(ctx sdk.Context, lock *lockuptypes.PeriodLock, // - lock duration is greater or equal to the unbonding time // - lock should not be already superfluid staked func (k Keeper) validateLockForSFDelegate(ctx sdk.Context, lock *lockuptypes.PeriodLock, sender string) error { - err := k.validateLockForSF(ctx, lock, sender) + err := k.validateLockForSF(lock, sender) if err != nil { return err } @@ -255,7 +255,7 @@ func (k Keeper) undelegateCommon(ctx sdk.Context, sender string, lockID uint64) if err != nil { return types.SuperfluidIntermediaryAccount{}, err } - err = k.validateLockForSF(ctx, lock, sender) + err = k.validateLockForSF(lock, sender) if err != nil { return types.SuperfluidIntermediaryAccount{}, err } @@ -316,7 +316,7 @@ func (k Keeper) partialUndelegateCommon(ctx sdk.Context, sender string, lockID u if err != nil { return types.SuperfluidIntermediaryAccount{}, &lockuptypes.PeriodLock{}, err } - err = k.validateLockForSF(ctx, lock, sender) + err = k.validateLockForSF(lock, sender) if err != nil { return types.SuperfluidIntermediaryAccount{}, &lockuptypes.PeriodLock{}, err } @@ -457,7 +457,7 @@ func (k Keeper) unbondLock(ctx sdk.Context, underlyingLockId uint64, sender stri if err != nil { return 0, err } - err = k.validateLockForSF(ctx, lock, sender) + err = k.validateLockForSF(lock, sender) if err != nil { return 0, err } diff --git a/x/tokenfactory/keeper/createdenom.go b/x/tokenfactory/keeper/createdenom.go index 054dd059b9d..40dfe9a6707 100644 --- a/x/tokenfactory/keeper/createdenom.go +++ b/x/tokenfactory/keeper/createdenom.go @@ -16,7 +16,7 @@ func (k Keeper) CreateDenom(ctx sdk.Context, creatorAddr string, subdenom string return "", err } - err = k.chargeForCreateDenom(ctx, creatorAddr, subdenom) + err = k.chargeForCreateDenom(ctx, creatorAddr) if err != nil { return "", err } @@ -73,7 +73,7 @@ func (k Keeper) validateCreateDenom(ctx sdk.Context, creatorAddr string, subdeno return denom, nil } -func (k Keeper) chargeForCreateDenom(ctx sdk.Context, creatorAddr string, subdenom string) (err error) { +func (k Keeper) chargeForCreateDenom(ctx sdk.Context, creatorAddr string) (err error) { params := k.GetParams(ctx) // if DenomCreationFee is non-zero, transfer the tokens from the creator From 12942b7bf5243e547389d3b47498988dcd43782d Mon Sep 17 00:00:00 2001 From: Ruslan Akhtariev Date: Thu, 10 Aug 2023 21:02:33 +0200 Subject: [PATCH 3/6] finish with unparam --- simulation/executor/util.go | 1 + simulation/simtypes/txbuilder.go | 4 ++-- x/downtime-detector/client/cli/query.go | 1 + x/protorev/client/cli/query.go | 2 ++ x/superfluid/keeper/export_test.go | 2 +- x/superfluid/keeper/migrate.go | 4 ++-- 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/simulation/executor/util.go b/simulation/executor/util.go index 849461124cb..e77e055b948 100644 --- a/simulation/executor/util.go +++ b/simulation/executor/util.go @@ -8,6 +8,7 @@ import ( "github.com/osmosis-labs/osmosis/v17/simulation/simtypes" ) +//nolint:unparam func getTestingMode(tb testing.TB) (testingMode bool, t *testing.T, b *testing.B) { tb.Helper() testingMode = false diff --git a/simulation/simtypes/txbuilder.go b/simulation/simtypes/txbuilder.go index df0a4390801..95c9ae47bce 100644 --- a/simulation/simtypes/txbuilder.go +++ b/simulation/simtypes/txbuilder.go @@ -62,14 +62,14 @@ func (sim *SimCtx) deliverTx(tx sdk.Tx, msg sdk.Msg, msgName string) (simulation txConfig := params.MakeEncodingConfig().TxConfig // TODO: unhardcode gasInfo, results, err := sim.BaseApp().Deliver(txConfig.TxEncoder(), tx) if err != nil { - return simulation.NoOpMsg(msgName, msgName, fmt.Sprintf("unable to deliver tx. \nreason: %v\n results: %v\n msg: %s\n tx: %s", err, results, msg, tx)), nil, nil, err + return simulation.NoOpMsg(msgName, msgName, fmt.Sprintf("unable to deliver tx. \nreason: %v\n results: %v\n msg: %s\n tx: %s", err, results, msg, tx)), []simulation.FutureOperation{}, nil, err } opMsg := simulation.NewOperationMsg(msg, true, "", gasInfo.GasWanted, gasInfo.GasUsed, nil) opMsg.Route = msgName opMsg.Name = msgName - return opMsg, nil, results.Data, nil + return opMsg, []simulation.FutureOperation{}, results.Data, nil } // GenTx generates a signed mock transaction. diff --git a/x/downtime-detector/client/cli/query.go b/x/downtime-detector/client/cli/query.go index f03680e0dbe..f7c6895e65f 100644 --- a/x/downtime-detector/client/cli/query.go +++ b/x/downtime-detector/client/cli/query.go @@ -30,6 +30,7 @@ downtime-duration is a duration, but is restricted to a smaller set. Heres a few }, &queryproto.RecoveredSinceDowntimeOfLengthRequest{} } +//nolint:unparam func parseDowntimeDuration(arg string, _ *pflag.FlagSet) (any, osmocli.FieldReadLocation, error) { dur, err := time.ParseDuration(arg) if err != nil { diff --git a/x/protorev/client/cli/query.go b/x/protorev/client/cli/query.go index 7e8af2fdded..b32b4c0d3c4 100644 --- a/x/protorev/client/cli/query.go +++ b/x/protorev/client/cli/query.go @@ -158,6 +158,8 @@ func NewQueryPoolCmd() (*osmocli.QueryDescriptor, *types.QueryGetProtoRevPoolReq } // convert a string array "[1,2,3]" to []uint64 +// +//nolint:unparam func parseRoute(arg string, _ *pflag.FlagSet) (any, osmocli.FieldReadLocation, error) { var route []uint64 err := json.Unmarshal([]byte(arg), &route) diff --git a/x/superfluid/keeper/export_test.go b/x/superfluid/keeper/export_test.go index 260d54dd531..413303147d5 100644 --- a/x/superfluid/keeper/export_test.go +++ b/x/superfluid/keeper/export_test.go @@ -40,7 +40,7 @@ func (k Keeper) ValidateSharesToMigrateUnlockAndExitBalancerPool(ctx sdk.Context } func (k Keeper) RouteMigration(ctx sdk.Context, sender sdk.AccAddress, lockId int64, sharesToMigrate sdk.Coin) (synthLockBeforeMigration lockuptypes.SyntheticLock, migrationType MigrationType, err error) { - return k.routeMigration(ctx, lockId, sharesToMigrate) + return k.routeMigration(ctx, lockId) } func (k Keeper) ValidateMigration(ctx sdk.Context, sender sdk.AccAddress, lockId uint64, sharesToMigrate sdk.Coin) (types.MigrationPoolIDs, *lockuptypes.PeriodLock, time.Duration, error) { diff --git a/x/superfluid/keeper/migrate.go b/x/superfluid/keeper/migrate.go index 4cdfa19602f..9546b2185c6 100644 --- a/x/superfluid/keeper/migrate.go +++ b/x/superfluid/keeper/migrate.go @@ -47,7 +47,7 @@ const ( // // Errors if the lock is not found, if the lock is not a balancer pool lock, or if the lock is not owned by the sender. func (k Keeper) RouteLockedBalancerToConcentratedMigration(ctx sdk.Context, sender sdk.AccAddress, providedLockId int64, sharesToMigrate sdk.Coin, tokenOutMins sdk.Coins) (positionData cltypes.CreateFullRangePositionData, migratedPoolIDs types.MigrationPoolIDs, concentratedLockId uint64, err error) { - synthLockBeforeMigration, migrationType, err := k.routeMigration(ctx, providedLockId, sharesToMigrate) + synthLockBeforeMigration, migrationType, err := k.routeMigration(ctx, providedLockId) if err != nil { return cltypes.CreateFullRangePositionData{}, types.MigrationPoolIDs{}, 0, err } @@ -217,7 +217,7 @@ func (k Keeper) migrateNonSuperfluidLockBalancerToConcentrated(ctx sdk.Context, // routeMigration determines the status of the provided lock which is used to determine the method for migration. // It also returns the underlying synthetic locks of the provided lock, if any exist. -func (k Keeper) routeMigration(ctx sdk.Context, providedLockId int64, sharesToMigrate sdk.Coin) (synthLockBeforeMigration lockuptypes.SyntheticLock, migrationType MigrationType, err error) { +func (k Keeper) routeMigration(ctx sdk.Context, providedLockId int64) (synthLockBeforeMigration lockuptypes.SyntheticLock, migrationType MigrationType, err error) { // As a hack around to get frontend working, we decided to allow negative values for the provided lock ID to indicate that the user wants to migrate shares that are not locked. if providedLockId <= 0 { return lockuptypes.SyntheticLock{}, Unlocked, nil From 1f1cc20121b04313a2542e528ed0c4742bba6a60 Mon Sep 17 00:00:00 2001 From: Ruslan Akhtariev Date: Thu, 10 Aug 2023 21:10:00 +0200 Subject: [PATCH 4/6] reset deliverTx and mark as nolint --- simulation/simtypes/txbuilder.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/simulation/simtypes/txbuilder.go b/simulation/simtypes/txbuilder.go index 95c9ae47bce..ca45ed1c86d 100644 --- a/simulation/simtypes/txbuilder.go +++ b/simulation/simtypes/txbuilder.go @@ -58,18 +58,20 @@ func (sim *SimCtx) defaultTxBuilder( } // TODO: Fix these args +// +//nolint:unparam func (sim *SimCtx) deliverTx(tx sdk.Tx, msg sdk.Msg, msgName string) (simulation.OperationMsg, []simulation.FutureOperation, []byte, error) { txConfig := params.MakeEncodingConfig().TxConfig // TODO: unhardcode gasInfo, results, err := sim.BaseApp().Deliver(txConfig.TxEncoder(), tx) if err != nil { - return simulation.NoOpMsg(msgName, msgName, fmt.Sprintf("unable to deliver tx. \nreason: %v\n results: %v\n msg: %s\n tx: %s", err, results, msg, tx)), []simulation.FutureOperation{}, nil, err + return simulation.NoOpMsg(msgName, msgName, fmt.Sprintf("unable to deliver tx. \nreason: %v\n results: %v\n msg: %s\n tx: %s", err, results, msg, tx)), nil, nil, err } opMsg := simulation.NewOperationMsg(msg, true, "", gasInfo.GasWanted, gasInfo.GasUsed, nil) opMsg.Route = msgName opMsg.Name = msgName - return opMsg, []simulation.FutureOperation{}, results.Data, nil + return opMsg, nil, results.Data, nil } // GenTx generates a signed mock transaction. From 2bdd9ab06ef53ac586daaabe6a023d234091135a Mon Sep 17 00:00:00 2001 From: Ruslan Akhtariev Date: Thu, 10 Aug 2023 21:11:28 +0200 Subject: [PATCH 5/6] nolint no favor --- simulation/simtypes/txbuilder.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/simulation/simtypes/txbuilder.go b/simulation/simtypes/txbuilder.go index ca45ed1c86d..95c9ae47bce 100644 --- a/simulation/simtypes/txbuilder.go +++ b/simulation/simtypes/txbuilder.go @@ -58,20 +58,18 @@ func (sim *SimCtx) defaultTxBuilder( } // TODO: Fix these args -// -//nolint:unparam func (sim *SimCtx) deliverTx(tx sdk.Tx, msg sdk.Msg, msgName string) (simulation.OperationMsg, []simulation.FutureOperation, []byte, error) { txConfig := params.MakeEncodingConfig().TxConfig // TODO: unhardcode gasInfo, results, err := sim.BaseApp().Deliver(txConfig.TxEncoder(), tx) if err != nil { - return simulation.NoOpMsg(msgName, msgName, fmt.Sprintf("unable to deliver tx. \nreason: %v\n results: %v\n msg: %s\n tx: %s", err, results, msg, tx)), nil, nil, err + return simulation.NoOpMsg(msgName, msgName, fmt.Sprintf("unable to deliver tx. \nreason: %v\n results: %v\n msg: %s\n tx: %s", err, results, msg, tx)), []simulation.FutureOperation{}, nil, err } opMsg := simulation.NewOperationMsg(msg, true, "", gasInfo.GasWanted, gasInfo.GasUsed, nil) opMsg.Route = msgName opMsg.Name = msgName - return opMsg, nil, results.Data, nil + return opMsg, []simulation.FutureOperation{}, results.Data, nil } // GenTx generates a signed mock transaction. From ebaf664685c299dbadeeaea5b0e97270aa4e371b Mon Sep 17 00:00:00 2001 From: Ruslan Akhtariev Date: Thu, 10 Aug 2023 21:19:50 +0200 Subject: [PATCH 6/6] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aeebf5e4cac..57b2a63025a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * [#6014](https://github.com/osmosis-labs/osmosis/pull/6014) refactor: reduce the number of returns in superfluid migration * [#5983](https://github.com/osmosis-labs/osmosis/pull/5983) refactor(CL): 6 return values in CL CreatePosition with a struct * [#6004](https://github.com/osmosis-labs/osmosis/pull/6004) reduce number of returns for creating full range position +* [#6018](https://github.com/osmosis-labs/osmosis/pull/6018) golangci: add unused parameters linter ### Features