-
Notifications
You must be signed in to change notification settings - Fork 608
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
Conversation
There was a problem hiding this 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 :)
@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! |
This reverts commit eb216a1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
// 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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) { |
There was a problem hiding this comment.
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?
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 |
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
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
Unreleased
section inCHANGELOG.md
? (yes / no)x/<module>/spec/
) / Osmosis docs repo / not documented)