From 8d67c15b69831e921400589a33cc5eb68bff3efe Mon Sep 17 00:00:00 2001 From: Mikhail Zabaluev Date: Fri, 10 Dec 2021 12:06:44 +0200 Subject: [PATCH 01/10] Bump tendermint-rs versions to 0.23.2 --- modules/Cargo.toml | 12 ++++++------ proto/Cargo.toml | 2 +- relayer-cli/Cargo.toml | 8 ++++---- relayer/Cargo.toml | 10 +++++----- tools/integration-test/Cargo.toml | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/modules/Cargo.toml b/modules/Cargo.toml index 263905bb39..a22a156c92 100644 --- a/modules/Cargo.toml +++ b/modules/Cargo.toml @@ -42,17 +42,17 @@ sha2 = { version = "0.9.8", default-features = false } flex-error = { version = "0.4.4", default-features = false } [dependencies.tendermint] -version = "=0.23.1" +version = "=0.23.2" [dependencies.tendermint-proto] -version = "=0.23.1" +version = "=0.23.2" [dependencies.tendermint-light-client] -version = "=0.23.1" +version = "=0.23.2" default-features = false [dependencies.tendermint-testgen] -version = "=0.23.1" +version = "=0.23.2" optional = true [dev-dependencies] @@ -61,8 +61,8 @@ tracing-subscriber = { version = "0.3.3", features = ["fmt", "env-filter", "json test-log = { version = "0.2.8", features = ["trace"] } modelator = "0.4.1" sha2 = { version = "0.9.8" } -tendermint-rpc = { version = "=0.23.1", features = ["http-client", "websocket-client"] } -tendermint-testgen = { version = "=0.23.1" } # Needed for generating (synthetic) light blocks. +tendermint-rpc = { version = "=0.23.2", features = ["http-client", "websocket-client"] } +tendermint-testgen = { version = "=0.23.2" } # Needed for generating (synthetic) light blocks. [[test]] name = "mbt" diff --git a/proto/Cargo.toml b/proto/Cargo.toml index 1f3986be3e..e7a1b4e213 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -30,4 +30,4 @@ getrandom = { version = "0.2", features = ["js"] } serde = "1.0" [dependencies.tendermint-proto] -version = "=0.23.1" +version = "=0.23.2" diff --git a/relayer-cli/Cargo.toml b/relayer-cli/Cargo.toml index 34736cf62b..4cc6495772 100644 --- a/relayer-cli/Cargo.toml +++ b/relayer-cli/Cargo.toml @@ -56,18 +56,18 @@ flex-error = { version = "0.4.4", default-features = false, features = ["std", " signal-hook = "0.3.10" [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] diff --git a/relayer/Cargo.toml b/relayer/Cargo.toml index b35e784561..cef42709ee 100644 --- a/relayer/Cargo.toml +++ b/relayer/Cargo.toml @@ -72,20 +72,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"] } @@ -95,4 +95,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" } diff --git a/tools/integration-test/Cargo.toml b/tools/integration-test/Cargo.toml index 3257d190ca..d8b6538ed6 100644 --- a/tools/integration-test/Cargo.toml +++ b/tools/integration-test/Cargo.toml @@ -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" From 9b2dec54663d5faa41c7dfab6b7fd47f4e2a669f Mon Sep 17 00:00:00 2001 From: Mikhail Zabaluev Date: Mon, 13 Dec 2021 14:55:15 +0200 Subject: [PATCH 02/10] modules: Replaced uses of chrono with time-rs Update to the related changes in tendermint API. --- Cargo.lock | 50 +++--- Cargo.toml | 17 +- modules/Cargo.toml | 2 +- .../msgs/transfer.rs | 2 +- .../clients/ics07_tendermint/client_def.rs | 4 +- .../ics07_tendermint/consensus_state.rs | 22 ++- .../src/clients/ics07_tendermint/header.rs | 3 +- .../src/core/ics02_client/client_consensus.rs | 7 +- modules/src/core/ics04_channel/events.rs | 4 +- .../core/ics04_channel/handler/send_packet.rs | 2 +- modules/src/core/ics04_channel/packet.rs | 2 +- modules/src/mock/client_state.rs | 4 +- modules/src/mock/header.rs | 2 +- modules/src/mock/host.rs | 7 +- modules/src/timestamp.rs | 168 +++++++----------- 15 files changed, 131 insertions(+), 165 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 460094bb7d..60b3d0aecf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -315,7 +315,6 @@ dependencies = [ "libc", "num-integer", "num-traits", - "serde", "winapi", ] @@ -1252,7 +1251,6 @@ name = "ibc" version = "0.9.0" dependencies = [ "bytes", - "chrono", "env_logger", "flex-error", "ibc-proto", @@ -1273,6 +1271,7 @@ dependencies = [ "tendermint-testgen", "test-log", "thiserror", + "time", "tracing", "tracing-subscriber 0.3.3", ] @@ -2872,13 +2871,11 @@ dependencies = [ [[package]] name = "tendermint" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02880339f0e89dc7de809cb300a7dbe5e066c71937a7a55472438ae02e4a841b" +version = "0.23.2" +source = "git+https://github.com/informalsystems/tendermint-rs?branch=release/v0.23.2#5c201f022abad7de62b4a9a1e28e02a8afeeee1c" dependencies = [ "async-trait", "bytes", - "chrono", "ed25519", "ed25519-dalek", "flex-error", @@ -2898,14 +2895,14 @@ dependencies = [ "subtle", "subtle-encoding", "tendermint-proto", + "time", "zeroize", ] [[package]] name = "tendermint-config" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff01e0eacdcfb75e8a1bbbc2d71286f7b6db3eda82c52ad7ca4f619ebb90cc" +version = "0.23.2" +source = "git+https://github.com/informalsystems/tendermint-rs?branch=release/v0.23.2#5c201f022abad7de62b4a9a1e28e02a8afeeee1c" dependencies = [ "flex-error", "serde", @@ -2917,11 +2914,9 @@ dependencies = [ [[package]] name = "tendermint-light-client" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e7c4fe20856c514b6c37550f2f391183a5d4831820fec2e0703a19fc1523259" +version = "0.23.2" +source = "git+https://github.com/informalsystems/tendermint-rs?branch=release/v0.23.2#5c201f022abad7de62b4a9a1e28e02a8afeeee1c" dependencies = [ - "chrono", "contracts", "crossbeam-channel 0.4.4", "derive_more", @@ -2933,17 +2928,16 @@ dependencies = [ "static_assertions", "tendermint", "tendermint-rpc", + "time", "tokio", ] [[package]] name = "tendermint-proto" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1b8319fcf0860833eabe3278cf2d94ca20ef04bee6a77d892f986026fb1c252" +version = "0.23.2" +source = "git+https://github.com/informalsystems/tendermint-rs?branch=release/v0.23.2#5c201f022abad7de62b4a9a1e28e02a8afeeee1c" dependencies = [ "bytes", - "chrono", "flex-error", "num-derive", "num-traits", @@ -2952,18 +2946,17 @@ dependencies = [ "serde", "serde_bytes", "subtle-encoding", + "time", ] [[package]] name = "tendermint-rpc" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c88786eeb1b408530fa7a8151aa9639cc04a6210cd8b5fa27aaafbd1e2a091" +version = "0.23.2" +source = "git+https://github.com/informalsystems/tendermint-rs?branch=release/v0.23.2#5c201f022abad7de62b4a9a1e28e02a8afeeee1c" dependencies = [ "async-trait", "async-tungstenite", "bytes", - "chrono", "flex-error", "futures", "getrandom 0.1.16", @@ -2981,6 +2974,7 @@ dependencies = [ "tendermint-config", "tendermint-proto", "thiserror", + "time", "tokio", "tracing", "url", @@ -2990,11 +2984,9 @@ dependencies = [ [[package]] name = "tendermint-testgen" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6df4b2bc95b5c65ab661c8ab0e0054dd61b4e4c4edd53c2831c317e40042eac" +version = "0.23.2" +source = "git+https://github.com/informalsystems/tendermint-rs?branch=release/v0.23.2#5c201f022abad7de62b4a9a1e28e02a8afeeee1c" dependencies = [ - "chrono", "ed25519-dalek", "gumdrop", "serde", @@ -3002,6 +2994,7 @@ dependencies = [ "simple-error", "tempfile", "tendermint", + "time", ] [[package]] @@ -3078,8 +3071,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e0a10c9a9fb3a5dce8c2239ed670f1a2569fcf42da035f5face1b19860d52b0" dependencies = [ "libc", + "time-macros", ] +[[package]] +name = "time-macros" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72c7ca5e81982d152f0788b131ebf96cc4bbd1b4575a7ed51f0f6fc866a05fdb" + [[package]] name = "tiny-bip39" version = "0.8.2" diff --git a/Cargo.toml b/Cargo.toml index d80af786e4..eccbaeed05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,9 +17,16 @@ exclude = [ "proto-compiler" ] +[patch.crates-io] +tendermint = { git = "https://github.com/informalsystems/tendermint-rs", branch = "release/v0.23.2" } +tendermint-rpc = { git = "https://github.com/informalsystems/tendermint-rs", branch = "release/v0.23.2" } +tendermint-proto = { git = "https://github.com/informalsystems/tendermint-rs", branch = "release/v0.23.2" } +tendermint-light-client = { git = "https://github.com/informalsystems/tendermint-rs", branch = "release/v0.23.2" } +tendermint-testgen = { git = "https://github.com/informalsystems/tendermint-rs", branch = "release/v0.23.2" } + # [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 = { 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" } diff --git a/modules/Cargo.toml b/modules/Cargo.toml index a22a156c92..58121c942d 100644 --- a/modules/Cargo.toml +++ b/modules/Cargo.toml @@ -27,7 +27,7 @@ mocks = ["tendermint-testgen"] # Proto definitions for all IBC-related interfaces, e.g., connections or channels. ibc-proto = { version = "0.13.0", path = "../proto" } ics23 = { version = "0.6.7", default-features = false } -chrono = { version = "0.4.19", default-features = false } +time = { version = "0.3", default-features = false } thiserror = { version = "1.0.30", default-features = false } serde_derive = { version = "1.0.104", default-features = false } serde = { version = "1.0", default-features = false } diff --git a/modules/src/applications/ics20_fungible_token_transfer/msgs/transfer.rs b/modules/src/applications/ics20_fungible_token_transfer/msgs/transfer.rs index 2522376f95..88be8fb54b 100644 --- a/modules/src/applications/ics20_fungible_token_transfer/msgs/transfer.rs +++ b/modules/src/applications/ics20_fungible_token_transfer/msgs/transfer.rs @@ -92,7 +92,7 @@ impl From for RawMsgTransfer { sender: domain_msg.sender.to_string(), receiver: domain_msg.receiver.to_string(), timeout_height: Some(domain_msg.timeout_height.into()), - timeout_timestamp: domain_msg.timeout_timestamp.as_nanoseconds(), + timeout_timestamp: domain_msg.timeout_timestamp.nanoseconds(), } } } diff --git a/modules/src/clients/ics07_tendermint/client_def.rs b/modules/src/clients/ics07_tendermint/client_def.rs index 351ffffa2a..f9b2199514 100644 --- a/modules/src/clients/ics07_tendermint/client_def.rs +++ b/modules/src/clients/ics07_tendermint/client_def.rs @@ -1,9 +1,9 @@ use std::convert::TryInto; use ibc_proto::ibc::core::commitment::v1::MerkleProof; -use tendermint::Time; use tendermint_light_client::components::verifier::{ProdVerifier, Verdict, Verifier}; use tendermint_light_client::types::{TrustedBlockState, UntrustedBlockState}; +use time::OffsetDateTime; use crate::clients::ics07_tendermint::client_state::ClientState; use crate::clients::ics07_tendermint::consensus_state::ConsensusState; @@ -107,7 +107,7 @@ impl ClientDef for TendermintClient { untrusted_state, trusted_state, &options, - Time(chrono::Utc::now()), + OffsetDateTime::now_utc().try_into().unwrap(), ); match verdict { diff --git a/modules/src/clients/ics07_tendermint/consensus_state.rs b/modules/src/clients/ics07_tendermint/consensus_state.rs index d439264bc0..141df337a6 100644 --- a/modules/src/clients/ics07_tendermint/consensus_state.rs +++ b/modules/src/clients/ics07_tendermint/consensus_state.rs @@ -2,9 +2,9 @@ use crate::prelude::*; use core::convert::Infallible; -use chrono::{TimeZone, Utc}; use serde::Serialize; use tendermint::{hash::Algorithm, time::Time, Hash}; +use tendermint_proto::google::protobuf as tpb; use tendermint_proto::Protobuf; use ibc_proto::ibc::lightclients::tendermint::v1::ConsensusState as RawConsensusState; @@ -58,9 +58,15 @@ impl TryFrom for ConsensusState { type Error = Error; fn try_from(raw: RawConsensusState) -> Result { - let proto_timestamp = raw + let prost_types::Timestamp { seconds, nanos } = raw .timestamp .ok_or_else(|| Error::invalid_raw_consensus_state("missing timestamp".into()))?; + // FIXME: shunts like this are necessary due to + // https://github.com/informalsystems/tendermint-rs/issues/1053 + let proto_timestamp = tpb::Timestamp { seconds, nanos }; + let timestamp = proto_timestamp + .try_into() + .map_err(|e| Error::invalid_raw_consensus_state(format!("invalid timestamp: {}", e)))?; Ok(Self { root: raw @@ -70,9 +76,7 @@ impl TryFrom for ConsensusState { })? .hash .into(), - timestamp: Utc - .timestamp(proto_timestamp.seconds, proto_timestamp.nanos as u32) - .into(), + timestamp, next_validators_hash: Hash::from_bytes(Algorithm::Sha256, &raw.next_validators_hash) .map_err(|e| Error::invalid_raw_consensus_state(e.to_string()))?, }) @@ -81,10 +85,10 @@ impl TryFrom for ConsensusState { impl From for RawConsensusState { fn from(value: ConsensusState) -> Self { - let timestamp = prost_types::Timestamp { - seconds: value.timestamp.0.timestamp(), - nanos: value.timestamp.0.timestamp_subsec_nanos() as i32, - }; + // FIXME: shunts like this are necessary due to + // https://github.com/informalsystems/tendermint-rs/issues/1053 + let tpb::Timestamp { seconds, nanos } = value.timestamp.into(); + let timestamp = prost_types::Timestamp { seconds, nanos }; RawConsensusState { timestamp: Some(timestamp), diff --git a/modules/src/clients/ics07_tendermint/header.rs b/modules/src/clients/ics07_tendermint/header.rs index a45734022d..8fe32105a5 100644 --- a/modules/src/clients/ics07_tendermint/header.rs +++ b/modules/src/clients/ics07_tendermint/header.rs @@ -1,7 +1,6 @@ use core::cmp::Ordering; use bytes::Buf; -use chrono::DateTime; use prost::Message; use serde_derive::{Deserialize, Serialize}; use tendermint::block::signed_header::SignedHeader; @@ -78,7 +77,7 @@ impl crate::core::ics02_client::header::Header for Header { } fn timestamp(&self) -> Timestamp { - Timestamp::from_datetime(DateTime::from(self.signed_header.header.time)) + self.signed_header.header.time.into() } fn wrap_any(self) -> AnyHeader { diff --git a/modules/src/core/ics02_client/client_consensus.rs b/modules/src/core/ics02_client/client_consensus.rs index 54c7192db6..de1e54fb80 100644 --- a/modules/src/core/ics02_client/client_consensus.rs +++ b/modules/src/core/ics02_client/client_consensus.rs @@ -3,8 +3,6 @@ use crate::prelude::*; use core::convert::Infallible; use core::marker::{Send, Sync}; -use chrono::{DateTime, Utc}; - use ibc_proto::ibc::core::client::v1::ConsensusStateWithHeight; use prost_types::Any; use serde::Serialize; @@ -55,10 +53,7 @@ pub enum AnyConsensusState { impl AnyConsensusState { pub fn timestamp(&self) -> Timestamp { match self { - Self::Tendermint(cs_state) => { - let date: DateTime = cs_state.timestamp.into(); - Timestamp::from_datetime(date) - } + Self::Tendermint(cs_state) => cs_state.timestamp.into(), #[cfg(any(test, feature = "mocks"))] Self::Mock(mock_state) => mock_state.timestamp(), diff --git a/modules/src/core/ics04_channel/events.rs b/modules/src/core/ics04_channel/events.rs index 972794c8a8..11efb275b6 100644 --- a/modules/src/core/ics04_channel/events.rs +++ b/modules/src/core/ics04_channel/events.rs @@ -294,7 +294,7 @@ impl TryFrom for Vec { key: PKT_TIMEOUT_TIMESTAMP_ATTRIBUTE_KEY.parse().unwrap(), value: p .timeout_timestamp - .as_nanoseconds() + .nanoseconds() .to_string() .parse() .unwrap(), @@ -960,7 +960,7 @@ mod tests { destination_channel: "b_test_channel".parse().unwrap(), data: "test_data".as_bytes().to_vec(), timeout_height: Height::new(1, 10), - timeout_timestamp: Timestamp::from_datetime(chrono::offset::Utc::now()), + timeout_timestamp: Timestamp::now(), }; let mut abci_events = vec![]; let send_packet = SendPacket { diff --git a/modules/src/core/ics04_channel/handler/send_packet.rs b/modules/src/core/ics04_channel/handler/send_packet.rs index dde7d60ede..1131fa6c8b 100644 --- a/modules/src/core/ics04_channel/handler/send_packet.rs +++ b/modules/src/core/ics04_channel/handler/send_packet.rs @@ -145,7 +145,7 @@ mod tests { let timestamp = Timestamp::now().add(Duration::from_secs(10)); //CD:TODO remove unwrap - let mut packet: Packet = get_dummy_raw_packet(1, timestamp.unwrap().as_nanoseconds()) + let mut packet: Packet = get_dummy_raw_packet(1, timestamp.unwrap().nanoseconds()) .try_into() .unwrap(); packet.sequence = 1.into(); diff --git a/modules/src/core/ics04_channel/packet.rs b/modules/src/core/ics04_channel/packet.rs index 12ec013549..6b4cdd1093 100644 --- a/modules/src/core/ics04_channel/packet.rs +++ b/modules/src/core/ics04_channel/packet.rs @@ -238,7 +238,7 @@ impl From for RawPacket { destination_channel: packet.destination_channel.to_string(), data: packet.data, timeout_height: Some(packet.timeout_height.into()), - timeout_timestamp: packet.timeout_timestamp.as_nanoseconds(), + timeout_timestamp: packet.timeout_timestamp.nanoseconds(), } } } diff --git a/modules/src/mock/client_state.rs b/modules/src/mock/client_state.rs index a218255942..d0779a0b77 100644 --- a/modules/src/mock/client_state.rs +++ b/modules/src/mock/client_state.rs @@ -85,7 +85,7 @@ impl From for RawMockClientState { RawMockClientState { header: Some(ibc_proto::ibc::mock::Header { height: Some(value.header.height().into()), - timestamp: value.header.timestamp.as_nanoseconds(), + timestamp: value.header.timestamp.nanoseconds(), }), } } @@ -158,7 +158,7 @@ impl From for RawMockConsensusState { RawMockConsensusState { header: Some(ibc_proto::ibc::mock::Header { height: Some(value.header.height().into()), - timestamp: value.header.timestamp.as_nanoseconds(), + timestamp: value.header.timestamp.nanoseconds(), }), } } diff --git a/modules/src/mock/header.rs b/modules/src/mock/header.rs index 1678a62407..381975ae48 100644 --- a/modules/src/mock/header.rs +++ b/modules/src/mock/header.rs @@ -37,7 +37,7 @@ impl From for RawMockHeader { fn from(value: MockHeader) -> Self { RawMockHeader { height: Some(value.height.into()), - timestamp: value.timestamp.as_nanoseconds(), + timestamp: value.timestamp.nanoseconds(), } } } diff --git a/modules/src/mock/host.rs b/modules/src/mock/host.rs index ec65ad7171..71cdd6d39b 100644 --- a/modules/src/mock/host.rs +++ b/modules/src/mock/host.rs @@ -3,6 +3,7 @@ use tendermint::time::Time; use tendermint_testgen::light_block::TmLightBlock; use tendermint_testgen::{Generator, LightBlock as TestgenLightBlock}; +use time::OffsetDateTime; use crate::clients::ics07_tendermint::consensus_state::ConsensusState as TMConsensusState; use crate::clients::ics07_tendermint::header::Header as TMHeader; @@ -63,10 +64,8 @@ impl HostBlock { // same timestamp as two block can be generated per second. let ten_millis = core::time::Duration::from_millis(1000); std::thread::sleep(ten_millis); - let time = Time(chrono::Utc::now()) - .duration_since(Time::unix_epoch()) - .unwrap() - .as_secs(); + let time: Time = OffsetDateTime::now_utc().try_into().unwrap(); + let time = time.duration_since(Time::unix_epoch()).unwrap().as_secs(); TestgenLightBlock::new_default_with_time_and_chain_id(chain_id.to_string(), time, height) .generate() diff --git a/modules/src/timestamp.rs b/modules/src/timestamp.rs index 500ea37377..267e7bf824 100644 --- a/modules/src/timestamp.rs +++ b/modules/src/timestamp.rs @@ -1,28 +1,40 @@ use crate::prelude::*; use core::fmt::Display; +use core::hash::{Hash, Hasher}; use core::num::ParseIntError; use core::ops::{Add, Sub}; use core::str::FromStr; use core::time::Duration; -use chrono::{offset::Utc, DateTime, TimeZone}; use flex_error::{define_error, TraceError}; use serde_derive::{Deserialize, Serialize}; use tendermint::Time; +use time::OffsetDateTime; pub const ZERO_DURATION: Duration = Duration::from_secs(0); -/// A newtype wrapper over `Option>` to keep track of +const NANOS_PER_SEC: u64 = 1_000_000_000; + +/// A newtype wrapper over `Option