From e97350891168984a7b7b079922424b8c980092a0 Mon Sep 17 00:00:00 2001 From: teor Date: Mon, 29 Aug 2022 03:08:27 +1000 Subject: [PATCH] build(deps): bump chrono from 0.4.19 to 0.4.20 (#4898) * Bump chrono to 0.4.20 * Fix clippy::assign_op_pattern * Update deprecated constant names * Drop old `time` crate dependency from `chrono` Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- Cargo.lock | 7 +- zebra-chain/Cargo.toml | 4 +- .../network_chain_tip_height_estimator.rs | 2 +- zebra-chain/src/serialization/arbitrary.rs | 4 +- zebra-consensus/Cargo.toml | 2 +- zebra-consensus/src/transaction/tests.rs | 77 +++++++++---------- zebra-consensus/src/transaction/tests/prop.rs | 7 +- zebra-network/Cargo.toml | 2 +- zebra-network/src/protocol/external/codec.rs | 18 +++-- zebra-rpc/Cargo.toml | 12 +-- zebra-state/Cargo.toml | 2 +- zebrad/Cargo.toml | 2 +- 12 files changed, 71 insertions(+), 68 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c1943aea..ff6668db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -740,15 +740,16 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.19" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +checksum = "6127248204b9aba09a362f6c930ef6a78f2c1b2215f8a7b398c06e1083f17af0" dependencies = [ - "libc", + "js-sys", "num-integer", "num-traits", "serde", "time 0.1.44", + "wasm-bindgen", "winapi", ] diff --git a/zebra-chain/Cargo.toml b/zebra-chain/Cargo.toml index df7aa486..32c29970 100644 --- a/zebra-chain/Cargo.toml +++ b/zebra-chain/Cargo.toml @@ -35,7 +35,7 @@ rand_core = "0.6.3" ripemd = "0.1.1" # Matches version used by hdwallet secp256k1 = { version = "0.21.3", features = ["serde"] } -sha2 = { version = "0.9.9", features=["compress"] } +sha2 = { version = "0.9.9", features = ["compress"] } subtle = "2.4.1" uint = "0.9.1" x25519-dalek = { version = "1.2.0", features = ["serde"] } @@ -49,7 +49,7 @@ zcash_note_encryption = "0.1" zcash_primitives = { version = "0.7.0", features = ["transparent-inputs"] } # Time -chrono = { version = "0.4.19", features = ["serde"] } +chrono = { version = "0.4.20", default-features = false, features = ["clock", "std", "serde"] } humantime = "2.1.0" # Error Handling & Formatting diff --git a/zebra-chain/src/chain_tip/network_chain_tip_height_estimator.rs b/zebra-chain/src/chain_tip/network_chain_tip_height_estimator.rs index 3a310524..5d4e1f59 100644 --- a/zebra-chain/src/chain_tip/network_chain_tip_height_estimator.rs +++ b/zebra-chain/src/chain_tip/network_chain_tip_height_estimator.rs @@ -93,7 +93,7 @@ impl NetworkChainTipHeightEstimator { let target_spacing_seconds = self.current_target_spacing.num_seconds(); let time_to_activation = Duration::seconds(remaining_blocks * target_spacing_seconds); - self.current_block_time = self.current_block_time + time_to_activation; + self.current_block_time += time_to_activation; self.current_height = max_height; } } diff --git a/zebra-chain/src/serialization/arbitrary.rs b/zebra-chain/src/serialization/arbitrary.rs index 953e8643..9c432475 100644 --- a/zebra-chain/src/serialization/arbitrary.rs +++ b/zebra-chain/src/serialization/arbitrary.rs @@ -2,7 +2,7 @@ use std::convert::TryInto; -use chrono::{TimeZone, Utc, MAX_DATETIME, MIN_DATETIME}; +use chrono::{DateTime, TimeZone, Utc}; use proptest::{arbitrary::any, prelude::*}; use super::{ @@ -41,7 +41,7 @@ impl Arbitrary for DateTime32 { pub fn datetime_full() -> impl Strategy> { ( // TODO: should we be subtracting 1 from the maximum timestamp? - MIN_DATETIME.timestamp()..=MAX_DATETIME.timestamp(), + DateTime::::MIN_UTC.timestamp()..=DateTime::::MAX_UTC.timestamp(), 0..2_000_000_000_u32, ) .prop_map(|(secs, nsecs)| Utc.timestamp(secs, nsecs)) diff --git a/zebra-consensus/Cargo.toml b/zebra-consensus/Cargo.toml index a0624f98..c8e55223 100644 --- a/zebra-consensus/Cargo.toml +++ b/zebra-consensus/Cargo.toml @@ -18,7 +18,7 @@ jubjub = "0.9.0" rand = { version = "0.8.5", package = "rand" } rayon = "1.5.3" -chrono = "0.4.19" +chrono = { version = "0.4.20", default-features = false, features = ["clock", "std"] } dirs = "4.0.0" displaydoc = "0.2.3" lazy_static = "1.4.0" diff --git a/zebra-consensus/src/transaction/tests.rs b/zebra-consensus/src/transaction/tests.rs index bae2d326..21f57988 100644 --- a/zebra-consensus/src/transaction/tests.rs +++ b/zebra-consensus/src/transaction/tests.rs @@ -1,11 +1,9 @@ //! Tests for Zcash transaction consensus checks. -use std::{ - collections::HashMap, - convert::{TryFrom, TryInto}, - sync::Arc, -}; +use std::{collections::HashMap, sync::Arc}; +use chrono::{DateTime, Utc}; +use color_eyre::eyre::Report; use halo2::pasta::{group::ff::PrimeField, pallas}; use tower::{service_fn, ServiceExt}; @@ -27,10 +25,9 @@ use zebra_chain::{ transparent::{self, CoinbaseData}, }; -use super::{check, Request, Verifier}; - use crate::error::TransactionError; -use color_eyre::eyre::Report; + +use super::{check, Request, Verifier}; #[cfg(test)] mod prop; @@ -264,7 +261,7 @@ async fn v5_transaction_is_rejected_before_nu5_activation() { height: canopy .activation_height(network) .expect("Canopy activation height is specified"), - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -327,7 +324,7 @@ fn v5_transaction_is_accepted_after_nu5_activation_for_network(network: Network) transaction: Arc::new(transaction), known_utxos: Arc::new(HashMap::new()), height: expiry_height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -377,7 +374,7 @@ async fn v4_transaction_with_transparent_transfer_is_accepted() { transaction: Arc::new(transaction), known_utxos: Arc::new(known_utxos), height: transaction_block_height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -416,7 +413,7 @@ async fn v4_transaction_with_last_valid_expiry_height() { transaction: Arc::new(transaction.clone()), known_utxos: Arc::new(known_utxos), height: block_height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -461,7 +458,7 @@ async fn v4_coinbase_transaction_with_low_expiry_height() { transaction: Arc::new(transaction.clone()), known_utxos: Arc::new(HashMap::new()), height: block_height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -503,7 +500,7 @@ async fn v4_transaction_with_too_low_expiry_height() { transaction: Arc::new(transaction.clone()), known_utxos: Arc::new(known_utxos), height: block_height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -548,7 +545,7 @@ async fn v4_transaction_with_exceeding_expiry_height() { transaction: Arc::new(transaction.clone()), known_utxos: Arc::new(known_utxos), height: block_height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -601,7 +598,7 @@ async fn v4_coinbase_transaction_with_exceeding_expiry_height() { transaction: Arc::new(transaction.clone()), known_utxos: Arc::new(HashMap::new()), height: block_height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -652,7 +649,7 @@ async fn v4_coinbase_transaction_is_accepted() { transaction: Arc::new(transaction), known_utxos: Arc::new(HashMap::new()), height: transaction_block_height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -702,7 +699,7 @@ async fn v4_transaction_with_transparent_transfer_is_rejected_by_the_script() { transaction: Arc::new(transaction), known_utxos: Arc::new(known_utxos), height: transaction_block_height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -752,7 +749,7 @@ async fn v4_transaction_with_conflicting_transparent_spend_is_rejected() { transaction: Arc::new(transaction), known_utxos: Arc::new(known_utxos), height: transaction_block_height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -818,7 +815,7 @@ fn v4_transaction_with_conflicting_sprout_nullifier_inside_joinsplit_is_rejected transaction: Arc::new(transaction), known_utxos: Arc::new(HashMap::new()), height: transaction_block_height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -889,7 +886,7 @@ fn v4_transaction_with_conflicting_sprout_nullifier_across_joinsplits_is_rejecte transaction: Arc::new(transaction), known_utxos: Arc::new(HashMap::new()), height: transaction_block_height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -943,7 +940,7 @@ async fn v5_transaction_with_transparent_transfer_is_accepted() { transaction: Arc::new(transaction), known_utxos: Arc::new(known_utxos), height: transaction_block_height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -983,7 +980,7 @@ async fn v5_transaction_with_last_valid_expiry_height() { transaction: Arc::new(transaction.clone()), known_utxos: Arc::new(known_utxos), height: block_height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -1026,7 +1023,7 @@ async fn v5_coinbase_transaction_expiry_height() { transaction: Arc::new(transaction.clone()), known_utxos: Arc::new(HashMap::new()), height: block_height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -1047,7 +1044,7 @@ async fn v5_coinbase_transaction_expiry_height() { transaction: Arc::new(new_transaction.clone()), known_utxos: Arc::new(HashMap::new()), height: block_height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -1072,7 +1069,7 @@ async fn v5_coinbase_transaction_expiry_height() { transaction: Arc::new(new_transaction.clone()), known_utxos: Arc::new(HashMap::new()), height: block_height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -1099,7 +1096,7 @@ async fn v5_coinbase_transaction_expiry_height() { transaction: Arc::new(new_transaction.clone()), known_utxos: Arc::new(HashMap::new()), height: new_expiry_height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -1141,7 +1138,7 @@ async fn v5_transaction_with_too_low_expiry_height() { transaction: Arc::new(transaction.clone()), known_utxos: Arc::new(known_utxos), height: block_height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -1187,7 +1184,7 @@ async fn v5_transaction_with_exceeding_expiry_height() { transaction: Arc::new(transaction.clone()), known_utxos: Arc::new(known_utxos), height: block_height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -1241,7 +1238,7 @@ async fn v5_coinbase_transaction_is_accepted() { transaction: Arc::new(transaction), known_utxos: Arc::new(known_utxos), height: transaction_block_height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -1293,7 +1290,7 @@ async fn v5_transaction_with_transparent_transfer_is_rejected_by_the_script() { transaction: Arc::new(transaction), known_utxos: Arc::new(known_utxos), height: transaction_block_height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -1345,7 +1342,7 @@ async fn v5_transaction_with_conflicting_transparent_spend_is_rejected() { transaction: Arc::new(transaction), known_utxos: Arc::new(known_utxos), height: transaction_block_height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -1390,7 +1387,7 @@ fn v4_with_signed_sprout_transfer_is_accepted() { transaction, known_utxos: Arc::new(HashMap::new()), height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -1463,7 +1460,7 @@ async fn v4_with_joinsplit_is_rejected_for_modification( transaction, known_utxos: Arc::new(HashMap::new()), height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -1499,7 +1496,7 @@ fn v4_with_sapling_spends() { transaction, known_utxos: Arc::new(HashMap::new()), height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -1542,7 +1539,7 @@ fn v4_with_duplicate_sapling_spends() { transaction, known_utxos: Arc::new(HashMap::new()), height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -1587,7 +1584,7 @@ fn v4_with_sapling_outputs_and_no_spends() { transaction, known_utxos: Arc::new(HashMap::new()), height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -1636,7 +1633,7 @@ fn v5_with_sapling_spends() { transaction: Arc::new(transaction), known_utxos: Arc::new(HashMap::new()), height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -1680,7 +1677,7 @@ fn v5_with_duplicate_sapling_spends() { transaction: Arc::new(transaction), known_utxos: Arc::new(HashMap::new()), height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; @@ -1743,7 +1740,7 @@ fn v5_with_duplicate_orchard_action() { transaction: Arc::new(transaction), known_utxos: Arc::new(HashMap::new()), height, - time: chrono::MAX_DATETIME, + time: DateTime::::MAX_UTC, }) .await; diff --git a/zebra-consensus/src/transaction/tests/prop.rs b/zebra-consensus/src/transaction/tests/prop.rs index e243dd4f..aaddb364 100644 --- a/zebra-consensus/src/transaction/tests/prop.rs +++ b/zebra-consensus/src/transaction/tests/prop.rs @@ -1,6 +1,6 @@ //! Randomised property tests for transaction verification. -use std::{collections::HashMap, convert::TryInto, sync::Arc}; +use std::{collections::HashMap, sync::Arc}; use chrono::{DateTime, Duration, Utc}; use proptest::{collection::vec, prelude::*}; @@ -14,9 +14,10 @@ use zebra_chain::{ transparent, }; -use super::mock_transparent_transfer; use crate::{error::TransactionError, transaction}; +use super::mock_transparent_transfer; + /// The maximum number of transparent inputs to include in a mock transaction. const MAX_TRANSPARENT_INPUTS: usize = 10; @@ -204,7 +205,7 @@ proptest! { (first_datetime, second_datetime) } else if first_datetime > second_datetime { (second_datetime, first_datetime) - } else if first_datetime == chrono::MAX_DATETIME { + } else if first_datetime == DateTime::::MAX_UTC { (first_datetime - Duration::nanoseconds(1), first_datetime) } else { (first_datetime, first_datetime + Duration::nanoseconds(1)) diff --git a/zebra-network/Cargo.toml b/zebra-network/Cargo.toml index e40e8015..f9c7930e 100644 --- a/zebra-network/Cargo.toml +++ b/zebra-network/Cargo.toml @@ -16,7 +16,7 @@ proptest-impl = ["proptest", "proptest-derive", "zebra-chain/proptest-impl"] bitflags = "1.3.2" byteorder = "1.4.3" bytes = "1.2.1" -chrono = "0.4.19" +chrono = { version = "0.4.20", 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/protocol/external/codec.rs b/zebra-network/src/protocol/external/codec.rs index f007b73c..1c6de9b8 100644 --- a/zebra-network/src/protocol/external/codec.rs +++ b/zebra-network/src/protocol/external/codec.rs @@ -2,7 +2,6 @@ use std::{ cmp::min, - convert::TryInto, fmt, io::{Cursor, Read, Write}, }; @@ -724,15 +723,18 @@ impl Codec { } } -// XXX replace these interior unit tests with exterior integration tests + proptest +// TODO: +// - move these unit tests to a separate file +// - add exterior integration tests + proptest #[cfg(test)] mod tests { - use super::*; + use std::net::{IpAddr, Ipv4Addr, SocketAddr}; - use chrono::{MAX_DATETIME, MIN_DATETIME}; + use chrono::DateTime; use futures::prelude::*; use lazy_static::lazy_static; - use std::net::{IpAddr, Ipv4Addr, SocketAddr}; + + use super::*; lazy_static! { static ref VERSION_TEST_VECTOR: Message = { @@ -808,8 +810,10 @@ mod tests { deserialize_version_with_time(1620777600).expect("recent time is valid"); deserialize_version_with_time(0).expect("zero time is valid"); - deserialize_version_with_time(MIN_DATETIME.timestamp()).expect("min time is valid"); - deserialize_version_with_time(MAX_DATETIME.timestamp()).expect("max time is valid"); + deserialize_version_with_time(DateTime::::MIN_UTC.timestamp()) + .expect("min time is valid"); + deserialize_version_with_time(DateTime::::MAX_UTC.timestamp()) + .expect("max time is valid"); } /// Deserialize a `Version` message containing `time`, and return the result. diff --git a/zebra-rpc/Cargo.toml b/zebra-rpc/Cargo.toml index d14f2c61..6bd3b1ff 100644 --- a/zebra-rpc/Cargo.toml +++ b/zebra-rpc/Cargo.toml @@ -12,12 +12,7 @@ default = [] proptest-impl = ["proptest", "proptest-derive", "zebra-chain/proptest-impl", "zebra-state/proptest-impl"] [dependencies] -zebra-chain = { path = "../zebra-chain" } -zebra-network = { path = "../zebra-network" } -zebra-node-services = { path = "../zebra-node-services" } -zebra-state = { path = "../zebra-state" } - -chrono = "0.4.19" +chrono = { version = "0.4.20", default-features = false, features = ["clock", "std"] } futures = "0.3.21" # lightwalletd sends JSON-RPC requests over HTTP 1.1 @@ -42,6 +37,11 @@ serde = { version = "1.0.142", features = ["serde_derive"] } proptest = { version = "0.10.1", optional = true } proptest-derive = { version = "0.3.0", optional = true } +zebra-chain = { path = "../zebra-chain" } +zebra-network = { path = "../zebra-network" } +zebra-node-services = { path = "../zebra-node-services" } +zebra-state = { path = "../zebra-state" } + [dev-dependencies] insta = { version = "1.17.1", features = ["redactions"] } proptest = "0.10.1" diff --git a/zebra-state/Cargo.toml b/zebra-state/Cargo.toml index 69345ddc..82df95df 100644 --- a/zebra-state/Cargo.toml +++ b/zebra-state/Cargo.toml @@ -10,7 +10,7 @@ proptest-impl = ["proptest", "proptest-derive", "zebra-test", "zebra-chain/propt [dependencies] bincode = "1.3.3" -chrono = "0.4.19" +chrono = { version = "0.4.20", default-features = false, features = ["clock", "std"] } dirs = "4.0.0" displaydoc = "0.2.3" futures = "0.3.21" diff --git a/zebrad/Cargo.toml b/zebrad/Cargo.toml index 6c979d45..ba068e38 100644 --- a/zebrad/Cargo.toml +++ b/zebrad/Cargo.toml @@ -77,7 +77,7 @@ zebra-state = { path = "../zebra-state" } abscissa_core = "0.5" gumdrop = "0.7" -chrono = "0.4.19" +chrono = { version = "0.4.20", default-features = false, features = ["clock", "std"] } humantime = "2.1.0" humantime-serde = "1.1.1" indexmap = "1.9.1"