-
Notifications
You must be signed in to change notification settings - Fork 103
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
Change IBCTimeout's Timestamp field to new Uint64 #473
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, not sure if this is the way. But let's see.
IbcTimeout is used in both directions:
IbcMsg::Transfer
IbcPacket
On the Go side, 0 is used to represent an unset Timeout (wasmd, ibc-go). This means wasmd would have to convert 0 -> nil as a special case. Then we have two different nulls here that cannot be differentiated by ibc-go (nil and Uint64(0)), so we either need to make it impossible to every have Uint64(0) or have a step in wasmd that merged the two into 0.
Would it be possible to get
Timestamp Uint64
to work instead? Not sure how flexible the combination of custom type and annotations is.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole concept of mapping a Go uint64 to a Rust Option is a bet flawed anyways. What you'd actually want is Option<NonNull> to keep a 1:1 mapping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the mapping is a bit flawed.
Timestamp Uint64
would work withtimestamp: Timestamp
on the rust side. Not very rusty, but at least consistent with the go side.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or if we could make the go-gen emit
Timestamp Uint64
withomitempty
, then that could also work withtimestamp: Option<Timestamp>
on the rust side, but not sure how to best approach that.Ofc this still has the flaw that both 0 and
None
are ways to represent 0 on the go side.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think this is pretty much what we want. Get back to the current code but just change uint64 -> Uint64.
Then we have for
Go -> Rust:
In Go, only one zero state exists, which is Uint64(0). Does it understand that to be empty and can omit it? If yes, good, then it becomes
None
in Rust. If no, we get Some(Timestamp::from_nanos(0)) which is not what we want in Rust.Rust -> Go:
Option<Timestamp>
can benull
or"0"
. "0" becomes Uint64(0). But does Go understand Uint64's default? Can it translatenull
or unset to Uint64(0)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, maybe we should not do this in general and instead create a
IBCTimeout
specific solution that deserialized into a helper type first and then turns nil into Uint64(0) for convenient of our Go users.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I thought the same at first, because we probably don't always want
null
to become 0.On the other hand, as you already said, that is the default behaviour for Go's
uint64
, so for Go users it probably makes more sense to always do that conversion.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe not so relevant for
Option<Timestamp>
, but I can easily come up with ideas forOption<Uint64>
where None means something different than Some(0). Let's look for a timeout specific solution, which can either be some sort of custom deserializer or just keep the type we currently have.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to make that distinction, then it could still be made with
*Uint64
on the Go side:nil
then serializes tonull
(or skipped if omitempty) andnull
deserializes tonil
, while"0"
deserializes to&Uint64(0)
.But I am also fine with just keep the version we have right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want the ability to make the distinction in other places, but not here. So I suggest keeping the current version and close this.
Glad we discussed this though!