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

Update to tendermint =0.23.2 and remove chrono #1665

Merged
merged 11 commits into from
Dec 16, 2021

Conversation

mzabaluev
Copy link
Contributor

@mzabaluev mzabaluev commented Dec 13, 2021

Closes #1639

Description

Update to changes in tendermint-rs 0.23.2 and remove all direct chrono dependencies.

Also renamed or removed Timestamp methods:

  • as_nanoseconds renamed to nanoseconds with deprecation of the old convention-breaking name;
  • as_datetime removed, into_datetime comes in its stead.
  • from_datetime removed, From<tendermint::Time> remains as a substitute.

PR author checklist:

  • Added changelog entry, using unclog.
  • Added tests: integration (for Hermes) or unit/mock tests (for modules).
  • Linked to GitHub issue.
  • Updated code comments and documentation (e.g., docs/).

Reviewer checklist:

  • Reviewed Files changed in the GitHub PR explorer.
  • Manually tested (in case integration/unit/mock tests are absent).

@mzabaluev mzabaluev added the I: dependencies Internal: related to dependencies label Dec 13, 2021
@mzabaluev mzabaluev force-pushed the mikhail/tendermint-0.23.2-and-remove-chrono branch from 56a2cda to fcea486 Compare December 13, 2021 16:49
Got some clarification from Soares about this.
@mzabaluev mzabaluev added the A: breaking Admin: breaking change that may impact operators label Dec 13, 2021
@mzabaluev mzabaluev marked this pull request as ready for review December 13, 2021 22:09
pub fn as_datetime(&self) -> Option<DateTime<Utc>> {
self.time
/// Convert a `Timestamp` to an optional [`OffsetDateTime`]
pub fn into_datetime(self) -> Option<OffsetDateTime> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder if we'd be more interested in getting tendermint::Time here?
That would also get rid of a public dependency on time.

Copy link
Member

Choose a reason for hiding this comment

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

Outside of ics07, we are not supposed to depend on Tendermint-specific code but I guess we can make an exception for the Time struct since it's general purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my mad scientist's secret world assimilation plan, we'll migrate to a common domain types crate that will provide idiomatic Rust support for Google's well-known protobuf types, and tendermint::Time will be morphed into one of the types from that yet unpublished crate. Until then, it could be whatever seems most practical at the moment.

Copy link
Contributor

@thanethomson thanethomson left a comment

Choose a reason for hiding this comment

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

Might also be worthwhile to mention in the changelog that we're upgrading to tendermint-rs v0.23.2.

Cargo.toml Show resolved Hide resolved
@@ -107,7 +107,7 @@ impl ClientDef for TendermintClient {
untrusted_state,
trusted_state,
&options,
Time(chrono::Utc::now()),
OffsetDateTime::now_utc().try_into().unwrap(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we not perhaps implement a now_utc() method for the Time struct to avoid directly importing dependencies from the time crate? I'd generally prefer to use interfaces that hide their underlying implementations as far as possible, as it reduces entanglement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The trouble with now_utc is, it requires std. So I assume it can't be part of Tendermint's core API without an std feature gate, too.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I can look into providing that mechanism. It's probably preferable to avoid mixing newtypes and the types they're supposed to wrap.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We'd still want to provide the TryFrom/Into conversions from/to OffsetDateTime for convenience, and time is not an optional dependency at the moment (though it could be after redoing the internal representation of Time per ADR-010).

modules/src/timestamp.rs Show resolved Hide resolved
modules/src/timestamp.rs Outdated Show resolved Hide resolved
@mzabaluev mzabaluev merged commit e7a6403 into master Dec 16, 2021
@mzabaluev mzabaluev deleted the mikhail/tendermint-0.23.2-and-remove-chrono branch December 16, 2021 17:59
hu55a1n1 pushed a commit to hu55a1n1/hermes that referenced this pull request Sep 13, 2022
* Bump tendermint-rs versions to 0.23.2

* modules: Replaced uses of chrono with time-rs

Update to the related changes in tendermint API.

* relayer: Removed uses of chrono

* no-std-check: Remove chrono
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: breaking Admin: breaking change that may impact operators I: dependencies Internal: related to dependencies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace chrono with time 0.3
4 participants