Skip to content

Commit

Permalink
Mode gate RecentBlockhashes/BlockhashQueue sync
Browse files Browse the repository at this point in the history
  • Loading branch information
t-nelson authored and mergify[bot] committed Jul 14, 2020
1 parent 51283c9 commit 5741002
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,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
}

Expand Down Expand Up @@ -1258,7 +1260,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);
}
}
}

Expand Down Expand Up @@ -2914,6 +2918,16 @@ impl Bank {
}
consumed_budget.saturating_sub(budget_recovery_delta)
}

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 {
Expand Down

0 comments on commit 5741002

Please sign in to comment.