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

08-wasm checksum fields should be (de)serialized with hex #1285

Closed
Farhad-Shabani opened this issue Jul 17, 2024 · 1 comment
Closed

08-wasm checksum fields should be (de)serialized with hex #1285

Farhad-Shabani opened this issue Jul 17, 2024 · 1 comment
Assignees
Milestone

Comments

@Farhad-Shabani
Copy link
Member

Summary

The checksum included in any type of 08-wasm messages, such as wasm ClientState, should be hex-encoded bytes. The ibc-go 08-wasm light client initially hex-decodes this to a valid checksum.
However, in a subsequent step, the entire payload, containing the checksum, is base64-encoded by the VM before being passed to a CosmWasm contract entry point.

Therefore, the wasm ClientState as client-side type should (de)serialize checksum with hex. Though, in the CosmWasm contract, since the VM passes base64-encoded bytes, we still have to keep using Binary type for the InstantiateMsg so can properly obtain the checksum bytes.

Version

<= 0.53.0

@Farhad-Shabani Farhad-Shabani added the A: bug Admin: something isn't working label Jul 17, 2024
@Farhad-Shabani Farhad-Shabani added this to the 0.54.0 milestone Jul 17, 2024
@Farhad-Shabani Farhad-Shabani self-assigned this Jul 17, 2024
@github-project-automation github-project-automation bot moved this to 📥 To Do in ibc-rs Jul 17, 2024
@Farhad-Shabani Farhad-Shabani removed the A: bug Admin: something isn't working label Jul 19, 2024
@Farhad-Shabani
Copy link
Member Author

Farhad-Shabani commented Jul 19, 2024

Following further investigation, we realized that the checksum, whether under the InstantiateMsg or a Wasm ClientState structs, is always base64 deserialized by VM before being passed to the CosmWasm contract entry point. Therefore, our definitions and serde derivations were correct as they were.

The confusion arose when we tried to use the Checksum type from the cosmwasm-std library, which offers hex (de)serialization. Although it is correct to use hex strings to derive checksum bytes from the relayer's perspective, on-chain operations require base64-encoded strings.

A few tests are added by PR #1283 to ensure this is taken into account.

@github-project-automation github-project-automation bot moved this from 📥 To Do to ✅ Done in ibc-rs Jul 19, 2024
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

No branches or pull requests

1 participant