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

proto: Align TryFrom impls for Duration with prost-types #1456

Merged
merged 2 commits into from
Aug 8, 2024

Conversation

romac
Copy link
Member

@romac romac commented Aug 8, 2024

No description provided.

@romac romac requested a review from tony-iqlusion August 8, 2024 12:13
@romac romac marked this pull request as ready for review August 8, 2024 12:13
Copy link
Collaborator

@tony-iqlusion tony-iqlusion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this probably makes more sense than supporting negative durations, at least unless there's an actual use for them in the Cosmos ecosystem somewhere

@tony-iqlusion tony-iqlusion merged commit f1ebab8 into main Aug 8, 2024
23 checks passed
@tony-iqlusion tony-iqlusion deleted the proto/try-from-duration-error branch August 8, 2024 19:05
@tony-iqlusion
Copy link
Collaborator

@romac with this merged I can confirm I can upgrade cosmos-sdk-proto / cosmrs 🎉

@romac
Copy link
Member Author

romac commented Aug 8, 2024

Glad to hear! Will do a release tomorrow then

@tony-iqlusion
Copy link
Collaborator

@romac it'd be good if you can get #1457 in as well

@romac
Copy link
Member Author

romac commented Aug 8, 2024

Will do! Apologies for the oversight and thanks for all the PRs 🙏

@rnbguy
Copy link
Member

rnbguy commented Nov 12, 2024

Coming from the above ibc-rs issue. Because of this PR, we can't expect Protobuf<T: From<Self>>. So the Protobuf trait

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

should be refactored to something like

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

Should I open an issue for this? Or I missed anything from the latest releases?

@romac
Copy link
Member Author

romac commented Nov 12, 2024

Ah that's an oversight from my part, sorry about that. Not sure what to do about that though? Do you think can make that conversion infallible for Duration?

@rnbguy
Copy link
Member

rnbguy commented Nov 13, 2024

I just explored the idea of trait Protobuf<T: Message + TryFrom<Self> + Default> and realized a lot of refactor needs to be done inside the tendermint domain types. Mainly because the encode_length or encode_vec -- these two Protobuf trait methods become fallible -- which in turn makes methods like hash, sign_bytes, into_signable_vec infallible too.

I am going to open an issue for this and continue the discussion there.

@erwanor
Copy link
Collaborator

erwanor commented Dec 7, 2024

Like Rano said, this broke a general ecosystem pattern of infallible domain type to wire conversion. To route around this, we are newtyping the core duration and making the conversion infallible: penumbra-zone/ibc-types#94. This is kind of ugly but works.

I don't think we should let this change contaminate the rest of the ecosystem types by changing the Protobuf marker trait. It's a core ecosystem pattern that is very entrenched, and good. If we change it, we generate work and headwinds for downstreams, with no upside in return.

Without commenting on this specific change, it would be awesome to have more heads up/consensus when we change domain type modeling or APIs. This is because the smallest change has dangerous ripple effects throughout. In most cases, downstream crates can navigate those change nimbly, but they are more perilous for deployed systems that need to plan around consensus/state compatibility. That's the case for Penumbra, Astria, Namada, and I'm sure many others as well.

@romac
Copy link
Member Author

romac commented Dec 9, 2024

Agreed, we should probably revert the change and make the conversion infallible again. Maybe we can provide a newtype type that is fallible in case someone needs to make sure that the conversion does not saturate?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants