From d6ea4f50c9ac1acfaa70da470b844300e34e3d08 Mon Sep 17 00:00:00 2001 From: Trent Nelson Date: Mon, 13 Jul 2020 15:38:06 -0600 Subject: [PATCH] Mode gate RecentBlockhashes/BlockhashQueue sync (cherry picked from commit 5741002a3201d33e01f74f1fe1f7d52726cc41e5) --- runtime/src/bank.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 4e85ef777c..3f6143beb7 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -532,7 +532,9 @@ impl Bank { new.update_stake_history(Some(parent.epoch())); new.update_clock(); new.update_fees(); - new.update_recent_blockhashes(); + if !new.fix_recent_blockhashes_sysvar_delay() { + new.update_recent_blockhashes(); + } new } @@ -1116,7 +1118,9 @@ impl Bank { let current_tick_height = self.tick_height.fetch_add(1, Ordering::Relaxed) as u64; if self.is_block_boundary(current_tick_height + 1) { w_blockhash_queue.register_hash(hash, &self.fee_calculator); - self.update_recent_blockhashes_locked(&w_blockhash_queue); + if self.fix_recent_blockhashes_sysvar_delay() { + self.update_recent_blockhashes_locked(&w_blockhash_queue); + } } } @@ -2652,6 +2656,16 @@ impl Bank { pub fn shrink_all_stale_slots(&self) { self.rc.accounts.accounts_db.shrink_all_stale_slots(); } + + fn fix_recent_blockhashes_sysvar_delay(&self) -> bool { + let activation_slot = match self.operating_mode() { + OperatingMode::Development => 0, + OperatingMode::Stable => Slot::MAX / 2, + OperatingMode::Preview => Slot::MAX / 2, + }; + + self.slot() >= activation_slot + } } impl Drop for Bank {