From 9552df5db288bca8eb461bb1e153c6efe0868640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= Date: Sun, 10 Nov 2019 17:22:43 +0000 Subject: [PATCH 1/2] srml-timestamp: define max timestamp drift in millis --- srml/timestamp/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/timestamp/src/lib.rs b/srml/timestamp/src/lib.rs index 2ab751088e8c7..095f0420f2b70 100644 --- a/srml/timestamp/src/lib.rs +++ b/srml/timestamp/src/lib.rs @@ -288,7 +288,7 @@ impl ProvideInherent for Module { } fn check_inherent(call: &Self::Call, data: &InherentData) -> result::Result<(), Self::Error> { - const MAX_TIMESTAMP_DRIFT: u64 = 60; + const MAX_TIMESTAMP_DRIFT: u64 = 30 * 1000; let t: u64 = match call { Call::set(ref t) => t.clone().saturated_into::(), From 2ad9c0f63e8011d222c54d731d1fb671fbdbe0f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= Date: Sun, 10 Nov 2019 18:07:45 +0000 Subject: [PATCH 2/2] srml-timestamp: suffix MAX_TIMESTAMP_DRIFT with unit --- srml/timestamp/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srml/timestamp/src/lib.rs b/srml/timestamp/src/lib.rs index 095f0420f2b70..5f0ec8d443b26 100644 --- a/srml/timestamp/src/lib.rs +++ b/srml/timestamp/src/lib.rs @@ -288,7 +288,7 @@ impl ProvideInherent for Module { } fn check_inherent(call: &Self::Call, data: &InherentData) -> result::Result<(), Self::Error> { - const MAX_TIMESTAMP_DRIFT: u64 = 30 * 1000; + const MAX_TIMESTAMP_DRIFT_MILLIS: u64 = 30 * 1000; let t: u64 = match call { Call::set(ref t) => t.clone().saturated_into::(), @@ -298,7 +298,7 @@ impl ProvideInherent for Module { let data = extract_inherent_data(data).map_err(|e| InherentError::Other(e))?; let minimum = (Self::now() + T::MinimumPeriod::get()).saturated_into::(); - if t > data + MAX_TIMESTAMP_DRIFT { + if t > data + MAX_TIMESTAMP_DRIFT_MILLIS { Err(InherentError::Other("Timestamp too far in future to accept".into())) } else if t < minimum { Err(InherentError::ValidAtTimestamp(minimum))