From 2680e3c6b262d868a042541162005bf40627baa8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 16 Nov 2022 16:47:45 +0000 Subject: [PATCH] build(deps): bump chrono from 0.4.22 to 0.4.23 (#5629) * build(deps): bump chrono from 0.4.22 to 0.4.23 Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.22 to 0.4.23. - [Release notes](https://github.com/chronotope/chrono/releases) - [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md) - [Commits](https://github.com/chronotope/chrono/compare/v0.4.22...v0.4.23) --- updated-dependencies: - dependency-name: chrono dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * uses Utx::timestamp_opt instead of timestamp Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: arya2 Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- zebra-chain/Cargo.toml | 2 +- zebra-chain/src/block/serialize.rs | 7 ++++++- zebra-chain/src/block/tests/generate.rs | 3 ++- zebra-chain/src/serialization/arbitrary.rs | 6 +++++- zebra-chain/src/serialization/date_time.rs | 4 +++- zebra-chain/src/transaction/arbitrary.rs | 9 +++++++-- zebra-chain/src/transaction/lock_time.rs | 18 +++++++++++++++--- zebra-chain/src/transaction/tests/vectors.rs | 3 ++- zebra-consensus/Cargo.toml | 2 +- zebra-network/Cargo.toml | 2 +- zebra-network/src/peer/handshake.rs | 5 ++++- zebra-network/src/protocol/external/codec.rs | 5 ++++- zebra-rpc/Cargo.toml | 2 +- zebra-state/Cargo.toml | 2 +- zebrad/Cargo.toml | 2 +- 16 files changed, 56 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 537c7df3cda..e68d68b8472 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -608,9 +608,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.22" +version = "0.4.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1" +checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" dependencies = [ "iana-time-zone", "js-sys", diff --git a/zebra-chain/Cargo.toml b/zebra-chain/Cargo.toml index 34ce8e59ca2..0102e7a0808 100644 --- a/zebra-chain/Cargo.toml +++ b/zebra-chain/Cargo.toml @@ -64,7 +64,7 @@ zcash_note_encryption = "0.2.0" zcash_primitives = { version = "0.8.1", features = ["transparent-inputs"] } # Time -chrono = { version = "0.4.22", default-features = false, features = ["clock", "std", "serde"] } +chrono = { version = "0.4.23", default-features = false, features = ["clock", "std", "serde"] } humantime = "2.1.0" # Error Handling & Formatting diff --git a/zebra-chain/src/block/serialize.rs b/zebra-chain/src/block/serialize.rs index ad9558000e0..a5742a80faa 100644 --- a/zebra-chain/src/block/serialize.rs +++ b/zebra-chain/src/block/serialize.rs @@ -87,7 +87,12 @@ impl ZcashDeserialize for Header { merkle_root: merkle::Root(reader.read_32_bytes()?), commitment_bytes: reader.read_32_bytes()?, // This can't panic, because all u32 values are valid `Utc.timestamp`s - time: Utc.timestamp(reader.read_u32::()?.into(), 0), + time: Utc + .timestamp_opt(reader.read_u32::()?.into(), 0) + .single() + .ok_or(SerializationError::Parse( + "out-of-range number of seconds and/or invalid nanosecond", + ))?, difficulty_threshold: CompactDifficulty(reader.read_u32::()?), nonce: reader.read_32_bytes()?, solution: equihash::Solution::zcash_deserialize(reader)?, diff --git a/zebra-chain/src/block/tests/generate.rs b/zebra-chain/src/block/tests/generate.rs index 4e10299b6b2..afaf733c0ae 100644 --- a/zebra-chain/src/block/tests/generate.rs +++ b/zebra-chain/src/block/tests/generate.rs @@ -45,7 +45,8 @@ pub fn transaction() -> (Transaction, Vec) { /// Returns a generated transparent lock time, and its canonical serialized bytes. pub fn lock_time() -> (LockTime, Vec) { let lock_time = LockTime::Time(DateTime::::from_utc( - NaiveDateTime::from_timestamp(61, 0), + NaiveDateTime::from_timestamp_opt(61, 0) + .expect("in-range number of seconds and valid nanosecond"), Utc, )); let lock_time_bytes = lock_time.zcash_serialize_to_vec().unwrap(); diff --git a/zebra-chain/src/serialization/arbitrary.rs b/zebra-chain/src/serialization/arbitrary.rs index 9c432475891..0eaba2729a5 100644 --- a/zebra-chain/src/serialization/arbitrary.rs +++ b/zebra-chain/src/serialization/arbitrary.rs @@ -44,7 +44,11 @@ pub fn datetime_full() -> impl Strategy> { DateTime::::MIN_UTC.timestamp()..=DateTime::::MAX_UTC.timestamp(), 0..2_000_000_000_u32, ) - .prop_map(|(secs, nsecs)| Utc.timestamp(secs, nsecs)) + .prop_map(|(secs, nsecs)| { + Utc.timestamp_opt(secs, nsecs) + .single() + .expect("in-range number of seconds and valid nanosecond") + }) } /// Returns a strategy that produces an arbitrary time from a [`u32`] number diff --git a/zebra-chain/src/serialization/date_time.rs b/zebra-chain/src/serialization/date_time.rs index bd5a3867e87..cdb86f638c7 100644 --- a/zebra-chain/src/serialization/date_time.rs +++ b/zebra-chain/src/serialization/date_time.rs @@ -228,7 +228,9 @@ impl From<&u32> for DateTime32 { impl From for chrono::DateTime { fn from(value: DateTime32) -> Self { // chrono::DateTime is guaranteed to hold 32-bit values - Utc.timestamp(value.timestamp.into(), 0) + Utc.timestamp_opt(value.timestamp.into(), 0) + .single() + .expect("in-range number of seconds and valid nanosecond") } } diff --git a/zebra-chain/src/transaction/arbitrary.rs b/zebra-chain/src/transaction/arbitrary.rs index 8098b51eaed..d3077a1547e 100644 --- a/zebra-chain/src/transaction/arbitrary.rs +++ b/zebra-chain/src/transaction/arbitrary.rs @@ -534,8 +534,13 @@ impl Arbitrary for LockTime { prop_oneof![ (block::Height::MIN.0..=LockTime::MAX_HEIGHT.0) .prop_map(|n| LockTime::Height(block::Height(n))), - (LockTime::MIN_TIMESTAMP..=LockTime::MAX_TIMESTAMP) - .prop_map(|n| { LockTime::Time(Utc.timestamp(n, 0)) }) + (LockTime::MIN_TIMESTAMP..=LockTime::MAX_TIMESTAMP).prop_map(|n| { + LockTime::Time( + Utc.timestamp_opt(n, 0) + .single() + .expect("in-range number of seconds and valid nanosecond"), + ) + }) ] .boxed() } diff --git a/zebra-chain/src/transaction/lock_time.rs b/zebra-chain/src/transaction/lock_time.rs index 32b48875f39..95e8eaf0284 100644 --- a/zebra-chain/src/transaction/lock_time.rs +++ b/zebra-chain/src/transaction/lock_time.rs @@ -71,7 +71,11 @@ impl LockTime { // // TODO: replace Utc.timestamp with DateTime32 (#2211) pub fn min_lock_time_timestamp() -> LockTime { - LockTime::Time(Utc.timestamp(Self::MIN_TIMESTAMP, 0)) + LockTime::Time( + Utc.timestamp_opt(Self::MIN_TIMESTAMP, 0) + .single() + .expect("in-range number of seconds and valid nanosecond"), + ) } /// Returns the maximum [`LockTime::Time`], as a [`LockTime`]. @@ -81,7 +85,11 @@ impl LockTime { // // TODO: replace Utc.timestamp with DateTime32 (#2211) pub fn max_lock_time_timestamp() -> LockTime { - LockTime::Time(Utc.timestamp(Self::MAX_TIMESTAMP, 0)) + LockTime::Time( + Utc.timestamp_opt(Self::MAX_TIMESTAMP, 0) + .single() + .expect("in-range number of seconds and valid nanosecond"), + ) } } @@ -108,7 +116,11 @@ impl ZcashDeserialize for LockTime { Ok(LockTime::Height(block::Height(n))) } else { // This can't panic, because all u32 values are valid `Utc.timestamp`s. - Ok(LockTime::Time(Utc.timestamp(n.into(), 0))) + Ok(LockTime::Time( + Utc.timestamp_opt(n.into(), 0) + .single() + .expect("in-range number of seconds and valid nanosecond"), + )) } } } diff --git a/zebra-chain/src/transaction/tests/vectors.rs b/zebra-chain/src/transaction/tests/vectors.rs index cf8426bc904..e7e897978d6 100644 --- a/zebra-chain/src/transaction/tests/vectors.rs +++ b/zebra-chain/src/transaction/tests/vectors.rs @@ -223,7 +223,8 @@ fn deserialize_large_transaction() { // Create a lock time. let lock_time = LockTime::Time(DateTime::::from_utc( - NaiveDateTime::from_timestamp(61, 0), + NaiveDateTime::from_timestamp_opt(61, 0) + .expect("in-range number of seconds and valid nanosecond"), Utc, )); diff --git a/zebra-consensus/Cargo.toml b/zebra-consensus/Cargo.toml index 94055e09cb1..f82f067be4e 100644 --- a/zebra-consensus/Cargo.toml +++ b/zebra-consensus/Cargo.toml @@ -19,7 +19,7 @@ jubjub = "0.9.0" rand = { version = "0.8.5", package = "rand" } rayon = "1.5.3" -chrono = { version = "0.4.22", default-features = false, features = ["clock", "std"] } +chrono = { version = "0.4.23", default-features = false, features = ["clock", "std"] } dirs = "4.0.0" displaydoc = "0.2.3" lazy_static = "1.4.0" diff --git a/zebra-network/Cargo.toml b/zebra-network/Cargo.toml index 7521df83e57..095bfb2e286 100644 --- a/zebra-network/Cargo.toml +++ b/zebra-network/Cargo.toml @@ -17,7 +17,7 @@ proptest-impl = ["proptest", "proptest-derive", "zebra-chain/proptest-impl"] bitflags = "1.3.2" byteorder = "1.4.3" bytes = "1.2.1" -chrono = { version = "0.4.22", default-features = false, features = ["clock", "std"] } +chrono = { version = "0.4.23", default-features = false, features = ["clock", "std"] } hex = "0.4.3" humantime-serde = "1.1.1" indexmap = { version = "1.9.1", features = ["serde"] } diff --git a/zebra-network/src/peer/handshake.rs b/zebra-network/src/peer/handshake.rs index 92972574654..2c8dbd3696d 100644 --- a/zebra-network/src/peer/handshake.rs +++ b/zebra-network/src/peer/handshake.rs @@ -608,7 +608,10 @@ where // To try to stay within the range where zcashd will ignore our clock skew, // truncate the timestamp to the nearest 5 minutes. let now = Utc::now().timestamp(); - let timestamp = Utc.timestamp(now - now.rem_euclid(5 * 60), 0); + let timestamp = Utc + .timestamp_opt(now - now.rem_euclid(5 * 60), 0) + .single() + .expect("in-range number of seconds and valid nanosecond"); let (their_addr, our_services, our_listen_addr) = match connected_addr { // Version messages require an address, so we use diff --git a/zebra-network/src/protocol/external/codec.rs b/zebra-network/src/protocol/external/codec.rs index a2bc6552dc3..f741a6267b8 100644 --- a/zebra-network/src/protocol/external/codec.rs +++ b/zebra-network/src/protocol/external/codec.rs @@ -738,7 +738,10 @@ mod tests { lazy_static! { static ref VERSION_TEST_VECTOR: Message = { let services = PeerServices::NODE_NETWORK; - let timestamp = Utc.timestamp(1_568_000_000, 0); + let timestamp = Utc + .timestamp_opt(1_568_000_000, 0) + .single() + .expect("in-range number of seconds and valid nanosecond"); VersionMessage { version: crate::constants::CURRENT_NETWORK_PROTOCOL_VERSION, diff --git a/zebra-rpc/Cargo.toml b/zebra-rpc/Cargo.toml index 233003af688..57ade6bacc7 100644 --- a/zebra-rpc/Cargo.toml +++ b/zebra-rpc/Cargo.toml @@ -30,7 +30,7 @@ proptest-impl = [ ] [dependencies] -chrono = { version = "0.4.22", default-features = false, features = ["clock", "std"] } +chrono = { version = "0.4.23", default-features = false, features = ["clock", "std"] } futures = "0.3.25" # lightwalletd sends JSON-RPC requests over HTTP 1.1 diff --git a/zebra-state/Cargo.toml b/zebra-state/Cargo.toml index 49b946b31fc..1a1bd6bc602 100644 --- a/zebra-state/Cargo.toml +++ b/zebra-state/Cargo.toml @@ -24,7 +24,7 @@ proptest-impl = [ [dependencies] bincode = "1.3.3" -chrono = { version = "0.4.22", default-features = false, features = ["clock", "std"] } +chrono = { version = "0.4.23", default-features = false, features = ["clock", "std"] } dirs = "4.0.0" displaydoc = "0.2.3" futures = "0.3.25" diff --git a/zebrad/Cargo.toml b/zebrad/Cargo.toml index 14638e65c92..dfc2014e047 100644 --- a/zebrad/Cargo.toml +++ b/zebrad/Cargo.toml @@ -93,7 +93,7 @@ zebra-state = { path = "../zebra-state" } abscissa_core = "0.5" gumdrop = { version = "0.7", features = ["default_expr"]} -chrono = { version = "0.4.22", default-features = false, features = ["clock", "std"] } +chrono = { version = "0.4.23", default-features = false, features = ["clock", "std"] } humantime = "2.1.0" humantime-serde = "1.1.1" indexmap = "1.9.1"