Test that tick slot hashes update the recent blockhash queue (#24242)
This commit is contained in:
@ -93,8 +93,8 @@ use {
|
||||
account_utils::StateMut,
|
||||
clock::{
|
||||
BankId, Epoch, Slot, SlotCount, SlotIndex, UnixTimestamp, DEFAULT_TICKS_PER_SECOND,
|
||||
INITIAL_RENT_EPOCH, MAX_PROCESSING_AGE, MAX_RECENT_BLOCKHASHES,
|
||||
MAX_TRANSACTION_FORWARDING_DELAY, SECONDS_PER_DAY,
|
||||
INITIAL_RENT_EPOCH, MAX_PROCESSING_AGE, MAX_TRANSACTION_FORWARDING_DELAY,
|
||||
SECONDS_PER_DAY,
|
||||
},
|
||||
ed25519_program,
|
||||
epoch_info::EpochInfo,
|
||||
@ -1252,12 +1252,6 @@ pub struct Bank {
|
||||
pub fee_structure: FeeStructure,
|
||||
}
|
||||
|
||||
impl Default for BlockhashQueue {
|
||||
fn default() -> Self {
|
||||
Self::new(MAX_RECENT_BLOCKHASHES)
|
||||
}
|
||||
}
|
||||
|
||||
struct VoteWithStakeDelegations {
|
||||
vote_state: Arc<VoteState>,
|
||||
vote_account: AccountSharedData,
|
||||
@ -3730,6 +3724,10 @@ impl Bank {
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn get_hash_age(&self, hash: &Hash) -> Option<u64> {
|
||||
self.blockhash_queue.read().unwrap().get_hash_age(hash)
|
||||
}
|
||||
|
||||
pub fn check_hash_age(&self, hash: &Hash, max_age: usize) -> Option<bool> {
|
||||
self.blockhash_queue
|
||||
.read()
|
||||
@ -6854,7 +6852,7 @@ pub(crate) mod tests {
|
||||
solana_sdk::{
|
||||
account::Account,
|
||||
bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable,
|
||||
clock::{DEFAULT_SLOTS_PER_EPOCH, DEFAULT_TICKS_PER_SLOT},
|
||||
clock::{DEFAULT_SLOTS_PER_EPOCH, DEFAULT_TICKS_PER_SLOT, MAX_RECENT_BLOCKHASHES},
|
||||
compute_budget::ComputeBudgetInstruction,
|
||||
epoch_schedule::MINIMUM_SLOTS_PER_EPOCH,
|
||||
feature::Feature,
|
||||
|
@ -2,7 +2,9 @@
|
||||
use solana_sdk::sysvar::recent_blockhashes;
|
||||
use {
|
||||
serde::{Deserialize, Serialize},
|
||||
solana_sdk::{fee_calculator::FeeCalculator, hash::Hash, timing::timestamp},
|
||||
solana_sdk::{
|
||||
clock::MAX_RECENT_BLOCKHASHES, fee_calculator::FeeCalculator, hash::Hash, timing::timestamp,
|
||||
},
|
||||
std::collections::HashMap,
|
||||
};
|
||||
|
||||
@ -29,6 +31,12 @@ pub struct BlockhashQueue {
|
||||
max_age: usize,
|
||||
}
|
||||
|
||||
impl Default for BlockhashQueue {
|
||||
fn default() -> Self {
|
||||
Self::new(MAX_RECENT_BLOCKHASHES)
|
||||
}
|
||||
}
|
||||
|
||||
impl BlockhashQueue {
|
||||
pub fn new(max_age: usize) -> Self {
|
||||
Self {
|
||||
|
Reference in New Issue
Block a user