From 761c86456e3fdcb2aea78f48cf5117dee9a2a600 Mon Sep 17 00:00:00 2001 From: stackman27 Date: Tue, 13 Jun 2023 11:41:52 -0700 Subject: [PATCH 1/4] added cleanup code --- x/incentives/client/cli/tx.go | 8 +++++++- x/incentives/keeper/gauge.go | 3 +++ x/incentives/types/constants.go | 1 + x/incentives/types/msgs.go | 3 ++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/x/incentives/client/cli/tx.go b/x/incentives/client/cli/tx.go index b251307f02f..f4f22001d85 100644 --- a/x/incentives/client/cli/tx.go +++ b/x/incentives/client/cli/tx.go @@ -31,7 +31,7 @@ func GetTxCmd() *cobra.Command { // NewCreateGaugeCmd broadcasts a CreateGauge message. func NewCreateGaugeCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "create-gauge [lockup_denom] [reward] [flags]", + Use: "create-gauge [lockup_denom] [reward] [poolId] [flags]", Short: "create a gauge to distribute rewards to users", Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { @@ -82,6 +82,11 @@ func NewCreateGaugeCmd() *cobra.Command { return err } + poolId, err := strconv.ParseUint(args[2], 10, 64) + if err != nil { + return err + } + distributeTo := lockuptypes.QueryCondition{ LockQueryType: lockuptypes.ByDuration, Denom: denom, @@ -96,6 +101,7 @@ func NewCreateGaugeCmd() *cobra.Command { coins, startTime, epochs, + poolId, ) return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) diff --git a/x/incentives/keeper/gauge.go b/x/incentives/keeper/gauge.go index 4bf943e03ab..0094602a898 100644 --- a/x/incentives/keeper/gauge.go +++ b/x/incentives/keeper/gauge.go @@ -184,6 +184,9 @@ func (k Keeper) CreateGauge(ctx sdk.Context, isPerpetual bool, owner sdk.AccAddr NumEpochsPaidOver: numEpochsPaidOver, } + // Fixed gas consumption create gauge based on the number of coins to add + ctx.GasMeter().ConsumeGas(uint64(types.BaseGasFeeForCreateGauge*(len(coins)+len(gauge.Coins))), "scaling gas cost for creating gauge rewards") + if err := k.bk.SendCoinsFromAccountToModule(ctx, owner, types.ModuleName, gauge.Coins); err != nil { return 0, err } diff --git a/x/incentives/types/constants.go b/x/incentives/types/constants.go index c9c031aef53..fdc1faca6de 100644 --- a/x/incentives/types/constants.go +++ b/x/incentives/types/constants.go @@ -3,6 +3,7 @@ package types import time "time" var ( + BaseGasFeeForCreateGauge = 10_000 BaseGasFeeForAddRewardToGauge = 10_000 // We set the default value to 1ns, as this is the only uptime we support as long as charging is disabled (or // until more supported uptimes are authorized by governance). diff --git a/x/incentives/types/msgs.go b/x/incentives/types/msgs.go index 2f3a105399f..dafeb82bd70 100644 --- a/x/incentives/types/msgs.go +++ b/x/incentives/types/msgs.go @@ -18,7 +18,7 @@ const ( var _ sdk.Msg = &MsgCreateGauge{} // NewMsgCreateGauge creates a message to create a gauge with the provided parameters. -func NewMsgCreateGauge(isPerpetual bool, owner sdk.AccAddress, distributeTo lockuptypes.QueryCondition, coins sdk.Coins, startTime time.Time, numEpochsPaidOver uint64) *MsgCreateGauge { +func NewMsgCreateGauge(isPerpetual bool, owner sdk.AccAddress, distributeTo lockuptypes.QueryCondition, coins sdk.Coins, startTime time.Time, numEpochsPaidOver uint64, poolId uint64) *MsgCreateGauge { return &MsgCreateGauge{ IsPerpetual: isPerpetual, Owner: owner.String(), @@ -26,6 +26,7 @@ func NewMsgCreateGauge(isPerpetual bool, owner sdk.AccAddress, distributeTo lock Coins: coins, StartTime: startTime, NumEpochsPaidOver: numEpochsPaidOver, + PoolId: poolId, } } From 67c332fd244c974ab44cb8fc022f1a1c2758b775 Mon Sep 17 00:00:00 2001 From: stackman27 Date: Tue, 13 Jun 2023 11:56:59 -0700 Subject: [PATCH 2/4] fixed test --- x/incentives/types/msgs_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/x/incentives/types/msgs_test.go b/x/incentives/types/msgs_test.go index ef9617a60d6..9b94907f645 100644 --- a/x/incentives/types/msgs_test.go +++ b/x/incentives/types/msgs_test.go @@ -39,6 +39,7 @@ func TestMsgCreateGauge(t *testing.T) { sdk.Coins{}, time.Now(), 2, + 0, ) return after(properMsg) From 4ca6359a898eaf640d4d01f0db00a79b9f5a19ee Mon Sep 17 00:00:00 2001 From: stackman27 Date: Wed, 14 Jun 2023 00:25:47 -0700 Subject: [PATCH 3/4] added changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a08d9918b2c..e86d703d85b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -96,7 +96,8 @@ and control over token transfers. * [#5363](https://github.com/osmosis-labs/osmosis/pull/5363) fix: twap record upgrade handler * [#5265](https://github.com/osmosis-labs/osmosis/pull/5265) fix: expect single synthetic lock per native lock ID * [#4983](https://github.com/osmosis-labs/osmosis/pull/4983) implement gas consume on denom creation - * [#4830](https://github.com/osmosis-labs/osmosis/pull/4830) Scale gas costs by denoms in gauge + * [#4830](https://github.com/osmosis-labs/osmosis/pull/4830) Scale gas costs by denoms in gauge (AddToGaugeReward) + * [#5511](https://github.com/osmosis-labs/osmosis/pull/5511) Scale gas costs by denoms in gauge (CreateGauge) * [#4336](https://github.com/osmosis-labs/osmosis/pull/4336) feat: make epochs standalone * [#4801](https://github.com/osmosis-labs/osmosis/pull/4801) refactor: remove GetTotalShares, GetTotalLiquidity and GetExitFee from PoolI * [#4951](https://github.com/osmosis-labs/osmosis/pull/4951) feat: implement pool liquidity query in pool manager, deprecate the one in gamm From fa54fd280b899f9c7a0486532694ba32dee35d7c Mon Sep 17 00:00:00 2001 From: stackman27 Date: Wed, 14 Jun 2023 12:02:43 -0700 Subject: [PATCH 4/4] cleanup --- x/incentives/keeper/gauge.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/incentives/keeper/gauge.go b/x/incentives/keeper/gauge.go index 0094602a898..b7ce65a34eb 100644 --- a/x/incentives/keeper/gauge.go +++ b/x/incentives/keeper/gauge.go @@ -185,7 +185,7 @@ func (k Keeper) CreateGauge(ctx sdk.Context, isPerpetual bool, owner sdk.AccAddr } // Fixed gas consumption create gauge based on the number of coins to add - ctx.GasMeter().ConsumeGas(uint64(types.BaseGasFeeForCreateGauge*(len(coins)+len(gauge.Coins))), "scaling gas cost for creating gauge rewards") + ctx.GasMeter().ConsumeGas(uint64(types.BaseGasFeeForCreateGauge*len(gauge.Coins)), "scaling gas cost for creating gauge rewards") if err := k.bk.SendCoinsFromAccountToModule(ctx, owner, types.ModuleName, gauge.Coins); err != nil { return 0, err