cosmos / ibc-rs

Rust implementation of the Inter-Blockchain Communication (IBC) protocol.
Apache License 2.0
182 stars 73 forks source link

ics02: remove `TryFrom<Error = ClientError>` restriction #1203

Closed rnbguy closed 2 months ago

rnbguy commented 2 months ago

Bug Summary

Currently ClientStateDecoder, ConsensusStateDecoder and Convertible takes ClientError for TryFrom::Error or a generic E for TryInto::Error.

https://github.com/cosmos/ibc-rs/blob/67d0735d3acc41ddadf8b20eb4b77c02f3707435/ibc-core/ics02-client/context/src/consensus_state.rs#L11

https://github.com/cosmos/ibc-rs/blob/67d0735d3acc41ddadf8b20eb4b77c02f3707435/ibc-core/ics02-client/context/src/client_state.rs#L15

https://github.com/cosmos/ibc-rs/blob/67d0735d3acc41ddadf8b20eb4b77c02f3707435/ibc-core/ics02-client/context/src/context.rs#L161

This should be avoided as this doesn't work with a TryFrom impl with a different error type.

Details

That TryFrom<T, Error = ClientError> should be TryFrom<T, Error: Into<ClientError>>. But we can't do this until associated-type-bounds stabilizes. This should be the case for ClientStateDecoder and Covertible too.

As an alternative, we can add where <Self as TryFrom<Any>>::Error: Into<ClientError> - but we end up adding this bound in every impl and method signature. This can be avoided when implied-bounds stabilizes.

Version