SDK: Allow `RecentBlockhashes` to hold the entire `BlockhashQueue` (#8632)
automerge
This commit is contained in:
parent
f47a789b15
commit
9d667db634
|
@ -358,7 +358,11 @@ mod tests {
|
||||||
fn create_default_recent_blockhashes_account() -> RefCell<Account> {
|
fn create_default_recent_blockhashes_account() -> RefCell<Account> {
|
||||||
RefCell::new(sysvar::recent_blockhashes::create_account_with_data(
|
RefCell::new(sysvar::recent_blockhashes::create_account_with_data(
|
||||||
1,
|
1,
|
||||||
vec![IterItem(0u64, &Hash::default(), &FeeCalculator::default()); 32].into_iter(),
|
vec![
|
||||||
|
IterItem(0u64, &Hash::default(), &FeeCalculator::default());
|
||||||
|
sysvar::recent_blockhashes::MAX_ENTRIES
|
||||||
|
]
|
||||||
|
.into_iter(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
fn create_default_rent_account() -> RefCell<Account> {
|
fn create_default_rent_account() -> RefCell<Account> {
|
||||||
|
@ -1088,11 +1092,7 @@ mod tests {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|meta| {
|
.map(|meta| {
|
||||||
RefCell::new(if sysvar::recent_blockhashes::check_id(&meta.pubkey) {
|
RefCell::new(if sysvar::recent_blockhashes::check_id(&meta.pubkey) {
|
||||||
sysvar::recent_blockhashes::create_account_with_data(
|
create_default_recent_blockhashes_account().into_inner()
|
||||||
1,
|
|
||||||
vec![IterItem(0u64, &Hash::default(), &FeeCalculator::default()); 32]
|
|
||||||
.into_iter(),
|
|
||||||
)
|
|
||||||
} else if sysvar::rent::check_id(&meta.pubkey) {
|
} else if sysvar::rent::check_id(&meta.pubkey) {
|
||||||
sysvar::rent::create_account(1, &Rent::free())
|
sysvar::rent::create_account(1, &Rent::free())
|
||||||
} else {
|
} else {
|
||||||
|
@ -1196,7 +1196,7 @@ mod tests {
|
||||||
&hash(&serialize(&0).unwrap()),
|
&hash(&serialize(&0).unwrap()),
|
||||||
&FeeCalculator::default()
|
&FeeCalculator::default()
|
||||||
);
|
);
|
||||||
32
|
sysvar::recent_blockhashes::MAX_ENTRIES
|
||||||
]
|
]
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
));
|
));
|
||||||
|
|
|
@ -7,7 +7,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
use std::{cmp::Ordering, collections::BinaryHeap, iter::FromIterator, ops::Deref};
|
use std::{cmp::Ordering, collections::BinaryHeap, iter::FromIterator, ops::Deref};
|
||||||
|
|
||||||
const MAX_ENTRIES: usize = 32;
|
pub const MAX_ENTRIES: usize = 150;
|
||||||
|
|
||||||
declare_sysvar_id!(
|
declare_sysvar_id!(
|
||||||
"SysvarRecentB1ockHashes11111111111111111111",
|
"SysvarRecentB1ockHashes11111111111111111111",
|
||||||
|
@ -107,7 +107,7 @@ impl<T: Ord> Iterator for IntoIterSorted<T> {
|
||||||
impl Sysvar for RecentBlockhashes {
|
impl Sysvar for RecentBlockhashes {
|
||||||
fn size_of() -> usize {
|
fn size_of() -> usize {
|
||||||
// hard-coded so that we don't have to construct an empty
|
// hard-coded so that we don't have to construct an empty
|
||||||
1288 // golden, update if MAX_ENTRIES changes
|
6008 // golden, update if MAX_ENTRIES changes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,10 +162,16 @@ pub fn create_test_recent_blockhashes(start: usize) -> RecentBlockhashes {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::hash::HASH_BYTES;
|
use crate::{clock::MAX_PROCESSING_AGE, hash::HASH_BYTES};
|
||||||
use rand::seq::SliceRandom;
|
use rand::seq::SliceRandom;
|
||||||
use rand::thread_rng;
|
use rand::thread_rng;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_sysvar_can_hold_all_active_blockhashes() {
|
||||||
|
// Ensure we can still hold all of the active entries in `BlockhashQueue`
|
||||||
|
assert!(MAX_PROCESSING_AGE <= MAX_ENTRIES);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_size_of() {
|
fn test_size_of() {
|
||||||
let entry = Entry::new(&Hash::default(), &FeeCalculator::default());
|
let entry = Entry::new(&Hash::default(), &FeeCalculator::default());
|
||||||
|
|
Loading…
Reference in New Issue