Deprecate SysvarRecentBlockhashes (#18875)
This commit is contained in:
@@ -65,6 +65,8 @@ use log::*;
|
||||
use rayon::ThreadPool;
|
||||
use solana_measure::measure::Measure;
|
||||
use solana_metrics::{datapoint_debug, inc_new_counter_debug, inc_new_counter_info};
|
||||
#[allow(deprecated)]
|
||||
use solana_sdk::recent_blockhashes_account;
|
||||
use solana_sdk::{
|
||||
account::{
|
||||
create_account_shared_data_with_fields as create_account, from_account, Account,
|
||||
@@ -96,7 +98,6 @@ use solana_sdk::{
|
||||
process_instruction::{ComputeMeter, Executor, ProcessInstructionWithContext},
|
||||
program_utils::limited_deserialize,
|
||||
pubkey::Pubkey,
|
||||
recent_blockhashes_account,
|
||||
sanitized_transaction::{SanitizedTransaction, SanitizedTransactionSlice},
|
||||
signature::{Keypair, Signature},
|
||||
slot_hashes::SlotHashes,
|
||||
@@ -2157,6 +2158,7 @@ impl Bank {
|
||||
}
|
||||
|
||||
fn update_recent_blockhashes_locked(&self, locked_blockhash_queue: &BlockhashQueue) {
|
||||
#[allow(deprecated)]
|
||||
self.update_sysvar_account(&sysvar::recent_blockhashes::id(), |account| {
|
||||
let recent_blockhash_iter = locked_blockhash_queue.get_recent_blockhashes();
|
||||
recent_blockhashes_account::create_account_with_data_and_fields(
|
||||
@@ -5292,6 +5294,7 @@ impl Bank {
|
||||
sysvar::clock::id(),
|
||||
sysvar::epoch_schedule::id(),
|
||||
sysvar::fees::id(),
|
||||
#[allow(deprecated)]
|
||||
sysvar::recent_blockhashes::id(),
|
||||
sysvar::rent::id(),
|
||||
sysvar::rewards::id(),
|
||||
@@ -9737,6 +9740,7 @@ pub(crate) mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
#[test]
|
||||
fn test_recent_blockhashes_sysvar() {
|
||||
let (genesis_config, _mint_keypair) = create_genesis_config(500);
|
||||
@@ -9756,6 +9760,7 @@ pub(crate) mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
#[test]
|
||||
fn test_blockhash_queue_sysvar_consistency() {
|
||||
let (genesis_config, _mint_keypair) = create_genesis_config(100_000);
|
||||
@@ -11990,6 +11995,7 @@ pub(crate) mod tests {
|
||||
sysvar::clock::id(),
|
||||
sysvar::epoch_schedule::id(),
|
||||
sysvar::fees::id(),
|
||||
#[allow(deprecated)]
|
||||
sysvar::recent_blockhashes::id(),
|
||||
sysvar::rent::id(),
|
||||
sysvar::slot_hashes::id(),
|
||||
@@ -12100,6 +12106,7 @@ pub(crate) mod tests {
|
||||
sysvar::clock::id(),
|
||||
sysvar::epoch_schedule::id(),
|
||||
sysvar::fees::id(),
|
||||
#[allow(deprecated)]
|
||||
sysvar::recent_blockhashes::id(),
|
||||
sysvar::rent::id(),
|
||||
sysvar::rewards::id(),
|
||||
@@ -13614,12 +13621,9 @@ pub(crate) mod tests {
|
||||
bank.add_builtin("mock_program1", program_id, mock_ix_processor);
|
||||
|
||||
let blockhash = bank.last_blockhash();
|
||||
let blockhash_sysvar = sysvar::recent_blockhashes::id();
|
||||
let orig_lamports = bank
|
||||
.get_account(&sysvar::recent_blockhashes::id())
|
||||
.unwrap()
|
||||
.lamports();
|
||||
info!("{:?}", bank.get_account(&sysvar::recent_blockhashes::id()));
|
||||
let blockhash_sysvar = sysvar::fees::id();
|
||||
let orig_lamports = bank.get_account(&sysvar::fees::id()).unwrap().lamports();
|
||||
info!("{:?}", bank.get_account(&sysvar::fees::id()));
|
||||
let tx = system_transaction::transfer(&mint_keypair, &blockhash_sysvar, 10, blockhash);
|
||||
assert_eq!(
|
||||
bank.process_transaction(&tx),
|
||||
@@ -13629,12 +13633,10 @@ pub(crate) mod tests {
|
||||
))
|
||||
);
|
||||
assert_eq!(
|
||||
bank.get_account(&sysvar::recent_blockhashes::id())
|
||||
.unwrap()
|
||||
.lamports(),
|
||||
bank.get_account(&sysvar::fees::id()).unwrap().lamports(),
|
||||
orig_lamports
|
||||
);
|
||||
info!("{:?}", bank.get_account(&sysvar::recent_blockhashes::id()));
|
||||
info!("{:?}", bank.get_account(&sysvar::fees::id()));
|
||||
|
||||
let accounts = vec![
|
||||
AccountMeta::new(mint_keypair.pubkey(), true),
|
||||
|
@@ -1,7 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use solana_sdk::{
|
||||
fee_calculator::FeeCalculator, hash::Hash, sysvar::recent_blockhashes, timing::timestamp,
|
||||
};
|
||||
#[allow(deprecated)]
|
||||
use solana_sdk::sysvar::recent_blockhashes;
|
||||
use solana_sdk::{fee_calculator::FeeCalculator, hash::Hash, timing::timestamp};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, AbiExample)]
|
||||
@@ -121,6 +121,11 @@ impl BlockhashQueue {
|
||||
None
|
||||
}
|
||||
|
||||
#[deprecated(
|
||||
since = "1.8.0",
|
||||
note = "Please do not use, will no longer be available in the future"
|
||||
)]
|
||||
#[allow(deprecated)]
|
||||
pub fn get_recent_blockhashes(&self) -> impl Iterator<Item = recent_blockhashes::IterItem> {
|
||||
(&self.ages)
|
||||
.iter()
|
||||
@@ -135,9 +140,9 @@ impl BlockhashQueue {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use bincode::serialize;
|
||||
use solana_sdk::{
|
||||
clock::MAX_RECENT_BLOCKHASHES, hash::hash, sysvar::recent_blockhashes::IterItem,
|
||||
};
|
||||
#[allow(deprecated)]
|
||||
use solana_sdk::sysvar::recent_blockhashes::IterItem;
|
||||
use solana_sdk::{clock::MAX_RECENT_BLOCKHASHES, hash::hash};
|
||||
|
||||
#[test]
|
||||
fn test_register_hash() {
|
||||
@@ -180,6 +185,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_get_recent_blockhashes() {
|
||||
let mut blockhash_queue = BlockhashQueue::new(MAX_RECENT_BLOCKHASHES);
|
||||
#[allow(deprecated)]
|
||||
let recent_blockhashes = blockhash_queue.get_recent_blockhashes();
|
||||
// Sanity-check an empty BlockhashQueue
|
||||
assert_eq!(recent_blockhashes.count(), 0);
|
||||
@@ -187,8 +193,10 @@ mod tests {
|
||||
let hash = hash(&serialize(&i).unwrap());
|
||||
blockhash_queue.register_hash(&hash, &FeeCalculator::default());
|
||||
}
|
||||
#[allow(deprecated)]
|
||||
let recent_blockhashes = blockhash_queue.get_recent_blockhashes();
|
||||
// Verify that the returned hashes are most recent
|
||||
#[allow(deprecated)]
|
||||
for IterItem(_slot, hash, _fee_calc) in recent_blockhashes {
|
||||
assert_eq!(
|
||||
Some(true),
|
||||
|
@@ -1,4 +1,6 @@
|
||||
use log::*;
|
||||
#[allow(deprecated)]
|
||||
use solana_sdk::sysvar::recent_blockhashes::RecentBlockhashes;
|
||||
use solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount, WritableAccount},
|
||||
account_utils::StateMut,
|
||||
@@ -12,7 +14,7 @@ use solana_sdk::{
|
||||
pubkey::Pubkey,
|
||||
system_instruction::{SystemError, SystemInstruction, MAX_PERMITTED_DATA_LENGTH},
|
||||
system_program,
|
||||
sysvar::{self, recent_blockhashes::RecentBlockhashes, rent::Rent},
|
||||
sysvar::{self, rent::Rent},
|
||||
};
|
||||
use std::collections::HashSet;
|
||||
|
||||
@@ -352,6 +354,7 @@ pub fn process_instruction(
|
||||
SystemInstruction::AdvanceNonceAccount => {
|
||||
let me = &mut keyed_account_at_index(keyed_accounts, 0)?;
|
||||
me.advance_nonce_account(
|
||||
#[allow(deprecated)]
|
||||
&from_keyed_account::<RecentBlockhashes>(keyed_account_at_index(
|
||||
keyed_accounts,
|
||||
1,
|
||||
@@ -366,6 +369,7 @@ pub fn process_instruction(
|
||||
me.withdraw_nonce_account(
|
||||
lamports,
|
||||
to,
|
||||
#[allow(deprecated)]
|
||||
&from_keyed_account::<RecentBlockhashes>(keyed_account_at_index(
|
||||
keyed_accounts,
|
||||
2,
|
||||
@@ -379,6 +383,7 @@ pub fn process_instruction(
|
||||
let me = &mut keyed_account_at_index(keyed_accounts, 0)?;
|
||||
me.initialize_nonce_account(
|
||||
&authorized,
|
||||
#[allow(deprecated)]
|
||||
&from_keyed_account::<RecentBlockhashes>(keyed_account_at_index(
|
||||
keyed_accounts,
|
||||
1,
|
||||
@@ -462,6 +467,8 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::{bank::Bank, bank_client::BankClient};
|
||||
use bincode::serialize;
|
||||
#[allow(deprecated)]
|
||||
use solana_sdk::sysvar::recent_blockhashes::IterItem;
|
||||
use solana_sdk::{
|
||||
account::{self, Account, AccountSharedData},
|
||||
client::SyncClient,
|
||||
@@ -475,7 +482,6 @@ mod tests {
|
||||
recent_blockhashes_account,
|
||||
signature::{Keypair, Signer},
|
||||
system_instruction, system_program, sysvar,
|
||||
sysvar::recent_blockhashes::IterItem,
|
||||
transaction::TransactionError,
|
||||
};
|
||||
use std::cell::RefCell;
|
||||
@@ -507,6 +513,7 @@ mod tests {
|
||||
}
|
||||
fn create_default_recent_blockhashes_account() -> RefCell<AccountSharedData> {
|
||||
RefCell::new(
|
||||
#[allow(deprecated)]
|
||||
recent_blockhashes_account::create_account_with_data_for_test(
|
||||
vec![
|
||||
IterItem(0u64, &Hash::default(), &FeeCalculator::default());
|
||||
@@ -1456,6 +1463,7 @@ mod tests {
|
||||
.accounts
|
||||
.iter()
|
||||
.map(|meta| {
|
||||
#[allow(deprecated)]
|
||||
RefCell::new(if sysvar::recent_blockhashes::check_id(&meta.pubkey) {
|
||||
create_default_recent_blockhashes_account().into_inner()
|
||||
} else if sysvar::rent::check_id(&meta.pubkey) {
|
||||
@@ -1524,6 +1532,7 @@ mod tests {
|
||||
vec![
|
||||
KeyedAccount::new(&Pubkey::default(), true, &create_default_account()),
|
||||
KeyedAccount::new(
|
||||
#[allow(deprecated)]
|
||||
&sysvar::recent_blockhashes::id(),
|
||||
false,
|
||||
&create_default_account(),
|
||||
@@ -1543,6 +1552,7 @@ mod tests {
|
||||
vec![
|
||||
KeyedAccount::new(&Pubkey::default(), true, &nonce_acc),
|
||||
KeyedAccount::new(
|
||||
#[allow(deprecated)]
|
||||
&sysvar::recent_blockhashes::id(),
|
||||
false,
|
||||
&create_default_recent_blockhashes_account(),
|
||||
@@ -1553,6 +1563,7 @@ mod tests {
|
||||
)
|
||||
.unwrap();
|
||||
let new_recent_blockhashes_account = RefCell::new(
|
||||
#[allow(deprecated)]
|
||||
solana_sdk::recent_blockhashes_account::create_account_with_data_for_test(
|
||||
vec![
|
||||
IterItem(
|
||||
@@ -1570,6 +1581,7 @@ mod tests {
|
||||
&Pubkey::default(),
|
||||
vec![
|
||||
KeyedAccount::new(&Pubkey::default(), true, &nonce_acc,),
|
||||
#[allow(deprecated)]
|
||||
KeyedAccount::new(
|
||||
&sysvar::recent_blockhashes::id(),
|
||||
false,
|
||||
@@ -1632,6 +1644,7 @@ mod tests {
|
||||
KeyedAccount::new(&Pubkey::default(), true, &create_default_account()),
|
||||
KeyedAccount::new(&Pubkey::default(), false, &create_default_account()),
|
||||
KeyedAccount::new(
|
||||
#[allow(deprecated)]
|
||||
&sysvar::recent_blockhashes::id(),
|
||||
false,
|
||||
&create_default_account()
|
||||
@@ -1656,6 +1669,7 @@ mod tests {
|
||||
),
|
||||
KeyedAccount::new(&Pubkey::default(), true, &create_default_account()),
|
||||
KeyedAccount::new(
|
||||
#[allow(deprecated)]
|
||||
&sysvar::recent_blockhashes::id(),
|
||||
false,
|
||||
&create_default_recent_blockhashes_account(),
|
||||
@@ -1681,6 +1695,7 @@ mod tests {
|
||||
),
|
||||
KeyedAccount::new(&Pubkey::default(), true, &create_default_account()),
|
||||
KeyedAccount::new(
|
||||
#[allow(deprecated)]
|
||||
&sysvar::recent_blockhashes::id(),
|
||||
false,
|
||||
&create_default_recent_blockhashes_account(),
|
||||
@@ -1733,6 +1748,7 @@ mod tests {
|
||||
&nonce_account::create_account(1_000_000),
|
||||
),
|
||||
KeyedAccount::new(
|
||||
#[allow(deprecated)]
|
||||
&sysvar::recent_blockhashes::id(),
|
||||
false,
|
||||
&create_default_account()
|
||||
@@ -1756,6 +1772,7 @@ mod tests {
|
||||
&nonce_account::create_account(1_000_000),
|
||||
),
|
||||
KeyedAccount::new(
|
||||
#[allow(deprecated)]
|
||||
&sysvar::recent_blockhashes::id(),
|
||||
false,
|
||||
&create_default_recent_blockhashes_account(),
|
||||
@@ -1780,6 +1797,7 @@ mod tests {
|
||||
&nonce_account::create_account(1_000_000),
|
||||
),
|
||||
KeyedAccount::new(
|
||||
#[allow(deprecated)]
|
||||
&sysvar::recent_blockhashes::id(),
|
||||
false,
|
||||
&create_default_recent_blockhashes_account(),
|
||||
@@ -1800,6 +1818,7 @@ mod tests {
|
||||
vec![
|
||||
KeyedAccount::new(&Pubkey::default(), true, &nonce_acc),
|
||||
KeyedAccount::new(
|
||||
#[allow(deprecated)]
|
||||
&sysvar::recent_blockhashes::id(),
|
||||
false,
|
||||
&create_default_recent_blockhashes_account(),
|
||||
|
Reference in New Issue
Block a user