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 deterministic Cosmwasm stargate queries #2190

Closed
wants to merge 11 commits into from

Conversation

mattverse
Copy link
Member

What is the purpose of the change

cref: osmosis-labs/wasmd#7

The original design was to have basic initialization for the whitelisted quries in the wasmd side, but upon leaving the inititialized whitelist empty, this is the attempt to move the whitelisted quries and bindings layer into osmosis side.

Brief Changelog

  • Add whitelisted stargate queries and ensure deterministic query.

Testing and Verifying

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.

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? (yes / no)
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? (yes / no)
  • How is the feature or change documented? (not applicable / specification (x/<module>/spec/) / Osmosis docs repo / not documented)

@mattverse mattverse requested a review from a team July 22, 2022 09:41
@github-actions github-actions bot added C:app-wiring Changes to the app folder T:build labels Jul 22, 2022
wasmbinding/stargate_bindings.go Outdated Show resolved Hide resolved
wasmbinding/stargate_bindings.go Outdated Show resolved Hide resolved
wasmbinding/stargate_bindings.go Outdated Show resolved Hide resolved
wasmbinding/wasm.go Show resolved Hide resolved
@sunnya97 sunnya97 changed the title Enable deterministic Cosmwasm stargate quries Enable deterministic Cosmwasm stargate queries Jul 29, 2022
@mattverse mattverse marked this pull request as draft August 1, 2022 15:21
@github-actions github-actions bot removed the T:build label Aug 1, 2022
@mattverse mattverse marked this pull request as ready for review August 1, 2022 16:07
@mattverse mattverse requested review from ValarDragon, p0mvn and a team August 1, 2022 16:07
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

What's the conclusion we came to on today's call re stargate queries? I'd like to get clarification prior to reviewing this :)

@mattverse
Copy link
Member Author

@alexanderbez For twap, we're planning to use bindings. However, we also do want to work towards enabling whitelisted stargate queries, this PR should be good for a round of review!

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

LGTM

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/query_plugin.go Show resolved Hide resolved
@mattverse mattverse mentioned this pull request Aug 4, 2022
5 tasks
// StargateQuerier dispatches whitelisted stargate queries
func StargateQuerier(queryRouter baseapp.GRPCQueryRouter) func(ctx sdk.Context, request *wasmvmtypes.StargateQuery) ([]byte, error) {
return func(ctx sdk.Context, request *wasmvmtypes.StargateQuery) ([]byte, error) {
binding, whitelisted := StargateWhitelist.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.

Just want to be extra-sure, this path is the /cosmos.auth.v1beta1.Query/Account path, NOT the http path in the proto files right?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, they are defined in the whitelist file

}

// normalize response to ensure backward compatibility
bz, err := NormalizeReponse(binding, res.Value)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
bz, err := NormalizeReponse(binding, res.Value)
bz, err := NormalizeResponse(binding, res.Value)

@@ -110,6 +144,33 @@ func CustomQuerier(qp *QueryPlugin) func(ctx sdk.Context, request json.RawMessag
}
}

// NormalizeReponses normalizes the responses by unmarshalling the response then marshalling them again.
// Normalizing the response is specifically important for responses that contain type of Any.
func NormalizeReponse(binding interface{}, bz []byte) ([]byte, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this normalization needed? Since we are not defining custom query protos in our repo and, instead, are directly using what is in the sdk and/or Osmosis, what are we ensuring backward compatibility against?

@mattverse
Copy link
Member Author

Found out that we need to Json Marshal the responses because cosmwasm stargate querier json unmarshals the responses by default. Closing this PR and opening a new PR replacing this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:app-wiring Changes to the app folder
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants