informalsystems / hermes-sdk

Apache License 2.0
9 stars 2 forks source link

Query for ConnectionEnd fails on Sovereign #333

Closed soareschen closed 1 month ago

soareschen commented 1 month ago

When querying the connection end on Sovereign, the client fails when parsing the response with the error:

Error: ParseError(Error("invalid type: string \"ibc\", expected struct CommitmentPrefix", line: 1, column: 139))

The failure is caused by the inconsistencies of serializing and deserializing the CommitmentPrefix struct on ibc-rs:

#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
pub struct CommitmentPrefix {
    bytes: Vec<u8>,
}

#[cfg(feature = "serde")]
impl serde::Serialize for CommitmentPrefix {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        format!("{self:?}").serialize(serializer)
    }
}

The implementation has an auto-derived Deserialize instance, but has a manually derived Serialize instance that treats the commitment as a string.

This has to be fixed on ibc-rs side with https://github.com/cosmos/ibc-rs/issues/1229. After that, the dependencies need to be updated on sov-rollup-starter, and then be tested again.

A temporary fix is pushed to the branch https://github.com/cosmos/ibc-rs/tree/soares/fix-commitment-prefix-deserialize. The temporary fix follows the serialization behavior and desrializes the JSON as string. This is so that the temporary fix can be applied on the client-side only without having to update sov-rollup-starter. Once a proper fix is done, we should update the dependency in Cargo.toml to use back the main branch.