Skip to content

imp(types): refactor Default implementations with concrete names #1074

@rnbguy

Description

@rnbguy

Details

There are a few Default implementations in ibc-rs codebase. My opinion is - they should not be called Default. Default can mean different things in different contexts. Users are encouraged to be specific.

For examples,

My opinion is to use ::zero(), ::one(), ::empty() - to be specific in the context.

Along with it, some of the Default values are not expected somewhere else. For example, CommitmentPrefix derives Default.

https://github.com/cosmos/ibc-rs/blob/caee889ad308a4aac3f9905de9cdda76c5533cfb/ibc-core/ics23-commitment/types/src/commitment.rs#L147-L150

Which recursively used for Counterparty's Default.

https://github.com/cosmos/ibc-rs/blob/caee889ad308a4aac3f9905de9cdda76c5533cfb/ibc-core/ics03-connection/types/src/connection.rs#L381-L386

But CounterParty::try_from(RawCounterParty::from(Counterparty::default())) fails as RawCounterparty::from assigns empty CommitmentPrefix - which is not expected when it is converted back to Counterparty.

https://github.com/cosmos/ibc-rs/blob/caee889ad308a4aac3f9905de9cdda76c5533cfb/ibc-core/ics03-connection/types/src/connection.rs#L412-L417

Version

<= v0.50.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    O: reliabilityObjective: cause to improve trustworthiness and consistent performing

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions