From ac09996a2066417b23e77f9c07b4e7011bc49d32 Mon Sep 17 00:00:00 2001 From: SW van Heerden Date: Mon, 17 Feb 2025 17:38:17 +0200 Subject: [PATCH 1/2] fix validation --- base_layer/core/src/validation/helpers.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/base_layer/core/src/validation/helpers.rs b/base_layer/core/src/validation/helpers.rs index a713859c71..a986824662 100644 --- a/base_layer/core/src/validation/helpers.rs +++ b/base_layer/core/src/validation/helpers.rs @@ -60,6 +60,8 @@ pub const LOG_TARGET: &str = "c::val::helpers"; /// When an empty slice is given as this is undefined for median average. /// https://math.stackexchange.com/a/3451015 pub fn calc_median_timestamp(timestamps: &[EpochTime]) -> Result { + let mut timestamps: Vec = timestamps.to_vec(); + timestamps.sort(); trace!( target: LOG_TARGET, "Calculate the median timestamp from {} timestamps", @@ -112,6 +114,11 @@ pub fn check_header_timestamp_greater_than_median( median_timestamp, block_header.hash().to_hex() ); + warn!( + target: LOG_TARGET, + "{:?}", + timestamps + ); return Err(ValidationError::BlockHeaderError( BlockHeaderValidationError::InvalidTimestamp(format!( "The timestamp `{}` was less than the median timestamp `{}`", From d8050ad3b0cf8ad65b3c324b71663593637c680a Mon Sep 17 00:00:00 2001 From: SW van Heerden Date: Mon, 17 Feb 2025 17:43:08 +0200 Subject: [PATCH 2/2] remove debug --- base_layer/core/src/validation/helpers.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/base_layer/core/src/validation/helpers.rs b/base_layer/core/src/validation/helpers.rs index a986824662..81d3cb0776 100644 --- a/base_layer/core/src/validation/helpers.rs +++ b/base_layer/core/src/validation/helpers.rs @@ -114,11 +114,6 @@ pub fn check_header_timestamp_greater_than_median( median_timestamp, block_header.hash().to_hex() ); - warn!( - target: LOG_TARGET, - "{:?}", - timestamps - ); return Err(ValidationError::BlockHeaderError( BlockHeaderValidationError::InvalidTimestamp(format!( "The timestamp `{}` was less than the median timestamp `{}`",