Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial whitelist for Stargate Query #2619

Merged
merged 30 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0835673
Add stargate queries
mattverse Jul 22, 2022
3d5b97c
Fix test
mattverse Jul 22, 2022
9dd65ff
Remove initial whitelist queries
mattverse Aug 1, 2022
344b1c1
Add initial bindings, change names
mattverse Aug 1, 2022
746c4af
Remove cosmos protos
mattverse Aug 1, 2022
b13bff2
Fix lint
mattverse Aug 2, 2022
eb216a1
Update wasm binary
mattverse Aug 3, 2022
55a9668
Revert "Update wasm binary"
mattverse Aug 3, 2022
ab9adc6
Bez's review
mattverse Aug 4, 2022
d8d2013
Add test cases
mattverse Aug 4, 2022
9871ddf
Remove logs
mattverse Aug 10, 2022
ba40941
WIP: return json marshalled response
mattverse Aug 10, 2022
2498529
Add Test Case
mattverse Aug 10, 2022
8ff9dbb
Merge branch 'main' into mattverse/test-json-marshalling
mattverse Aug 10, 2022
3681fac
Add changelog
mattverse Aug 10, 2022
c28e94e
Modify Changelog
mattverse Aug 11, 2022
36ab5d7
Normalize -> ProtoToJson
mattverse Aug 16, 2022
7e148a4
Merge branch 'main' into mattverse/test-json-marshalling
mattverse Aug 22, 2022
3957854
Fix merge conflict
mattverse Aug 22, 2022
204f20a
Add stargate querier test
mattverse Aug 30, 2022
49f709d
Add alot more test cases
mattverse Aug 31, 2022
1e6a842
Add test case for breaking grpc querier
mattverse Sep 1, 2022
18499bf
Update wasmbinding/query_plugin_test.go
mattverse Sep 1, 2022
0ad85d4
code review from upstream
mattverse Sep 6, 2022
4ffac7b
Add initial Stargate whitelist
mattverse Sep 6, 2022
4206c57
Fix lint
mattverse Sep 6, 2022
e6c13c6
Fix test
mattverse Sep 6, 2022
0e3543c
Update wasmbinding/stargate_whitelist.go
ValarDragon Sep 6, 2022
ac14ce3
Update wasmbinding/stargate_whitelist.go
ValarDragon Sep 6, 2022
c2f5554
Merge branch 'main' into mattverse/initial-stargate-queries
mattverse Sep 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions wasmbinding/query_plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

"github.com/osmosis-labs/osmosis/v12/app"
epochtypes "github.com/osmosis-labs/osmosis/v12/x/epochs/types"
lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types"

"github.com/osmosis-labs/osmosis/v12/wasmbinding"
)
Expand Down Expand Up @@ -63,10 +64,10 @@ func (suite *StargateTestSuite) TestStargateQuerier() {
},
{
name: "unregistered path(not whitelisted)",
path: "/osmosis.epochs.v1beta1.Query/CurrentEpoch",
path: "/osmosis.lockup.Query/AccountLockedLongerDuration",
requestData: func() []byte {
currentEpochRequest := epochtypes.QueryCurrentEpochRequest{}
bz, err := proto.Marshal(&currentEpochRequest)
request := lockuptypes.AccountLockedLongerDurationRequest{}
bz, err := proto.Marshal(&request)
suite.Require().NoError(err)
return bz
},
Expand Down Expand Up @@ -124,7 +125,6 @@ func (suite *StargateTestSuite) TestStargateQuerier() {
responseProtoStruct: &banktypes.QueryAllBalancesRequest{},
expectedQuerierError: true,
},

// TODO: errors in wrong query in state machine
}

Expand Down
85 changes: 84 additions & 1 deletion wasmbinding/stargate_whitelist.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,19 @@ import (

authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

epochtypes "github.com/osmosis-labs/osmosis/v12/x/epochs/types"
gammtypes "github.com/osmosis-labs/osmosis/v12/x/gamm/types"
incentivestypes "github.com/osmosis-labs/osmosis/v12/x/incentives/types"
lockuptypes "github.com/osmosis-labs/osmosis/v12/x/lockup/types"
minttypes "github.com/osmosis-labs/osmosis/v12/x/mint/types"
poolincentivestypes "github.com/osmosis-labs/osmosis/v12/x/pool-incentives/types"
superfluidtypes "github.com/osmosis-labs/osmosis/v12/x/superfluid/types"
txfeestypes "github.com/osmosis-labs/osmosis/v12/x/txfees/types"
)

// StargateWhitelist keeps whitelist and its deterministic
Expand All @@ -17,8 +28,80 @@ import (
var StargateWhitelist sync.Map

func init() {
// cosmos-sdk queries

// auth
StargateWhitelist.Store("/cosmos.auth.v1beta1.Query/Account", &authtypes.QueryAccountResponse{})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish there was a way to infer these w/o hard-coding them :-/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah agreed, lets make an issue to ideate/ follow-up. I think theres some magic happening in the proto-grpc backend / RPC service, that we should be able to expose some code re-use from to eliminate this in the future.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be possible with the chnages being done in the sdk to support deterministic queries.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @marbar3778, can you give me the link about the changes you said, thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StargateWhitelist.Store("/cosmos.bank.v1beta1.Query/AllBalances", &banktypes.QueryAllBalancesResponse{})
StargateWhitelist.Store("/cosmos.auth.v1beta1.Query/Params", &authtypes.QueryParamsResponse{})

// bank
StargateWhitelist.Store("/cosmos.bank.v1beta1.Query/Balance", &banktypes.QueryBalanceResponse{})
StargateWhitelist.Store("/cosmos.bank.v1beta1.Query/DenomMetadata", &banktypes.QueryDenomsMetadataResponse{})
StargateWhitelist.Store("/cosmos.bank.v1beta1.Query/Params", &banktypes.QueryParamsResponse{})
StargateWhitelist.Store("/cosmos.bank.v1beta1.Query/SupplyOf", &banktypes.QuerySupplyOfResponse{})

// distribution
StargateWhitelist.Store("/cosmos.distribution.v1beta1.Query/Params", &distributiontypes.QueryParamsResponse{})
StargateWhitelist.Store("/cosmos.distribution.v1beta1.Query/DelegatorWithdrawAddress", &distributiontypes.QueryDelegatorWithdrawAddressResponse{})
StargateWhitelist.Store("/cosmos.distribution.v1beta1.Query/ValidatorCommission", &distributiontypes.QueryValidatorCommissionResponse{})

// gov
StargateWhitelist.Store("/cosmos.gov.v1beta1.Query/Deposit", &govtypes.QueryDepositResponse{})
StargateWhitelist.Store("/cosmos.gov.v1beta1.Query/Params", &govtypes.QueryParamsResponse{})
StargateWhitelist.Store("/cosmos.gov.v1beta1.Query/Vote", &govtypes.QueryVoteResponse{})

// slashing
StargateWhitelist.Store("/cosmos.slashing.v1beta1.Query/Params", &slashingtypes.QueryParamsResponse{})
StargateWhitelist.Store("/cosmos.slashing.v1beta1.Query/SigningInfo", &slashingtypes.QuerySigningInfoResponse{})

// staking
StargateWhitelist.Store("/cosmos.staking.v1beta1.Query/Delegation", &stakingtypes.QueryDelegationResponse{})
StargateWhitelist.Store("/cosmos.staking.v1beta1.Query/Params", &stakingtypes.QueryParamsResponse{})
StargateWhitelist.Store("/cosmos.staking.v1beta1.Query/Validator", &stakingtypes.QueryValidatorResponse{})

// osmosis queries

//epochs
StargateWhitelist.Store("/osmosis.epochs.v1beta1.Query/EpochInfos", &epochtypes.QueryEpochsInfoResponse{})
StargateWhitelist.Store("/osmosis.epochs.v1beta1.Query/CurrentEpoch", &epochtypes.QueryCurrentEpochResponse{})

// gamm
StargateWhitelist.Store("/osmosis.gamm.v1beta1.Query/NumPools", &gammtypes.QueryNumPoolsResponse{})
StargateWhitelist.Store("/osmosis.gamm.v1beta1.Query/TotalLiquidity", &gammtypes.QueryTotalLiquidityResponse{})
StargateWhitelist.Store("/osmosis.gamm.v1beta1.Query/Pool", &gammtypes.QueryPoolResponse{})
StargateWhitelist.Store("/osmosis.gamm.v1beta1.Query/PoolParams", &gammtypes.QueryPoolParamsResponse{})
StargateWhitelist.Store("/osmosis.gamm.v1beta1.Query/TotalPoolLiquidity", &gammtypes.QueryTotalPoolLiquidityResponse{})
StargateWhitelist.Store("/osmosis.gamm.v1beta1.Query/TotalShares", &gammtypes.QueryTotalSharesResponse{})
StargateWhitelist.Store("/osmosis.gamm.v1beta1.Query/SpotPrice", &gammtypes.QuerySpotPriceResponse{})

// incentives
StargateWhitelist.Store("/osmosis.incentives.Query/ModuleToDistributeCoins", &incentivestypes.ModuleToDistributeCoinsResponse{})
StargateWhitelist.Store("/osmosis.incentives.Query/ModuleDistributedCoins", &incentivestypes.ModuleDistributedCoinsResponse{})
StargateWhitelist.Store("/osmosis.incentives.Query/LockableDurations", &incentivestypes.QueryLockableDurationsResponse{})

// lockup
StargateWhitelist.Store("/osmosis.lockup.Query/ModuleBalance", &lockuptypes.ModuleBalanceResponse{})
StargateWhitelist.Store("/osmosis.lockup.Query/ModuleLockedAmount", &lockuptypes.ModuleLockedAmountResponse{})
StargateWhitelist.Store("/osmosis.lockup.Query/AccountUnlockableCoins", &lockuptypes.AccountUnlockableCoinsResponse{})
StargateWhitelist.Store("/osmosis.lockup.Query/AccountUnlockingCoins", &lockuptypes.AccountUnlockingCoinsResponse{})
StargateWhitelist.Store("/osmosis.lockup.Query/LockedDenom", &lockuptypes.LockedDenomResponse{})

// mint
StargateWhitelist.Store("/osmosis.mint.v1beta1.Query/EpochProvisions", &minttypes.QueryEpochProvisionsResponse{})
StargateWhitelist.Store("/osmosis.mint.v1beta1.Query/Params", &minttypes.QueryParamsResponse{})

// pool-incentives
StargateWhitelist.Store("/osmosis.poolincentives.v1beta1.Query/GaugeIds", &poolincentivestypes.QueryGaugeIdsResponse{})

// superfluid
StargateWhitelist.Store("/osmosis.superfluid.Query/Params", &superfluidtypes.QueryParamsResponse{})
StargateWhitelist.Store("/osmosis.superfluid.Query/AssetType", &superfluidtypes.AssetTypeResponse{})
StargateWhitelist.Store("/osmosis.superfluid.Query/AllAssets", &superfluidtypes.AllAssetsResponse{})
StargateWhitelist.Store("/osmosis.superfluid.Query/AssetMultiplier", &superfluidtypes.AssetMultiplierResponse{})

// txfees
StargateWhitelist.Store("/osmosis.txfees.v1beta1.Query/FeeTokens", &txfeestypes.QueryFeeTokensResponse{})
StargateWhitelist.Store("/osmosis.txfees.v1beta1.Query/DenomSpotPrice", &txfeestypes.QueryDenomSpotPriceResponse{})
StargateWhitelist.Store("/osmosis.txfees.v1beta1.Query/DenomPoolId", &txfeestypes.QueryDenomPoolIdResponse{})
StargateWhitelist.Store("/osmosis.txfees.v1beta1.Query/BaseDenom", &txfeestypes.QueryBaseDenomResponse{})
}