From 246e8985f40f05c00f175912cc2665f5571e1034 Mon Sep 17 00:00:00 2001 From: Andrew Fitzgerald Date: Sun, 12 May 2024 10:19:26 -0500 Subject: [PATCH] Bank::unix_timestamp_from_genesis use saturating math (#1290) --- runtime/src/bank.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index fa9e98d08a60c6..210d833b2800f0 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -1812,7 +1812,11 @@ impl Bank { /// computed unix_timestamp at this slot height pub fn unix_timestamp_from_genesis(&self) -> i64 { - self.genesis_creation_time + ((self.slot as u128 * self.ns_per_slot) / 1_000_000_000) as i64 + self.genesis_creation_time.saturating_add( + (self.slot as u128) + .saturating_mul(self.ns_per_slot) + .saturating_div(1_000_000_000) as i64, + ) } fn update_sysvar_account(&self, pubkey: &Pubkey, updater: F)