Skip to content

Commit

Permalink
Update to tendermint =0.23.2 and remove chrono (informalsystems#1665)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
mzabaluev committed Dec 16, 2021
1 parent 38a8dc9 commit 9c2d2ad
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Pin tendermint-rs dependencies to =0.23.2
([#1665](https://github.com/informalsystems/ibc-rs/pull/1665))
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Remove `Timestamp` API that depended on the `chrono` crate:
([#1665](https://github.com/informalsystems/ibc-rs/pull/1665)):
- `Timestamp::from_datetime`; use `From<tendermint::Time>`
- `Timestamp::as_datetime`, superseded by `Timestamp::into_datetime`
4 changes: 4 additions & 0 deletions .changelog/unreleased/improvements/ibc/1665-remove-chrono.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- More conventional ad-hoc conversion methods on `Timestamp`
([#1665](https://github.com/informalsystems/ibc-rs/pull/1665)):
- `Timestamp::nanoseconds` replaces `Timestamp::as_nanoseconds`
- `Timestamp::into_datetime` substitutes `Timestamp::as_datetime`
45 changes: 25 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 12 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@ exclude = [
]

# [patch.crates-io]
# tendermint = { git = "https://github.com/informalsystems/tendermint-rs", branch = "master" }
# tendermint-rpc = { git = "https://github.com/informalsystems/tendermint-rs", branch = "master" }
# tendermint-proto = { git = "https://github.com/informalsystems/tendermint-rs", branch = "master" }
# tendermint-light-client = { git = "https://github.com/informalsystems/tendermint-rs", branch = "master" }
# tendermint-testgen = { git = "https://github.com/informalsystems/tendermint-rs", branch = "master" }
# tendermint = { git = "https://github.com/informalsystems/tendermint-rs", branch = "v0.23.x" }
# tendermint-rpc = { git = "https://github.com/informalsystems/tendermint-rs", branch = "v0.23.x" }
# tendermint-proto = { git = "https://github.com/informalsystems/tendermint-rs", branch = "v0.23.x" }
# tendermint-light-client = { git = "https://github.com/informalsystems/tendermint-rs", branch = "v0.23.x" }
# tendermint-testgen = { git = "https://github.com/informalsystems/tendermint-rs", branch = "v0.23.x" }

# [patch.crates-io]
# tendermint = { path = "../tendermint-rs/tendermint" }
# tendermint-rpc = { path = "../tendermint-rs/rpc" }
# tendermint-proto = { path = "../tendermint-rs/proto" }
# tendermint-light-client = { path = "../tendermint-rs/light-client" }
# tendermint-testgen = { path = "../tendermint-rs/testgen" }
1 change: 0 additions & 1 deletion ci/no-std-check/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ sp-std = { version = "3.0.0", default-features = false, optional = true }

# Dependencies that support no_std
bytes = { version = "1.0.1", default-features = false }
chrono = { version = "0.4.19", default-features = false }
contracts = { version = "0.4.0", default-features = false }
crossbeam-channel = { version = "0.5.1", default-features = false }
ed25519 = { version = "1.2.0", default-features = false, features = ["serde"] }
Expand Down
1 change: 0 additions & 1 deletion ci/no-std-check/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use sp_std;
// Supported Imports

use bytes;
use chrono;
use contracts;
use crossbeam_channel;
use ed25519;
Expand Down
8 changes: 4 additions & 4 deletions relayer-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ flex-error = { version = "0.4.4", default-features = false, features = ["std", "
signal-hook = "0.3.12"

[dependencies.tendermint-proto]
version = "=0.23.1"
version = "=0.23.2"

[dependencies.tendermint]
version = "=0.23.1"
version = "=0.23.2"
features = ["secp256k1"]

[dependencies.tendermint-rpc]
version = "=0.23.1"
version = "=0.23.2"
features = ["http-client", "websocket-client"]

[dependencies.tendermint-light-client]
version = "=0.23.1"
version = "=0.23.2"
features = ["unstable"]

[dependencies.abscissa_core]
Expand Down
11 changes: 5 additions & 6 deletions relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ ibc = { version = "0.9.0", path = "../modules" }
ibc-proto = { version = "0.13.0", path = "../proto" }
ibc-telemetry = { version = "0.9.0", path = "../telemetry", optional = true }

chrono = { version = "0.4.19", default-features = false, features = ["clock"] }
subtle-encoding = "0.5"
humantime-serde = "1.0.0"
serde = "1.0"
Expand Down Expand Up @@ -71,20 +70,20 @@ version = "0.4.0"
features = ["num-bigint", "serde"]

[dependencies.tendermint]
version = "=0.23.1"
version = "=0.23.2"
features = ["secp256k1"]

[dependencies.tendermint-rpc]
version = "=0.23.1"
version = "=0.23.2"
features = ["http-client", "websocket-client"]

[dependencies.tendermint-light-client]
version = "=0.23.1"
version = "=0.23.2"
default-features = false
features = ["rpc-client", "secp256k1", "unstable"]

[dependencies.tendermint-proto]
version = "=0.23.1"
version = "=0.23.2"

[dev-dependencies]
ibc = { version = "0.9.0", path = "../modules", features = ["mocks"] }
Expand All @@ -94,4 +93,4 @@ tracing-subscriber = { version = "0.3.3", features = ["fmt", "env-filter", "json
test-log = { version = "0.2.8", features = ["trace"] }

# Needed for generating (synthetic) light blocks.
tendermint-testgen = { version = "=0.23.1" }
tendermint-testgen = { version = "=0.23.2" }
6 changes: 2 additions & 4 deletions relayer/src/chain/cosmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use std::{fmt, thread, time::Instant};

use bech32::{ToBase32, Variant};
use bitcoin::hashes::hex::ToHex;
use chrono::DateTime;
use itertools::Itertools;
use prost::Message;
use prost_types::Any;
Expand Down Expand Up @@ -57,7 +56,6 @@ use ibc::core::ics24_host::{ClientUpgradePath, Path, IBC_QUERY_PATH, SDK_UPGRADE
use ibc::events::{from_tx_response_event, IbcEvent};
use ibc::query::{QueryTxHash, QueryTxRequest};
use ibc::signer::Signer;
use ibc::timestamp::Timestamp;
use ibc::Height as ICSHeight;
use ibc::{downcast, query::QueryBlockRequest};
use ibc_proto::cosmos::auth::v1beta1::{BaseAccount, EthAccount, QueryAccountRequest};
Expand Down Expand Up @@ -1103,15 +1101,15 @@ impl ChainEndpoint for CosmosSdkChain {
crate::time!("query_status");
let status = self.status()?;

let time = DateTime::from(status.sync_info.latest_block_time);
let time = status.sync_info.latest_block_time;
let height = ICSHeight {
revision_number: ChainId::chain_version(status.node_info.network.as_str()),
revision_height: u64::from(status.sync_info.latest_block_height),
};

Ok(StatusResponse {
height,
timestamp: Timestamp::from_datetime(time),
timestamp: time.into(),
})
}

Expand Down
3 changes: 1 addition & 2 deletions relayer/src/foreign_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use core::{fmt, time::Duration};
use std::thread;
use std::time::Instant;

use chrono::Utc;
use itertools::Itertools;
use prost_types::Any;
use tracing::{debug, error, info, trace, warn};
Expand Down Expand Up @@ -569,7 +568,7 @@ impl<DstChain: ChainHandle, SrcChain: ChainHandle> ForeignClient<DstChain, SrcCh
// we can backoff between subsequent client updates.
let refresh_window = client_state.refresh_period();
// Compute the duration since the last update of this client
let elapsed = Timestamp::from_datetime(Utc::now()).duration_since(&last_update_time);
let elapsed = Timestamp::now().duration_since(&last_update_time);

if client_state.is_frozen() || client_state.expired(elapsed.unwrap_or_default()) {
return Err(ForeignClientError::expired_or_frozen(
Expand Down
4 changes: 1 addition & 3 deletions relayer/src/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use core::fmt::{Display, Formatter};
use core::str::FromStr;
use core::time::Duration;

use chrono::Utc;
use flex_error::{define_error, DetailOnly};
use ibc::applications::ics20_fungible_token_transfer::msgs::transfer::MsgTransfer;
use ibc::core::ics24_host::identifier::{ChainId, ChannelId, PortId};
Expand Down Expand Up @@ -98,8 +97,7 @@ pub fn build_and_send_transfer_messages<SrcChain: ChainHandle, DstChain: ChainHa
let timeout_timestamp = if opts.timeout_seconds == Duration::from_secs(0) {
Timestamp::none()
} else {
(Timestamp::from_datetime(Utc::now()) + opts.timeout_seconds)
.map_err(PacketError::timestamp_overflow)?
(Timestamp::now() + opts.timeout_seconds).map_err(PacketError::timestamp_overflow)?
};

let timeout_height = if opts.timeout_height_offset == 0 {
Expand Down
4 changes: 2 additions & 2 deletions tools/integration-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ ibc = { path = "../../modules" }
ibc-relayer = { path = "../../relayer" }
ibc-relayer-cli = { path = "../../relayer-cli" }
ibc-proto = { path = "../../proto" }
tendermint = { version = "=0.23.1" }
tendermint-rpc = { version = "=0.23.1", features = ["http-client", "websocket-client"] }
tendermint = { version = "=0.23.2" }
tendermint-rpc = { version = "=0.23.2", features = ["http-client", "websocket-client"] }

tokio = { version = "1.0", features = ["full"] }
tracing = "0.1.26"
Expand Down

0 comments on commit 9c2d2ad

Please sign in to comment.