Skip to content

[ibc-client-tendermint-types] properly handle fallible conversion between prost Duration and core Duration #1376

@rnbguy

Description

@rnbguy

Bug Summary

This PR cometbft/tendermint-rs#1456 makes the conversion between tendermint-rs's auto-compiled Google's Duration and core::time::Duration fallible in both direction.

Because of this, our From<DomainClientState> for ProtoClientState pattern fails for Tendermint light client state implementations.

Details

The below is the current fix for Tendermint light client fields which use Duration type.

https://github.com/cosmos/ibc-rs/blob/81625d6f99a137ed39cce4429a16ff6f66742fc3/ibc-clients/ics07-tendermint/types/src/client_state.rs#L323-L325

Ideally, the following implementation

https://github.com/cosmos/ibc-rs/blob/81625d6f99a137ed39cce4429a16ff6f66742fc3/ibc-clients/ics07-tendermint/types/src/client_state.rs#L317

should be refactored to,

impl TryFrom<ClientState> for RawTmClientState

with

 trusting_period: Some(value.trusting_period.try_into()?), 
 unbonding_period: Some(value.unbonding_period.try_into()?), 
 max_clock_drift: Some(value.max_clock_drift.try_into()?),

For this, we need a refactor of Protobuf trait in tendermint-rs repo -- which should use TryFrom<Self>.

pub trait Protobuf<T: Message + TryFrom<Self> + Default>
where ...

Version

Metadata

Metadata

Assignees

No one assigned

    Labels

    A: bugAdmin: something isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions