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

wasm client fails to query TimestampAtHeight #1262

Closed
rnbguy opened this issue Jun 18, 2024 · 2 comments
Closed

wasm client fails to query TimestampAtHeight #1262

rnbguy opened this issue Jun 18, 2024 · 2 comments
Labels
A: blocked Admin: blocked by another (internal/external) issue or PR A: bug Admin: something isn't working S: wasm Scope: support Wasm envs

Comments

@rnbguy
Copy link
Collaborator

rnbguy commented Jun 18, 2024

Bug Summary

With a wasm light client, compiled from ibc-rs, ibc-go fails to query TimestampAtHeight. The error it raises:

Error: Status { code: Unknown, message: "failed to execute message; message index: 0: height (0-32): Error parsing into type ibc_client_cw::types::msgs::QueryMsg: missing field revision_number: wasm contract call failed [cosmos/ibc-go/modules/light-clients/08-wasm/types/vm.go:212] With gas wanted: '18446744073709551615' and gas used: '106008' ", metadata: MetadataMap { headers: {"content-type": "application/grpc", "x-cosmos-block-height": "56"} }, source: None }

Details

This happens as ibc-go omits revision_number field if it is set to zero while mashaling to JSON. From json go package:

The "omitempty" option specifies that the field should be omitted from the encoding if the field has an empty value, defined as false, 0, a nil pointer, a nil interface value, and any empty array, slice, map, or string.

type Height struct {
	RevisionNumber int `json:"revision_number,omitempty"`
	RevisionHeight int `json:"revision_height,omitempty"`
}
h := Height{RevisionNumber: 0, RevisionHeight: 12}
hJSON, _ := json.Marshal(h)
fmt.Printf("%s", hJSON) // {"revision_height":12}

To make it work, we need to annotate our revision_number field with #[serde(default)].

pub struct Height {
/// Previously known as "epoch"
revision_number: u64,

Version

v0.53.0

@rnbguy rnbguy added this to ibc-rs Jun 18, 2024
@github-project-automation github-project-automation bot moved this to 📥 To Do in ibc-rs Jun 18, 2024
@rnbguy rnbguy added A: bug Admin: something isn't working S: wasm Scope: support Wasm envs labels Jun 18, 2024
@rnbguy
Copy link
Collaborator Author

rnbguy commented Jun 18, 2024

This requires a design decision. So, please refrain from creating a PR for this.

@rnbguy
Copy link
Collaborator Author

rnbguy commented Oct 4, 2024

ibc-go's main branch contains the fix.

@rnbguy rnbguy closed this as completed Oct 4, 2024
@github-project-automation github-project-automation bot moved this from 📥 To Do to ✅ Done in ibc-rs Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: blocked Admin: blocked by another (internal/external) issue or PR A: bug Admin: something isn't working S: wasm Scope: support Wasm envs
Projects
Status: Done
Development

No branches or pull requests

1 participant