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

RE: Enable Whitelist Stargate Query #2353

Merged
merged 24 commits into from
Sep 6, 2022
Merged

Conversation

mattverse
Copy link
Member

Closes: #2190
Closes: #2098

What is the purpose of the change

Add whitelisted stargate queries and ensure deterministic query. The difference of this PR with the previous PR(#2190) is that we json marshal the responses, not proto marshalling them. Test cases have been also been updated for this accordingly, tested and confirmed that this way of enabling stargate queries work via sample contract (https://github.com/osmosis-labs/swaprouter)

Brief Changelog

  • Enable Stargate Query

Testing and Verifying

Tested locally and confrimed that this way of whitelisting works contract side by deploying contract with this commit.
Also added go test to ensure we're safe with json marshalling.

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? yes
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? yes

@mattverse mattverse requested a review from a team August 10, 2022 14:17
@github-actions github-actions bot added the C:app-wiring Changes to the app folder label Aug 10, 2022
@github-actions github-actions bot added the C:docs Improvements or additions to documentation label Aug 10, 2022
@ValarDragon ValarDragon added this to the V12 Blockers milestone Aug 19, 2022
Copy link
Member

@p0mvn p0mvn left a comment

Choose a reason for hiding this comment

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

Overall looks good, nice work!

Could you please elaborate in comments/specs on the following things:

  • why do we need to proto unmarshal and then json marshal?
  • why do we need to message.Reset()?

I also think that we might consider splitting up some test cases and testing StargateQuerier directly

wasmbinding/stargate_whitelist_test.go Outdated Show resolved Hide resolved
wasmbinding/query_plugin.go Show resolved Hide resolved
wasmbinding/query_plugin.go Outdated Show resolved Hide resolved
wasmbinding/query_plugin.go Outdated Show resolved Hide resolved
wasmbinding/query_plugin.go Outdated Show resolved Hide resolved
wasmbinding/stargate_whitelist_test.go Outdated Show resolved Hide resolved
@p0mvn
Copy link
Member

p0mvn commented Aug 29, 2022

Why do we redefine StargateQuerier in osmosis-labs/wasmd#7?

Shouldn't we encourage clients to define their own?

@nicolaslara
Copy link
Contributor

Why do we redefine StargateQuerier in osmosis-labs/wasmd#7?
Shouldn't we encourage clients to define their own?

Having clients define their own was the previews solution. Upstreaming the whitelist means that very few clients will need to define their won (they can just whitelist endpoints instead)

@mattverse
Copy link
Member Author

Why do we redefine StargateQuerier in osmosis-labs/wasmd#7?
Shouldn't we encourage clients to define their own?

Having clients define their own was the previews solution. Upstreaming the whitelist means that very few clients will need to define their won (they can just whitelist endpoints instead)

Yeah also having clients define their own was too much overhead, almost impossible for clients to use.

@p0mvn
Copy link
Member

p0mvn commented Aug 30, 2022

Sounds good, makes sense @mattverse @nicolaslara . Then, why are we defining our own instead of merging the generic StargateQuerier in the wasmd fork, updating the go.mod and reusing it here given that our goal is to eventually upstream it?

Should we then completely move all the StargateQuerier logic to the wasmd PR: osmosis-labs/wasmd#7

wasmbinding/query_plugin_test.go Outdated Show resolved Hide resolved
wasmbinding/query_plugin.go Show resolved Hide resolved
wasmbinding/query_plugin.go Show resolved Hide resolved
wasmbinding/query_plugin.go Show resolved Hide resolved
wasmbinding/stargate_whitelist_test.go Outdated Show resolved Hide resolved
@iboss-ptk
Copy link
Contributor

iboss-ptk commented Aug 31, 2022

On testing, do we have list of known causes for non-determinism? Notice that there seems to be only schema upgrade test that address non-determinism issue.

If we have the list, then we might be able to create a generic test scenario to test against all enabled stargate query and construct test from func (*Map) Range to avoid human error of forgetting to add test when there is new whitelist. Let me know if this make sense or not.

Other point is what I pointed out to @mattverse few weeks back about the potential of making whitelist a config file of some sort. Is that possible? Will need that to filter out CosmWasm Querier generation, but if it's too tricky, I could make code gen retrieve all keys from StargateWhitelist directly through ffi as well.

@nicolaslara
Copy link
Contributor

On testing, do we have list of known causes for non-determinism?

I don't think there is a comprehensive list, and there could always be new, previously unknown causes of non-determinism that pop-up. The main culprits at the moment are returning values based on: explicit randomness, any sort of unordered lists, system time, floats, and maps.

generic test scenario against all enabled stargate query

I think doing these generic tests for the causes of non-determinism would be quite difficult (they're all quite unique), but great if achievable! maybe some sort of simulation with different underlying architectures/setups for the nodes? Could be done with e2e testing, but I'd say it's outside the scope of this PR.

@mattverse
Copy link
Member Author

Added way more test cases upon @p0mvn 's review!

@mattverse mattverse requested a review from p0mvn August 31, 2022 08:44
@p0mvn
Copy link
Member

p0mvn commented Aug 31, 2022

Sounds good, makes sense @mattverse @nicolaslara . Then, why are we defining our own instead of merging the generic StargateQuerier in the wasmd fork, updating the go.mod and reusing it here given that our goal is to eventually upstream it?

Should we then completely move all the StargateQuerier logic to the wasmd PR: osmosis-labs/wasmd#7

Synched with Matt. The goal is to eventually remove StargateQuerier from here, once it is upstreamed to wasmd. For now, we want to have it for the speed of development since upstreaming to wasmd might take some time

Copy link
Member

@p0mvn p0mvn left a comment

Choose a reason for hiding this comment

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

LGTM! Great work @mattverse . Thanks for testing this thoroughly

wasmbinding/query_plugin_test.go Outdated Show resolved Hide resolved
wasmbinding/query_plugin_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@iboss-ptk iboss-ptk left a comment

Choose a reason for hiding this comment

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

LGTM! Great work @mattverse!

Wish the whitelist process doesn’t require registering response type but that could be future improvement.

@ValarDragon ValarDragon added the A:backport/v12.x backport patches to v12.x branch label Sep 6, 2022
@ValarDragon ValarDragon merged commit d5cc792 into main Sep 6, 2022
@ValarDragon ValarDragon deleted the mattverse/test-json-marshalling branch September 6, 2022 21:04
mergify bot pushed a commit that referenced this pull request Sep 6, 2022
* Add stargate queries

* Fix test

* Remove initial whitelist queries

* Add initial bindings, change names

* Remove cosmos protos

* Fix lint

* Update wasm binary

* Revert "Update wasm binary"

This reverts commit eb216a1.

* Bez's review

* Add test cases

* Remove logs

* WIP: return json marshalled response

* Add Test Case

* Add changelog

* Modify Changelog

* Normalize -> ProtoToJson

* Fix merge conflict

* Add stargate querier test

* Add alot more test cases

* Add test case for breaking grpc querier

* Update wasmbinding/query_plugin_test.go

Co-authored-by: Roman <[email protected]>

* code review from upstream

Co-authored-by: Roman <[email protected]>
(cherry picked from commit d5cc792)
@github-actions github-actions bot mentioned this pull request Jan 15, 2024
@github-actions github-actions bot mentioned this pull request Mar 1, 2024
@github-actions github-actions bot mentioned this pull request May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:backport/v12.x backport patches to v12.x branch C:app-wiring Changes to the app folder C:docs Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fork cosmwasm to re-enable queries
5 participants