Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions prdoc/pr_5055.prdoc
Original file line number Diff line number Diff line change
@@ -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: minor
10 changes: 6 additions & 4 deletions substrate/frame/timestamp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,12 @@ impl<T: Config> UnixTime for Pallet<T> {
// `sp_timestamp::InherentDataProvider`.
let now = Now::<T>::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::<u64>())
}
Expand Down