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

Enable whitelisted Stargate Query with determinism #7

Closed
wants to merge 9 commits into from

Conversation

mattverse
Copy link
Member

What is the purpose of the change

We have a history of disabling stargate queries, as some of the queries were non-deterministic to run on the state machine. (cref: CosmWasm#812).

This PR introduces re-enabling stargate queries whilst ensuring determinism using protos and bindings. (Orignial idea was from terra-money/classic-core#738, but most are modified as they have a different structure of wasmd from current wasmd)

Testing

Further plans to test this is TBD(upon concept ACK of this approach), although I do not have exact plans to test this in a local machine as of rn.

@mattverse mattverse requested review from ValarDragon and p0mvn and removed request for ValarDragon July 20, 2022 14:38
@iboss-ptk
Copy link

@mattverse will this PR enables queries for osmosis's module as well?

@mattverse
Copy link
Member Author

mattverse commented Jul 22, 2022

@iboss-ptk We can enable it via bindings. Rn I'm trying to move these proto layers into Osmosis, while keeping these inits in the wasmd layer empty!

@mattverse
Copy link
Member Author

Update: Leaving the initialization whitelisted stargate queries empty so that we can also get this upstremed

x/wasm/keeper/stargate_bindings.go Outdated Show resolved Hide resolved
x/wasm/keeper/stargate_bindings.go Outdated Show resolved Hide resolved
x/wasm/keeper/stargate_bindings.go Outdated Show resolved Hide resolved
return func(ctx sdk.Context, msg *wasmvmtypes.StargateQuery) ([]byte, error) {
return nil, wasmvmtypes.UnsupportedRequest{Kind: "Stargate queries are disabled."}
return func(ctx sdk.Context, request *wasmvmtypes.StargateQuery) ([]byte, error) {
binding, whitelisted := StargateLayerBindings.Load(request.Path)
Copy link
Member

Choose a reason for hiding this comment

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

Can we call this binding? I feel like the semantics are different

In my eyes, bindings are API abstractions that we implement on top of the existing message server and querier.

On the other hand, this seems like a query response to me.

Please correct me if I'm wrong

Suggested change
binding, whitelisted := StargateLayerBindings.Load(request.Path)
response, whitelisted := StargateLayerBindings.Load(request.Path)

Copy link
Member Author

@mattverse mattverse Aug 4, 2022

Choose a reason for hiding this comment

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

I named it binding because imo it is the layer of API abstraction, as it returns an interface to marshal into, not the response itself. Lmk what you think

x/wasm/keeper/query_plugins.go Outdated Show resolved Hide resolved
x/wasm/keeper/query_plugins.go Outdated Show resolved Hide resolved
@mattverse
Copy link
Member Author

Note that this PR is different from osmosis-labs/osmosis#2353 in the sense that we don't json marshal the responses here

@p0mvn
Copy link
Member

p0mvn commented Aug 29, 2022

Note that this PR is different from osmosis-labs/osmosis#2353 in the sense that we don't json marshal the responses here

Why do we need another StargateQuerier here? Shouldn't we encourage clients to define their own? Also, why is normalization logic different here from Osmosis?

@mattverse
Copy link
Member Author

Note that this PR is different from osmosis-labs/osmosis#2353 in the sense that we don't json marshal the responses here

Why do we need another StargateQuerier here? Shouldn't we encourage clients to define their own? Also, why is normalization logic different here from Osmosis?

This is a very good question, this PR serves its main focus for upstream, I wasnt so sure if we want to enforce using the response by json unmarshalling as we did in our osmosis repo. On the second thought, I do think that providing json marshalled responses is how it should be supported in the upstream as well, changed this PR to sync with the logic in Osmosis

@p0mvn
Copy link
Member

p0mvn commented Sep 1, 2022

@mattverse Do you mind making this PR against https://github.com/osmosis-labs/wasmd/tree/v0.28.0-osmo-v12?

We will use that branch for the v12 release. It is made off of https://github.com/CosmWasm/wasmd/releases/tag/v0.28.0. In addition, it changes the SDK and iavl dependencies to our forks. This is necessary to avoid dependency conflicts when updating wasmd dep in osmosis-labs/osmosis

Once upstream releases the whitelist change that we need, we can switch to using that instead

@mattverse
Copy link
Member Author

mattverse commented Sep 2, 2022

@p0mvn actually, since we have osmosis-labs/osmosis#2353 on Osmosis, I don't think we need to maintain a separate commit for wasmd fork for Osmosis. + we have a separate PR for this on upstream. Thius I think this PR should be good to close. wdyt about this idea?

@p0mvn
Copy link
Member

p0mvn commented Sep 2, 2022

@p0mvn actually, since we have osmosis-labs/osmosis#2353 on Osmosis, I don't think we need to maintain a separate commit for wasmd fork for Osmosis. + we have a separate PR for this on upstream. Thius I think this PR should be good to close. wdyt about this idea?

Sounds good. One concern is I wonder if they have time to review, approve and release it in the upstream before we need it. Maybe let's avoid deleting this branch for now so that we can fallback to it in the worst case

@czarcas7ic
Copy link
Member

Same PR going upstream, closing here

@czarcas7ic czarcas7ic closed this Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants