Skip to content
Snippets Groups Projects
Unverified Commit 03c45b91 authored by Gonçalo Pestana's avatar Gonçalo Pestana Committed by GitHub
Browse files

pallet-timestamp: `UnixTime::now` implementation logs error only if called at genesis (#5055)

This PR reverts the removal of an [`if`
statement](https://github.com/paritytech/polkadot-sdk/commit/7ecf3f75#diff-8bf31ba8d9ebd6377983fd7ecc7f4e41cb1478a600db1a15a578d1ae0e8ed435L370)
merged recently, which affected test output verbosity of several pallets
(e.g. staking, EPM, and potentially others).

More generally, the `UnixTime::now` implementation of the timestamp
pallet should log an error *only* when called at the genesis block.
parent 686ee99c
No related merge requests found
Pipeline #486917 waiting for manual action with stages
in 1 hour, 24 minutes, and 16 seconds
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
......@@ -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>())
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment