From 73582dc37cfd77e4a29916e8ed3c627f4a8e2434 Mon Sep 17 00:00:00 2001 From: mattverse Date: Tue, 13 Jun 2023 14:44:23 +0900 Subject: [PATCH 1/3] Fix stargate whitelist --- CHANGELOG.md | 1 + wasmbinding/stargate_whitelist.go | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7e253495a3..a08d9918b2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -89,6 +89,7 @@ and control over token transfers. * [#5138](https://github.com/osmosis-labs/osmosis/pull/5138) refactor: rename swap fee to spread factor * [#5020](https://github.com/osmosis-labs/osmosis/pull/5020) Add gas config to the client.toml * [#5459](https://github.com/osmosis-labs/osmosis/pull/5459) Create locktypes.LockQueryType.NoLock gauge. MsgCreateGauge takes pool id for new gauge type. + * [#5503](https://github.com/osmosis-labs/osmosis/pull/5503) Deprecate gamm spot price query and add pool manager spot price query to stargate query whitelist. ## State Breaking * [#5380](https://github.com/osmosis-labs/osmosis/pull/5380) feat: add ica authorized messages in upgrade handler diff --git a/wasmbinding/stargate_whitelist.go b/wasmbinding/stargate_whitelist.go index 62b6e59abbf..0ad40390f17 100644 --- a/wasmbinding/stargate_whitelist.go +++ b/wasmbinding/stargate_whitelist.go @@ -17,7 +17,6 @@ import ( concentratedliquidityquery "github.com/osmosis-labs/osmosis/v16/x/concentrated-liquidity/client/queryproto" downtimequerytypes "github.com/osmosis-labs/osmosis/v16/x/downtime-detector/client/queryproto" gammtypes "github.com/osmosis-labs/osmosis/v16/x/gamm/types" - gammv2types "github.com/osmosis-labs/osmosis/v16/x/gamm/v2types" incentivestypes "github.com/osmosis-labs/osmosis/v16/x/incentives/types" lockuptypes "github.com/osmosis-labs/osmosis/v16/x/lockup/types" minttypes "github.com/osmosis-labs/osmosis/v16/x/mint/types" @@ -93,7 +92,6 @@ func init() { setWhitelistedQuery("/osmosis.gamm.v1beta1.Query/CalcExitPoolCoinsFromShares", &gammtypes.QueryCalcExitPoolCoinsFromSharesResponse{}) setWhitelistedQuery("/osmosis.gamm.v1beta1.Query/CalcJoinPoolNoSwapShares", &gammtypes.QueryCalcJoinPoolNoSwapSharesResponse{}) setWhitelistedQuery("/osmosis.gamm.v1beta1.Query/PoolType", &gammtypes.QueryPoolTypeResponse{}) - setWhitelistedQuery("/osmosis.gamm.v2.Query/SpotPrice", &gammv2types.QuerySpotPriceResponse{}) setWhitelistedQuery("/osmosis.gamm.v1beta1.Query/EstimateSwapExactAmountIn", &gammtypes.QuerySwapExactAmountInResponse{}) setWhitelistedQuery("/osmosis.gamm.v1beta1.Query/EstimateSwapExactAmountOut", &gammtypes.QuerySwapExactAmountOutResponse{}) @@ -131,6 +129,7 @@ func init() { setWhitelistedQuery("/osmosis.poolmanager.v1beta1.Query/EstimateSinglePoolSwapExactAmountIn", &poolmanagerqueryproto.EstimateSwapExactAmountInResponse{}) setWhitelistedQuery("/osmosis.poolmanager.v1beta1.Query/EstimateSinglePoolSwapExactAmountOut", &poolmanagerqueryproto.EstimateSwapExactAmountOutResponse{}) setWhitelistedQuery("/osmosis.poolmanager.v1beta1.Query/Pool", &poolmanagerqueryproto.PoolResponse{}) + setWhitelistedQuery("/osmosis.poolmanager.v1beta1.Query/SpotPrice", &poolmanagerqueryproto.SpotPriceResponse{}) // txfees setWhitelistedQuery("/osmosis.txfees.v1beta1.Query/FeeTokens", &txfeestypes.QueryFeeTokensResponse{}) From 7dabcb62f35ad97363d0b5ca6a688ace6a90f0ae Mon Sep 17 00:00:00 2001 From: mattverse Date: Tue, 13 Jun 2023 18:20:28 +0900 Subject: [PATCH 2/3] Fix query pulgin test --- wasmbinding/query_plugin_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wasmbinding/query_plugin_test.go b/wasmbinding/query_plugin_test.go index 63009449ae4..4393087db89 100644 --- a/wasmbinding/query_plugin_test.go +++ b/wasmbinding/query_plugin_test.go @@ -71,7 +71,7 @@ func (suite *StargateTestSuite) TestStargateQuerier() { }, { name: "happy path gamm", - path: "/osmosis.gamm.v2.Query/SpotPrice", + path: "/osmosis.poolmanager.v1beta1.Query/SpotPrice", testSetup: func() { pk := ed25519.GenPrivKey().PubKey() sender := sdk.AccAddress(pk.Address()) From b6ffc06daf6aebecdf417449b92c676cf81b626d Mon Sep 17 00:00:00 2001 From: mattverse Date: Tue, 13 Jun 2023 19:56:43 +0900 Subject: [PATCH 3/3] Bring back spot price --- wasmbinding/query_plugin_test.go | 31 ++++++++++++++++++++++++++++++- wasmbinding/stargate_whitelist.go | 3 +++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/wasmbinding/query_plugin_test.go b/wasmbinding/query_plugin_test.go index 4393087db89..e1407c5b921 100644 --- a/wasmbinding/query_plugin_test.go +++ b/wasmbinding/query_plugin_test.go @@ -70,7 +70,36 @@ func (suite *StargateTestSuite) TestStargateQuerier() { responseProtoStruct: &epochtypes.QueryEpochsInfoResponse{}, }, { - name: "happy path gamm", + name: "happy path gamm spot price", + path: "/osmosis.gamm.v2.Query/SpotPrice", + testSetup: func() { + pk := ed25519.GenPrivKey().PubKey() + sender := sdk.AccAddress(pk.Address()) + err := simapp.FundAccount(suite.app.BankKeeper, suite.ctx, sender, apptesting.DefaultAcctFunds) + suite.Require().NoError(err) + msg := balancer.NewMsgCreateBalancerPool(sender, + balancer.NewPoolParams(sdk.ZeroDec(), sdk.ZeroDec(), nil), + apptesting.DefaultPoolAssets, "") + _, err = suite.app.PoolManagerKeeper.CreatePool(suite.ctx, msg) + suite.NoError(err) + }, + requestData: func() []byte { + queryrequest := gammv2types.QuerySpotPriceRequest{ //nolint:staticcheck // we're intentionally using this deprecated package for testing + PoolId: 1, + BaseAssetDenom: "bar", + QuoteAssetDenom: "uosmo", + } + bz, err := proto.Marshal(&queryrequest) + suite.Require().NoError(err) + return bz + }, + checkResponseStruct: true, + responseProtoStruct: &gammv2types.QuerySpotPriceResponse{ //nolint:staticcheck // we're intentionally using this deprecated package for testing + SpotPrice: sdk.NewDecWithPrec(5, 1).String(), + }, + }, + { + name: "happy path pool manager", path: "/osmosis.poolmanager.v1beta1.Query/SpotPrice", testSetup: func() { pk := ed25519.GenPrivKey().PubKey() diff --git a/wasmbinding/stargate_whitelist.go b/wasmbinding/stargate_whitelist.go index 0ad40390f17..ad41ed72e93 100644 --- a/wasmbinding/stargate_whitelist.go +++ b/wasmbinding/stargate_whitelist.go @@ -14,6 +14,8 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" + gammv2types "github.com/osmosis-labs/osmosis/v16/x/gamm/v2types" + concentratedliquidityquery "github.com/osmosis-labs/osmosis/v16/x/concentrated-liquidity/client/queryproto" downtimequerytypes "github.com/osmosis-labs/osmosis/v16/x/downtime-detector/client/queryproto" gammtypes "github.com/osmosis-labs/osmosis/v16/x/gamm/types" @@ -92,6 +94,7 @@ func init() { setWhitelistedQuery("/osmosis.gamm.v1beta1.Query/CalcExitPoolCoinsFromShares", &gammtypes.QueryCalcExitPoolCoinsFromSharesResponse{}) setWhitelistedQuery("/osmosis.gamm.v1beta1.Query/CalcJoinPoolNoSwapShares", &gammtypes.QueryCalcJoinPoolNoSwapSharesResponse{}) setWhitelistedQuery("/osmosis.gamm.v1beta1.Query/PoolType", &gammtypes.QueryPoolTypeResponse{}) + setWhitelistedQuery("/osmosis.gamm.v2.Query/SpotPrice", &gammv2types.QuerySpotPriceResponse{}) setWhitelistedQuery("/osmosis.gamm.v1beta1.Query/EstimateSwapExactAmountIn", &gammtypes.QuerySwapExactAmountInResponse{}) setWhitelistedQuery("/osmosis.gamm.v1beta1.Query/EstimateSwapExactAmountOut", &gammtypes.QuerySwapExactAmountOutResponse{})