diff --git a/prdoc/pr_5055.prdoc b/prdoc/pr_5055.prdoc new file mode 100644 index 000000000000..470deed2765b --- /dev/null +++ b/prdoc/pr_5055.prdoc @@ -0,0 +1,11 @@ +title: Only log error in `UnixTime::now` call of the pallet-timestamp implementation if called at genesis + +doc: + - audience: Runtime Dev + description: | + This minor patch re-introduces a check to ensure that the `UnixTime::now` implementation in the timestamp only + logs an error if called at the genesis block. + +crates: +- name: pallet-timestamp + bump: patch diff --git a/substrate/frame/timestamp/src/lib.rs b/substrate/frame/timestamp/src/lib.rs index ca495c5e24ef..78e2939e65b9 100644 --- a/substrate/frame/timestamp/src/lib.rs +++ b/substrate/frame/timestamp/src/lib.rs @@ -368,10 +368,12 @@ impl UnixTime for Pallet { // `sp_timestamp::InherentDataProvider`. let now = Now::::get(); - log::error!( - target: "runtime::timestamp", - "`pallet_timestamp::UnixTime::now` is called at genesis, invalid value returned: 0", - ); + if now == T::Moment::zero() { + log::error!( + target: "runtime::timestamp", + "`pallet_timestamp::UnixTime::now` is called at genesis, invalid value returned: 0", + ); + } core::time::Duration::from_millis(now.saturated_into::()) }