-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Remove time-utils #11410
base: master
Are you sure you want to change the base?
Remove time-utils #11410
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,7 +62,6 @@ use rlp::{encode, Decodable, DecoderError, Encodable, RlpStream, Rlp}; | |
use ethereum_types::{H256, H520, Address, U128, U256}; | ||
use parity_bytes::Bytes; | ||
use parking_lot::{Mutex, RwLock}; | ||
use time_utils::CheckedSystemTime; | ||
use common_types::{ | ||
ancestry_action::AncestryAction, | ||
BlockNumber, | ||
|
@@ -759,10 +758,10 @@ fn verify_timestamp(step: &Step, header_step: u64) -> Result<(), BlockError> { | |
// Returning it further won't recover the sync process. | ||
trace!(target: "engine", "verify_timestamp: block too early"); | ||
|
||
let found = CheckedSystemTime::checked_add(UNIX_EPOCH, Duration::from_secs(oob.found)) | ||
let found = UNIX_EPOCH.checked_add(Duration::from_secs(oob.found)) | ||
.ok_or(BlockError::TimestampOverflow)?; | ||
let max = oob.max.and_then(|m| CheckedSystemTime::checked_add(UNIX_EPOCH, Duration::from_secs(m))); | ||
let min = oob.min.and_then(|m| CheckedSystemTime::checked_add(UNIX_EPOCH, Duration::from_secs(m))); | ||
let max = oob.max.and_then(|m| UNIX_EPOCH.checked_add(Duration::from_secs(m))); | ||
let min = oob.min.and_then(|m| UNIX_EPOCH.checked_add(Duration::from_secs(m))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for authority-round the issue of |
||
|
||
let new_oob = OutOfBounds { min, max, found }; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,6 @@ use common_types::{ | |
use ethereum_types::{Address, H64}; | ||
use log::{debug, trace}; | ||
use rand::Rng; | ||
use time_utils::CheckedSystemTime; | ||
use unexpected::Mismatch; | ||
|
||
use crate::{ | ||
|
@@ -273,7 +272,7 @@ impl CliqueBlockState { | |
// This is a quite bad API because we must mutate both variables even when already `inturn` fails | ||
// That's why we can't return early and must have the `if-else` in the end | ||
pub fn calc_next_timestamp(&mut self, timestamp: u64, period: u64) -> Result<(), Error> { | ||
let inturn = CheckedSystemTime::checked_add(UNIX_EPOCH, Duration::from_secs(timestamp.saturating_add(period))); | ||
let inturn = UNIX_EPOCH.checked_add(Duration::from_secs(timestamp.saturating_add(period))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is the tricky part that needs to be audited |
||
|
||
self.next_timestamp_inturn = inturn; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,7 +84,6 @@ use macros::map; | |
use parking_lot::RwLock; | ||
use rand::Rng; | ||
use unexpected::{Mismatch, OutOfBounds}; | ||
use time_utils::CheckedSystemTime; | ||
use common_types::{ | ||
BlockNumber, | ||
ids::BlockId, | ||
|
@@ -571,7 +570,7 @@ impl Engine for Clique { | |
|
||
// Don't waste time checking blocks from the future | ||
{ | ||
let limit = CheckedSystemTime::checked_add(SystemTime::now(), Duration::from_secs(self.period)) | ||
let limit = SystemTime::now().checked_add(Duration::from_secs(self.period)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here it doesn't matter if we're not taking 2038 problem into account as |
||
.ok_or(BlockError::TimestampOverflow)?; | ||
|
||
// This should succeed under the constraints that the system clock works | ||
|
@@ -581,7 +580,7 @@ impl Engine for Clique { | |
|
||
let hdr = Duration::from_secs(header.timestamp()); | ||
if hdr > limit_as_dur { | ||
let found = CheckedSystemTime::checked_add(UNIX_EPOCH, hdr).ok_or(BlockError::TimestampOverflow)?; | ||
let found = UNIX_EPOCH.checked_add(hdr).ok_or(BlockError::TimestampOverflow)?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here we're in the error path anyway |
||
|
||
Err(BlockError::TemporarilyInvalid(OutOfBounds { | ||
min: None, | ||
|
@@ -692,8 +691,8 @@ impl Engine for Clique { | |
// Ensure that the block's timestamp isn't too close to it's parent | ||
let limit = parent.timestamp().saturating_add(self.period); | ||
if limit > header.timestamp() { | ||
let max = CheckedSystemTime::checked_add(UNIX_EPOCH, Duration::from_secs(header.timestamp())); | ||
let found = CheckedSystemTime::checked_add(UNIX_EPOCH, Duration::from_secs(limit)) | ||
let max = UNIX_EPOCH.checked_add(Duration::from_secs(header.timestamp())); | ||
let found = UNIX_EPOCH.checked_add(Duration::from_secs(limit)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. error path again |
||
.ok_or(BlockError::TimestampOverflow)?; | ||
|
||
Err(BlockError::InvalidTimestamp(OutOfBounds { | ||
|
This file was deleted.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.