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 · 3 comments · Fixed by #1397
Closed

wasm client fails to query TimestampAtHeight #1262

rnbguy opened this issue Jun 18, 2024 · 3 comments · Fixed by #1397
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
Member

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)] with #[cfg_attr(feature = "serde", ...)].
https://github.com/cosmos/ibc-rs/blob/8424f6903045b203614f12a5839c330a3559cece/ibc-core/ics02-client/types/src/height.rs#L32-L34

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
Member Author

rnbguy commented Jun 18, 2024

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

@rnbguy
Copy link
Member Author

rnbguy commented Oct 4, 2024

ibc-go's main branch contains the fix.

The fix landed on ibc-go v9.

@rnbguy
Copy link
Member Author

rnbguy commented Jan 27, 2025

Looks like, we need a patch for this. ibc-go v8 wasm doesn't have this fix and breaks with ibc-rs wasm light client integration.

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
None yet
Development

Successfully merging a pull request may close this issue.

1 participant