Skip to content

Commit

Permalink
build(deps): bump chrono from 0.4.22 to 0.4.23 (#5629)
Browse files Browse the repository at this point in the history
* 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](chronotope/chrono@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] <[email protected]>

* uses Utx::timestamp_opt instead of timestamp

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: arya2 <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 16, 2022
1 parent 844ebf0 commit 2680e3c
Show file tree
Hide file tree
Showing 16 changed files with 56 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion zebra-chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion zebra-chain/src/block/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<LittleEndian>()?.into(), 0),
time: Utc
.timestamp_opt(reader.read_u32::<LittleEndian>()?.into(), 0)
.single()
.ok_or(SerializationError::Parse(
"out-of-range number of seconds and/or invalid nanosecond",
))?,
difficulty_threshold: CompactDifficulty(reader.read_u32::<LittleEndian>()?),
nonce: reader.read_32_bytes()?,
solution: equihash::Solution::zcash_deserialize(reader)?,
Expand Down
3 changes: 2 additions & 1 deletion zebra-chain/src/block/tests/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ pub fn transaction() -> (Transaction, Vec<u8>) {
/// Returns a generated transparent lock time, and its canonical serialized bytes.
pub fn lock_time() -> (LockTime, Vec<u8>) {
let lock_time = LockTime::Time(DateTime::<Utc>::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();
Expand Down
6 changes: 5 additions & 1 deletion zebra-chain/src/serialization/arbitrary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ pub fn datetime_full() -> impl Strategy<Value = chrono::DateTime<Utc>> {
DateTime::<Utc>::MIN_UTC.timestamp()..=DateTime::<Utc>::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
Expand Down
4 changes: 3 additions & 1 deletion zebra-chain/src/serialization/date_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ impl From<&u32> for DateTime32 {
impl From<DateTime32> for chrono::DateTime<Utc> {
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")
}
}

Expand Down
9 changes: 7 additions & 2 deletions zebra-chain/src/transaction/arbitrary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
18 changes: 15 additions & 3 deletions zebra-chain/src/transaction/lock_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`].
Expand All @@ -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"),
)
}
}

Expand All @@ -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"),
))
}
}
}
3 changes: 2 additions & 1 deletion zebra-chain/src/transaction/tests/vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ fn deserialize_large_transaction() {

// Create a lock time.
let lock_time = LockTime::Time(DateTime::<Utc>::from_utc(
NaiveDateTime::from_timestamp(61, 0),
NaiveDateTime::from_timestamp_opt(61, 0)
.expect("in-range number of seconds and valid nanosecond"),
Utc,
));

Expand Down
2 changes: 1 addition & 1 deletion zebra-consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion zebra-network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
5 changes: 4 additions & 1 deletion zebra-network/src/peer/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion zebra-network/src/protocol/external/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion zebra-rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion zebra-state/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion zebrad/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 2680e3c

Please sign in to comment.