rfc3339 direct ser/deser fix for protobuf Timestamp #666
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.
A fix for an issue that bubbled up during #665 .
The Time domain type was incorrectly serialized by itself. (It was correctly serialized as part of another struct.)
This change implements correct serialization for tendermint::Time via tendermint_proto::Timestamp.
Timestamp needed a helper struct so it could be serialized/deserialized without custom serializers.
You can clearly see the dependencies on serializers in this change:
The serializer to correctly ser/deser an RFC3339 string into a Timestamp is moved into
tendermint_proto::serializers::timestamp
.The Timestamp struct needs a helper struct so it can use those serializers. Otherwise Timestamp would have required a custom serializer.
With the Timestamp struct directly serializable, there's no need for special serialization for
Option<Timestamp>
. All structs having that field can now be serialized by just defining serialization overOption<>
with thetendermint_proto::serializers::optional
module.Unfortunately, the tendermint::Time struct is directly serialized/deserialized in testgen structs (and possibly in IBC) in several places. But now that it is directly serializable through Timestamp (and from an RFC3339 string), there is no need for extra annotation when serializing/deserializing it. It's going to be interesting if/when someone comes to us that they need it serialized differently (in the
{seconds:x,nanos:x}
format, isntead of RFC3339).Referenced an issue explaining the need for the change
Updated all relevant documentation in docs
Updated all code comments where relevant
Wrote tests
Updated CHANGELOG.md