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

Introduce AcceptListStargateQuerier #1069

Merged
merged 11 commits into from
Nov 2, 2022
Merged

Introduce AcceptListStargateQuerier #1069

merged 11 commits into from
Nov 2, 2022

Conversation

alpe
Copy link
Contributor

@alpe alpe commented Nov 1, 2022

Resolves #904

This PR is based on the excellent work in #971 by @mattverse . Thanks a lot for your PR!

I rebased the branch on top of current main and refactored the accept list setup and initialization for backward compatibility and smooth integration into our constructor option model.
The default mode is still rejecting Stargate queries. I made this an explicit handler: RejectStargateQuerier

If any chain wants to maintain and enable a set of Stargate queries, it can easily configured via WithQueryPlugins option, now. This is a full example:

accepted := wasmkeeper.AcceptedStargateQueries{
	"/cosmos.auth.v1beta1.Query/Account": &authtypes.QueryAccountResponse{},
}
querierOpts := wasmkeeper.WithQueryPlugins(
	&wasmkeeper.QueryPlugins{
		Stargate: wasmkeeper.AcceptListStargateQuerier(accepted, app.GRPCQueryRouter(), appCodec),
	})

app.WasmKeeper = wasm.NewKeeper(
	appCodec,
	keys[wasm.StoreKey],
	app.getSubspace(wasm.ModuleName),
	app.AccountKeeper,
	app.BankKeeper,
	app.StakingKeeper,
	app.DistrKeeper,
	app.IBCKeeper.ChannelKeeper,
	&app.IBCKeeper.PortKeeper,
	scopedWasmKeeper,
	app.TransferKeeper,
	app.MsgServiceRouter(),
	app.GRPCQueryRouter(),
	wasmDir,
	wasmConfig,
	availableCapabilities,
	querierOpts,
)

Note for the reviewer:
Beside rebasing all only the last commit was added. Please squash commits

@alpe alpe marked this pull request as ready for review November 1, 2022 14:34
@alpe alpe requested a review from pinosu November 1, 2022 14:34
@alpe alpe added this to the v0.30.0 milestone Nov 1, 2022
@codecov
Copy link

codecov bot commented Nov 1, 2022

Codecov Report

Merging #1069 (40cf990) into main (84e24d3) will increase coverage by 0.02%.
The diff coverage is 65.00%.

❗ Current head 40cf990 differs from pull request most recent head 1c3fb33. Consider uploading reports for the commit 1c3fb33 to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1069      +/-   ##
==========================================
+ Coverage   59.28%   59.30%   +0.02%     
==========================================
  Files          53       53              
  Lines        6722     6755      +33     
==========================================
+ Hits         3985     4006      +21     
- Misses       2442     2453      +11     
- Partials      295      296       +1     
Impacted Files Coverage Δ
x/wasm/keeper/options.go 74.71% <ø> (ø)
x/wasm/module.go 37.90% <0.00%> (ø)
x/wasm/types/proposal.go 61.31% <0.00%> (-1.81%) ⬇️
x/wasm/keeper/query_plugins.go 81.81% <92.59%> (+0.71%) ⬆️
x/wasm/keeper/keeper.go 87.42% <100.00%> (ø)

Copy link
Contributor

@pinosu pinosu left a comment

Choose a reason for hiding this comment

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

nice work! LGTM 👍 just a typo needs to be fixed in the test name.

@alpe alpe merged commit a9ce273 into main Nov 2, 2022
@alpe alpe deleted the 971_polished branch November 2, 2022 16:16
NoahSaso pushed a commit to NoahSaso/wasmd that referenced this pull request Dec 2, 2022
* Stargate query enable

* Remove initialized whitelists

* Roman's review

* Minor improvement

* Add tests

* Add testings and codec

* Fix lint

* Fix test

* Fix from code review

* Refactor Stargate querier init

* Fix typo

Co-authored-by: mattverse <mattpark1028@gmail.com>
Magicloud pushed a commit to fpco/wasmd that referenced this pull request Jan 13, 2023
* Stargate query enable

* Remove initialized whitelists

* Roman's review

* Minor improvement

* Add tests

* Add testings and codec

* Fix lint

* Fix test

* Fix from code review

* Refactor Stargate querier init

* Fix typo

Co-authored-by: mattverse <mattpark1028@gmail.com>
conorpp pushed a commit to wormhole-foundation/wasmd that referenced this pull request Feb 1, 2023
* Stargate query enable

* Remove initialized whitelists

* Roman's review

* Minor improvement

* Add tests

* Add testings and codec

* Fix lint

* Fix test

* Fix from code review

* Refactor Stargate querier init

* Fix typo

Co-authored-by: mattverse <mattpark1028@gmail.com>
dudong2 pushed a commit to Finschia/wasmd that referenced this pull request Aug 17, 2023
* Stargate query enable

* Remove initialized whitelists

* Roman's review

* Minor improvement

* Add tests

* Add testings and codec

* Fix lint

* Fix test

* Fix from code review

* Refactor Stargate querier init

* Fix typo

Co-authored-by: mattverse <mattpark1028@gmail.com>
dudong2 pushed a commit to Finschia/wasmd that referenced this pull request Aug 17, 2023
* Stargate query enable

* Remove initialized whitelists

* Roman's review

* Minor improvement

* Add tests

* Add testings and codec

* Fix lint

* Fix test

* Fix from code review

* Refactor Stargate querier init

* Fix typo

Co-authored-by: mattverse <mattpark1028@gmail.com>
dudong2 added a commit to Finschia/wasmd that referenced this pull request Aug 23, 2023
* Introduce AcceptListStargateQuerier (CosmWasm#1069)

* Stargate query enable

* Remove initialized whitelists

* Roman's review

* Minor improvement

* Add tests

* Add testings and codec

* Fix lint

* Fix test

* Fix from code review

* Refactor Stargate querier init

* Fix typo

Co-authored-by: mattverse <mattpark1028@gmail.com>

* docs: add changelog

---------

Co-authored-by: Alexander Peters <alpe@users.noreply.github.com>
Co-authored-by: mattverse <mattpark1028@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use an Allow list for StargateQuery instead of completely disabling it
3 participants