Deprecate SysvarRecentBlockhashes (#18875)
This commit is contained in:
parent
f1b9f97aef
commit
72e374d0f3
|
@ -4,6 +4,8 @@ use crate::{
|
||||||
};
|
};
|
||||||
use bincode::deserialize;
|
use bincode::deserialize;
|
||||||
use bv::BitVec;
|
use bv::BitVec;
|
||||||
|
#[allow(deprecated)]
|
||||||
|
use solana_sdk::sysvar::recent_blockhashes::RecentBlockhashes;
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
clock::{Clock, Epoch, Slot, UnixTimestamp},
|
clock::{Clock, Epoch, Slot, UnixTimestamp},
|
||||||
epoch_schedule::EpochSchedule,
|
epoch_schedule::EpochSchedule,
|
||||||
|
@ -12,10 +14,11 @@ use solana_sdk::{
|
||||||
slot_hashes::SlotHashes,
|
slot_hashes::SlotHashes,
|
||||||
slot_history::{self, SlotHistory},
|
slot_history::{self, SlotHistory},
|
||||||
stake_history::{StakeHistory, StakeHistoryEntry},
|
stake_history::{StakeHistory, StakeHistoryEntry},
|
||||||
sysvar::{self, fees::Fees, recent_blockhashes::RecentBlockhashes, rewards::Rewards},
|
sysvar::{self, fees::Fees, rewards::Rewards},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn parse_sysvar(data: &[u8], pubkey: &Pubkey) -> Result<SysvarAccountType, ParseAccountError> {
|
pub fn parse_sysvar(data: &[u8], pubkey: &Pubkey) -> Result<SysvarAccountType, ParseAccountError> {
|
||||||
|
#[allow(deprecated)]
|
||||||
let parsed_account = {
|
let parsed_account = {
|
||||||
if pubkey == &sysvar::clock::id() {
|
if pubkey == &sysvar::clock::id() {
|
||||||
deserialize::<Clock>(data)
|
deserialize::<Clock>(data)
|
||||||
|
@ -213,10 +216,9 @@ pub struct UiStakeHistoryEntry {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
use solana_sdk::{
|
#[allow(deprecated)]
|
||||||
account::create_account_for_test, fee_calculator::FeeCalculator, hash::Hash,
|
use solana_sdk::sysvar::recent_blockhashes::IterItem;
|
||||||
sysvar::recent_blockhashes::IterItem,
|
use solana_sdk::{account::create_account_for_test, fee_calculator::FeeCalculator, hash::Hash};
|
||||||
};
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_sysvars() {
|
fn test_parse_sysvars() {
|
||||||
|
@ -249,6 +251,7 @@ mod test {
|
||||||
let fee_calculator = FeeCalculator {
|
let fee_calculator = FeeCalculator {
|
||||||
lamports_per_signature: 10,
|
lamports_per_signature: 10,
|
||||||
};
|
};
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes: RecentBlockhashes = vec![IterItem(0, &hash, &fee_calculator)]
|
let recent_blockhashes: RecentBlockhashes = vec![IterItem(0, &hash, &fee_calculator)]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.collect();
|
.collect();
|
||||||
|
@ -256,6 +259,7 @@ mod test {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_sysvar(
|
parse_sysvar(
|
||||||
&recent_blockhashes_sysvar.data,
|
&recent_blockhashes_sysvar.data,
|
||||||
|
#[allow(deprecated)]
|
||||||
&sysvar::recent_blockhashes::id()
|
&sysvar::recent_blockhashes::id()
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
//! @brief Example Rust-based BPF program that tests sysvar use
|
//! @brief Example Rust-based BPF program that tests sysvar use
|
||||||
|
|
||||||
extern crate solana_program;
|
extern crate solana_program;
|
||||||
|
#[allow(deprecated)]
|
||||||
|
use solana_program::sysvar::recent_blockhashes::RecentBlockhashes;
|
||||||
use solana_program::{
|
use solana_program::{
|
||||||
account_info::AccountInfo,
|
account_info::AccountInfo,
|
||||||
entrypoint,
|
entrypoint,
|
||||||
|
@ -10,9 +12,8 @@ use solana_program::{
|
||||||
program_error::ProgramError,
|
program_error::ProgramError,
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
sysvar::{
|
sysvar::{
|
||||||
self, clock::Clock, epoch_schedule::EpochSchedule, fees::Fees, instructions,
|
self, clock::Clock, epoch_schedule::EpochSchedule, fees::Fees, instructions, rent::Rent,
|
||||||
recent_blockhashes::RecentBlockhashes, rent::Rent, slot_hashes::SlotHashes,
|
slot_hashes::SlotHashes, slot_history::SlotHistory, stake_history::StakeHistory, Sysvar,
|
||||||
slot_history::SlotHistory, stake_history::StakeHistory, Sysvar,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -61,6 +62,7 @@ pub fn process_instruction(
|
||||||
assert_eq!(0, index);
|
assert_eq!(0, index);
|
||||||
|
|
||||||
// Recent Blockhashes
|
// Recent Blockhashes
|
||||||
|
#[allow(deprecated)]
|
||||||
{
|
{
|
||||||
msg!("RecentBlockhashes identifier:");
|
msg!("RecentBlockhashes identifier:");
|
||||||
sysvar::recent_blockhashes::id().log();
|
sysvar::recent_blockhashes::id().log();
|
||||||
|
|
|
@ -65,6 +65,8 @@ use log::*;
|
||||||
use rayon::ThreadPool;
|
use rayon::ThreadPool;
|
||||||
use solana_measure::measure::Measure;
|
use solana_measure::measure::Measure;
|
||||||
use solana_metrics::{datapoint_debug, inc_new_counter_debug, inc_new_counter_info};
|
use solana_metrics::{datapoint_debug, inc_new_counter_debug, inc_new_counter_info};
|
||||||
|
#[allow(deprecated)]
|
||||||
|
use solana_sdk::recent_blockhashes_account;
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account::{
|
account::{
|
||||||
create_account_shared_data_with_fields as create_account, from_account, 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},
|
process_instruction::{ComputeMeter, Executor, ProcessInstructionWithContext},
|
||||||
program_utils::limited_deserialize,
|
program_utils::limited_deserialize,
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
recent_blockhashes_account,
|
|
||||||
sanitized_transaction::{SanitizedTransaction, SanitizedTransactionSlice},
|
sanitized_transaction::{SanitizedTransaction, SanitizedTransactionSlice},
|
||||||
signature::{Keypair, Signature},
|
signature::{Keypair, Signature},
|
||||||
slot_hashes::SlotHashes,
|
slot_hashes::SlotHashes,
|
||||||
|
@ -2157,6 +2158,7 @@ impl Bank {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_recent_blockhashes_locked(&self, locked_blockhash_queue: &BlockhashQueue) {
|
fn update_recent_blockhashes_locked(&self, locked_blockhash_queue: &BlockhashQueue) {
|
||||||
|
#[allow(deprecated)]
|
||||||
self.update_sysvar_account(&sysvar::recent_blockhashes::id(), |account| {
|
self.update_sysvar_account(&sysvar::recent_blockhashes::id(), |account| {
|
||||||
let recent_blockhash_iter = locked_blockhash_queue.get_recent_blockhashes();
|
let recent_blockhash_iter = locked_blockhash_queue.get_recent_blockhashes();
|
||||||
recent_blockhashes_account::create_account_with_data_and_fields(
|
recent_blockhashes_account::create_account_with_data_and_fields(
|
||||||
|
@ -5292,6 +5294,7 @@ impl Bank {
|
||||||
sysvar::clock::id(),
|
sysvar::clock::id(),
|
||||||
sysvar::epoch_schedule::id(),
|
sysvar::epoch_schedule::id(),
|
||||||
sysvar::fees::id(),
|
sysvar::fees::id(),
|
||||||
|
#[allow(deprecated)]
|
||||||
sysvar::recent_blockhashes::id(),
|
sysvar::recent_blockhashes::id(),
|
||||||
sysvar::rent::id(),
|
sysvar::rent::id(),
|
||||||
sysvar::rewards::id(),
|
sysvar::rewards::id(),
|
||||||
|
@ -9737,6 +9740,7 @@ pub(crate) mod tests {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_recent_blockhashes_sysvar() {
|
fn test_recent_blockhashes_sysvar() {
|
||||||
let (genesis_config, _mint_keypair) = create_genesis_config(500);
|
let (genesis_config, _mint_keypair) = create_genesis_config(500);
|
||||||
|
@ -9756,6 +9760,7 @@ pub(crate) mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_blockhash_queue_sysvar_consistency() {
|
fn test_blockhash_queue_sysvar_consistency() {
|
||||||
let (genesis_config, _mint_keypair) = create_genesis_config(100_000);
|
let (genesis_config, _mint_keypair) = create_genesis_config(100_000);
|
||||||
|
@ -11990,6 +11995,7 @@ pub(crate) mod tests {
|
||||||
sysvar::clock::id(),
|
sysvar::clock::id(),
|
||||||
sysvar::epoch_schedule::id(),
|
sysvar::epoch_schedule::id(),
|
||||||
sysvar::fees::id(),
|
sysvar::fees::id(),
|
||||||
|
#[allow(deprecated)]
|
||||||
sysvar::recent_blockhashes::id(),
|
sysvar::recent_blockhashes::id(),
|
||||||
sysvar::rent::id(),
|
sysvar::rent::id(),
|
||||||
sysvar::slot_hashes::id(),
|
sysvar::slot_hashes::id(),
|
||||||
|
@ -12100,6 +12106,7 @@ pub(crate) mod tests {
|
||||||
sysvar::clock::id(),
|
sysvar::clock::id(),
|
||||||
sysvar::epoch_schedule::id(),
|
sysvar::epoch_schedule::id(),
|
||||||
sysvar::fees::id(),
|
sysvar::fees::id(),
|
||||||
|
#[allow(deprecated)]
|
||||||
sysvar::recent_blockhashes::id(),
|
sysvar::recent_blockhashes::id(),
|
||||||
sysvar::rent::id(),
|
sysvar::rent::id(),
|
||||||
sysvar::rewards::id(),
|
sysvar::rewards::id(),
|
||||||
|
@ -13614,12 +13621,9 @@ pub(crate) mod tests {
|
||||||
bank.add_builtin("mock_program1", program_id, mock_ix_processor);
|
bank.add_builtin("mock_program1", program_id, mock_ix_processor);
|
||||||
|
|
||||||
let blockhash = bank.last_blockhash();
|
let blockhash = bank.last_blockhash();
|
||||||
let blockhash_sysvar = sysvar::recent_blockhashes::id();
|
let blockhash_sysvar = sysvar::fees::id();
|
||||||
let orig_lamports = bank
|
let orig_lamports = bank.get_account(&sysvar::fees::id()).unwrap().lamports();
|
||||||
.get_account(&sysvar::recent_blockhashes::id())
|
info!("{:?}", bank.get_account(&sysvar::fees::id()));
|
||||||
.unwrap()
|
|
||||||
.lamports();
|
|
||||||
info!("{:?}", bank.get_account(&sysvar::recent_blockhashes::id()));
|
|
||||||
let tx = system_transaction::transfer(&mint_keypair, &blockhash_sysvar, 10, blockhash);
|
let tx = system_transaction::transfer(&mint_keypair, &blockhash_sysvar, 10, blockhash);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
bank.process_transaction(&tx),
|
bank.process_transaction(&tx),
|
||||||
|
@ -13629,12 +13633,10 @@ pub(crate) mod tests {
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
bank.get_account(&sysvar::recent_blockhashes::id())
|
bank.get_account(&sysvar::fees::id()).unwrap().lamports(),
|
||||||
.unwrap()
|
|
||||||
.lamports(),
|
|
||||||
orig_lamports
|
orig_lamports
|
||||||
);
|
);
|
||||||
info!("{:?}", bank.get_account(&sysvar::recent_blockhashes::id()));
|
info!("{:?}", bank.get_account(&sysvar::fees::id()));
|
||||||
|
|
||||||
let accounts = vec![
|
let accounts = vec![
|
||||||
AccountMeta::new(mint_keypair.pubkey(), true),
|
AccountMeta::new(mint_keypair.pubkey(), true),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use solana_sdk::{
|
#[allow(deprecated)]
|
||||||
fee_calculator::FeeCalculator, hash::Hash, sysvar::recent_blockhashes, timing::timestamp,
|
use solana_sdk::sysvar::recent_blockhashes;
|
||||||
};
|
use solana_sdk::{fee_calculator::FeeCalculator, hash::Hash, timing::timestamp};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, AbiExample)]
|
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, AbiExample)]
|
||||||
|
@ -121,6 +121,11 @@ impl BlockhashQueue {
|
||||||
None
|
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> {
|
pub fn get_recent_blockhashes(&self) -> impl Iterator<Item = recent_blockhashes::IterItem> {
|
||||||
(&self.ages)
|
(&self.ages)
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -135,9 +140,9 @@ impl BlockhashQueue {
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use bincode::serialize;
|
use bincode::serialize;
|
||||||
use solana_sdk::{
|
#[allow(deprecated)]
|
||||||
clock::MAX_RECENT_BLOCKHASHES, hash::hash, sysvar::recent_blockhashes::IterItem,
|
use solana_sdk::sysvar::recent_blockhashes::IterItem;
|
||||||
};
|
use solana_sdk::{clock::MAX_RECENT_BLOCKHASHES, hash::hash};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_register_hash() {
|
fn test_register_hash() {
|
||||||
|
@ -180,6 +185,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_get_recent_blockhashes() {
|
fn test_get_recent_blockhashes() {
|
||||||
let mut blockhash_queue = BlockhashQueue::new(MAX_RECENT_BLOCKHASHES);
|
let mut blockhash_queue = BlockhashQueue::new(MAX_RECENT_BLOCKHASHES);
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = blockhash_queue.get_recent_blockhashes();
|
let recent_blockhashes = blockhash_queue.get_recent_blockhashes();
|
||||||
// Sanity-check an empty BlockhashQueue
|
// Sanity-check an empty BlockhashQueue
|
||||||
assert_eq!(recent_blockhashes.count(), 0);
|
assert_eq!(recent_blockhashes.count(), 0);
|
||||||
|
@ -187,8 +193,10 @@ mod tests {
|
||||||
let hash = hash(&serialize(&i).unwrap());
|
let hash = hash(&serialize(&i).unwrap());
|
||||||
blockhash_queue.register_hash(&hash, &FeeCalculator::default());
|
blockhash_queue.register_hash(&hash, &FeeCalculator::default());
|
||||||
}
|
}
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = blockhash_queue.get_recent_blockhashes();
|
let recent_blockhashes = blockhash_queue.get_recent_blockhashes();
|
||||||
// Verify that the returned hashes are most recent
|
// Verify that the returned hashes are most recent
|
||||||
|
#[allow(deprecated)]
|
||||||
for IterItem(_slot, hash, _fee_calc) in recent_blockhashes {
|
for IterItem(_slot, hash, _fee_calc) in recent_blockhashes {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Some(true),
|
Some(true),
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
use log::*;
|
use log::*;
|
||||||
|
#[allow(deprecated)]
|
||||||
|
use solana_sdk::sysvar::recent_blockhashes::RecentBlockhashes;
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account::{AccountSharedData, ReadableAccount, WritableAccount},
|
account::{AccountSharedData, ReadableAccount, WritableAccount},
|
||||||
account_utils::StateMut,
|
account_utils::StateMut,
|
||||||
|
@ -12,7 +14,7 @@ use solana_sdk::{
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
system_instruction::{SystemError, SystemInstruction, MAX_PERMITTED_DATA_LENGTH},
|
system_instruction::{SystemError, SystemInstruction, MAX_PERMITTED_DATA_LENGTH},
|
||||||
system_program,
|
system_program,
|
||||||
sysvar::{self, recent_blockhashes::RecentBlockhashes, rent::Rent},
|
sysvar::{self, rent::Rent},
|
||||||
};
|
};
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
|
@ -352,6 +354,7 @@ pub fn process_instruction(
|
||||||
SystemInstruction::AdvanceNonceAccount => {
|
SystemInstruction::AdvanceNonceAccount => {
|
||||||
let me = &mut keyed_account_at_index(keyed_accounts, 0)?;
|
let me = &mut keyed_account_at_index(keyed_accounts, 0)?;
|
||||||
me.advance_nonce_account(
|
me.advance_nonce_account(
|
||||||
|
#[allow(deprecated)]
|
||||||
&from_keyed_account::<RecentBlockhashes>(keyed_account_at_index(
|
&from_keyed_account::<RecentBlockhashes>(keyed_account_at_index(
|
||||||
keyed_accounts,
|
keyed_accounts,
|
||||||
1,
|
1,
|
||||||
|
@ -366,6 +369,7 @@ pub fn process_instruction(
|
||||||
me.withdraw_nonce_account(
|
me.withdraw_nonce_account(
|
||||||
lamports,
|
lamports,
|
||||||
to,
|
to,
|
||||||
|
#[allow(deprecated)]
|
||||||
&from_keyed_account::<RecentBlockhashes>(keyed_account_at_index(
|
&from_keyed_account::<RecentBlockhashes>(keyed_account_at_index(
|
||||||
keyed_accounts,
|
keyed_accounts,
|
||||||
2,
|
2,
|
||||||
|
@ -379,6 +383,7 @@ pub fn process_instruction(
|
||||||
let me = &mut keyed_account_at_index(keyed_accounts, 0)?;
|
let me = &mut keyed_account_at_index(keyed_accounts, 0)?;
|
||||||
me.initialize_nonce_account(
|
me.initialize_nonce_account(
|
||||||
&authorized,
|
&authorized,
|
||||||
|
#[allow(deprecated)]
|
||||||
&from_keyed_account::<RecentBlockhashes>(keyed_account_at_index(
|
&from_keyed_account::<RecentBlockhashes>(keyed_account_at_index(
|
||||||
keyed_accounts,
|
keyed_accounts,
|
||||||
1,
|
1,
|
||||||
|
@ -462,6 +467,8 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{bank::Bank, bank_client::BankClient};
|
use crate::{bank::Bank, bank_client::BankClient};
|
||||||
use bincode::serialize;
|
use bincode::serialize;
|
||||||
|
#[allow(deprecated)]
|
||||||
|
use solana_sdk::sysvar::recent_blockhashes::IterItem;
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account::{self, Account, AccountSharedData},
|
account::{self, Account, AccountSharedData},
|
||||||
client::SyncClient,
|
client::SyncClient,
|
||||||
|
@ -475,7 +482,6 @@ mod tests {
|
||||||
recent_blockhashes_account,
|
recent_blockhashes_account,
|
||||||
signature::{Keypair, Signer},
|
signature::{Keypair, Signer},
|
||||||
system_instruction, system_program, sysvar,
|
system_instruction, system_program, sysvar,
|
||||||
sysvar::recent_blockhashes::IterItem,
|
|
||||||
transaction::TransactionError,
|
transaction::TransactionError,
|
||||||
};
|
};
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
@ -507,6 +513,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
fn create_default_recent_blockhashes_account() -> RefCell<AccountSharedData> {
|
fn create_default_recent_blockhashes_account() -> RefCell<AccountSharedData> {
|
||||||
RefCell::new(
|
RefCell::new(
|
||||||
|
#[allow(deprecated)]
|
||||||
recent_blockhashes_account::create_account_with_data_for_test(
|
recent_blockhashes_account::create_account_with_data_for_test(
|
||||||
vec![
|
vec![
|
||||||
IterItem(0u64, &Hash::default(), &FeeCalculator::default());
|
IterItem(0u64, &Hash::default(), &FeeCalculator::default());
|
||||||
|
@ -1456,6 +1463,7 @@ mod tests {
|
||||||
.accounts
|
.accounts
|
||||||
.iter()
|
.iter()
|
||||||
.map(|meta| {
|
.map(|meta| {
|
||||||
|
#[allow(deprecated)]
|
||||||
RefCell::new(if sysvar::recent_blockhashes::check_id(&meta.pubkey) {
|
RefCell::new(if sysvar::recent_blockhashes::check_id(&meta.pubkey) {
|
||||||
create_default_recent_blockhashes_account().into_inner()
|
create_default_recent_blockhashes_account().into_inner()
|
||||||
} else if sysvar::rent::check_id(&meta.pubkey) {
|
} else if sysvar::rent::check_id(&meta.pubkey) {
|
||||||
|
@ -1524,6 +1532,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
KeyedAccount::new(&Pubkey::default(), true, &create_default_account()),
|
KeyedAccount::new(&Pubkey::default(), true, &create_default_account()),
|
||||||
KeyedAccount::new(
|
KeyedAccount::new(
|
||||||
|
#[allow(deprecated)]
|
||||||
&sysvar::recent_blockhashes::id(),
|
&sysvar::recent_blockhashes::id(),
|
||||||
false,
|
false,
|
||||||
&create_default_account(),
|
&create_default_account(),
|
||||||
|
@ -1543,6 +1552,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
KeyedAccount::new(&Pubkey::default(), true, &nonce_acc),
|
KeyedAccount::new(&Pubkey::default(), true, &nonce_acc),
|
||||||
KeyedAccount::new(
|
KeyedAccount::new(
|
||||||
|
#[allow(deprecated)]
|
||||||
&sysvar::recent_blockhashes::id(),
|
&sysvar::recent_blockhashes::id(),
|
||||||
false,
|
false,
|
||||||
&create_default_recent_blockhashes_account(),
|
&create_default_recent_blockhashes_account(),
|
||||||
|
@ -1553,6 +1563,7 @@ mod tests {
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let new_recent_blockhashes_account = RefCell::new(
|
let new_recent_blockhashes_account = RefCell::new(
|
||||||
|
#[allow(deprecated)]
|
||||||
solana_sdk::recent_blockhashes_account::create_account_with_data_for_test(
|
solana_sdk::recent_blockhashes_account::create_account_with_data_for_test(
|
||||||
vec![
|
vec![
|
||||||
IterItem(
|
IterItem(
|
||||||
|
@ -1570,6 +1581,7 @@ mod tests {
|
||||||
&Pubkey::default(),
|
&Pubkey::default(),
|
||||||
vec![
|
vec![
|
||||||
KeyedAccount::new(&Pubkey::default(), true, &nonce_acc,),
|
KeyedAccount::new(&Pubkey::default(), true, &nonce_acc,),
|
||||||
|
#[allow(deprecated)]
|
||||||
KeyedAccount::new(
|
KeyedAccount::new(
|
||||||
&sysvar::recent_blockhashes::id(),
|
&sysvar::recent_blockhashes::id(),
|
||||||
false,
|
false,
|
||||||
|
@ -1632,6 +1644,7 @@ mod tests {
|
||||||
KeyedAccount::new(&Pubkey::default(), true, &create_default_account()),
|
KeyedAccount::new(&Pubkey::default(), true, &create_default_account()),
|
||||||
KeyedAccount::new(&Pubkey::default(), false, &create_default_account()),
|
KeyedAccount::new(&Pubkey::default(), false, &create_default_account()),
|
||||||
KeyedAccount::new(
|
KeyedAccount::new(
|
||||||
|
#[allow(deprecated)]
|
||||||
&sysvar::recent_blockhashes::id(),
|
&sysvar::recent_blockhashes::id(),
|
||||||
false,
|
false,
|
||||||
&create_default_account()
|
&create_default_account()
|
||||||
|
@ -1656,6 +1669,7 @@ mod tests {
|
||||||
),
|
),
|
||||||
KeyedAccount::new(&Pubkey::default(), true, &create_default_account()),
|
KeyedAccount::new(&Pubkey::default(), true, &create_default_account()),
|
||||||
KeyedAccount::new(
|
KeyedAccount::new(
|
||||||
|
#[allow(deprecated)]
|
||||||
&sysvar::recent_blockhashes::id(),
|
&sysvar::recent_blockhashes::id(),
|
||||||
false,
|
false,
|
||||||
&create_default_recent_blockhashes_account(),
|
&create_default_recent_blockhashes_account(),
|
||||||
|
@ -1681,6 +1695,7 @@ mod tests {
|
||||||
),
|
),
|
||||||
KeyedAccount::new(&Pubkey::default(), true, &create_default_account()),
|
KeyedAccount::new(&Pubkey::default(), true, &create_default_account()),
|
||||||
KeyedAccount::new(
|
KeyedAccount::new(
|
||||||
|
#[allow(deprecated)]
|
||||||
&sysvar::recent_blockhashes::id(),
|
&sysvar::recent_blockhashes::id(),
|
||||||
false,
|
false,
|
||||||
&create_default_recent_blockhashes_account(),
|
&create_default_recent_blockhashes_account(),
|
||||||
|
@ -1733,6 +1748,7 @@ mod tests {
|
||||||
&nonce_account::create_account(1_000_000),
|
&nonce_account::create_account(1_000_000),
|
||||||
),
|
),
|
||||||
KeyedAccount::new(
|
KeyedAccount::new(
|
||||||
|
#[allow(deprecated)]
|
||||||
&sysvar::recent_blockhashes::id(),
|
&sysvar::recent_blockhashes::id(),
|
||||||
false,
|
false,
|
||||||
&create_default_account()
|
&create_default_account()
|
||||||
|
@ -1756,6 +1772,7 @@ mod tests {
|
||||||
&nonce_account::create_account(1_000_000),
|
&nonce_account::create_account(1_000_000),
|
||||||
),
|
),
|
||||||
KeyedAccount::new(
|
KeyedAccount::new(
|
||||||
|
#[allow(deprecated)]
|
||||||
&sysvar::recent_blockhashes::id(),
|
&sysvar::recent_blockhashes::id(),
|
||||||
false,
|
false,
|
||||||
&create_default_recent_blockhashes_account(),
|
&create_default_recent_blockhashes_account(),
|
||||||
|
@ -1780,6 +1797,7 @@ mod tests {
|
||||||
&nonce_account::create_account(1_000_000),
|
&nonce_account::create_account(1_000_000),
|
||||||
),
|
),
|
||||||
KeyedAccount::new(
|
KeyedAccount::new(
|
||||||
|
#[allow(deprecated)]
|
||||||
&sysvar::recent_blockhashes::id(),
|
&sysvar::recent_blockhashes::id(),
|
||||||
false,
|
false,
|
||||||
&create_default_recent_blockhashes_account(),
|
&create_default_recent_blockhashes_account(),
|
||||||
|
@ -1800,6 +1818,7 @@ mod tests {
|
||||||
vec![
|
vec![
|
||||||
KeyedAccount::new(&Pubkey::default(), true, &nonce_acc),
|
KeyedAccount::new(&Pubkey::default(), true, &nonce_acc),
|
||||||
KeyedAccount::new(
|
KeyedAccount::new(
|
||||||
|
#[allow(deprecated)]
|
||||||
&sysvar::recent_blockhashes::id(),
|
&sysvar::recent_blockhashes::id(),
|
||||||
false,
|
false,
|
||||||
&create_default_recent_blockhashes_account(),
|
&create_default_recent_blockhashes_account(),
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
|
#[allow(deprecated)]
|
||||||
|
use crate::sysvar::recent_blockhashes;
|
||||||
use crate::{
|
use crate::{
|
||||||
decode_error::DecodeError,
|
decode_error::DecodeError,
|
||||||
instruction::{AccountMeta, Instruction},
|
instruction::{AccountMeta, Instruction},
|
||||||
nonce,
|
nonce,
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
system_program,
|
system_program,
|
||||||
sysvar::{recent_blockhashes, rent},
|
sysvar::rent,
|
||||||
};
|
};
|
||||||
use num_derive::{FromPrimitive, ToPrimitive};
|
use num_derive::{FromPrimitive, ToPrimitive};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
@ -400,6 +402,7 @@ pub fn create_nonce_account_with_seed(
|
||||||
&SystemInstruction::InitializeNonceAccount(*authority),
|
&SystemInstruction::InitializeNonceAccount(*authority),
|
||||||
vec![
|
vec![
|
||||||
AccountMeta::new(*nonce_pubkey, false),
|
AccountMeta::new(*nonce_pubkey, false),
|
||||||
|
#[allow(deprecated)]
|
||||||
AccountMeta::new_readonly(recent_blockhashes::id(), false),
|
AccountMeta::new_readonly(recent_blockhashes::id(), false),
|
||||||
AccountMeta::new_readonly(rent::id(), false),
|
AccountMeta::new_readonly(rent::id(), false),
|
||||||
],
|
],
|
||||||
|
@ -426,6 +429,7 @@ pub fn create_nonce_account(
|
||||||
&SystemInstruction::InitializeNonceAccount(*authority),
|
&SystemInstruction::InitializeNonceAccount(*authority),
|
||||||
vec![
|
vec![
|
||||||
AccountMeta::new(*nonce_pubkey, false),
|
AccountMeta::new(*nonce_pubkey, false),
|
||||||
|
#[allow(deprecated)]
|
||||||
AccountMeta::new_readonly(recent_blockhashes::id(), false),
|
AccountMeta::new_readonly(recent_blockhashes::id(), false),
|
||||||
AccountMeta::new_readonly(rent::id(), false),
|
AccountMeta::new_readonly(rent::id(), false),
|
||||||
],
|
],
|
||||||
|
@ -436,6 +440,7 @@ pub fn create_nonce_account(
|
||||||
pub fn advance_nonce_account(nonce_pubkey: &Pubkey, authorized_pubkey: &Pubkey) -> Instruction {
|
pub fn advance_nonce_account(nonce_pubkey: &Pubkey, authorized_pubkey: &Pubkey) -> Instruction {
|
||||||
let account_metas = vec![
|
let account_metas = vec![
|
||||||
AccountMeta::new(*nonce_pubkey, false),
|
AccountMeta::new(*nonce_pubkey, false),
|
||||||
|
#[allow(deprecated)]
|
||||||
AccountMeta::new_readonly(recent_blockhashes::id(), false),
|
AccountMeta::new_readonly(recent_blockhashes::id(), false),
|
||||||
AccountMeta::new_readonly(*authorized_pubkey, true),
|
AccountMeta::new_readonly(*authorized_pubkey, true),
|
||||||
];
|
];
|
||||||
|
@ -455,6 +460,7 @@ pub fn withdraw_nonce_account(
|
||||||
let account_metas = vec![
|
let account_metas = vec![
|
||||||
AccountMeta::new(*nonce_pubkey, false),
|
AccountMeta::new(*nonce_pubkey, false),
|
||||||
AccountMeta::new(*to_pubkey, false),
|
AccountMeta::new(*to_pubkey, false),
|
||||||
|
#[allow(deprecated)]
|
||||||
AccountMeta::new_readonly(recent_blockhashes::id(), false),
|
AccountMeta::new_readonly(recent_blockhashes::id(), false),
|
||||||
AccountMeta::new_readonly(rent::id(), false),
|
AccountMeta::new_readonly(rent::id(), false),
|
||||||
AccountMeta::new_readonly(*authorized_pubkey, true),
|
AccountMeta::new_readonly(*authorized_pubkey, true),
|
||||||
|
|
|
@ -13,6 +13,7 @@ pub mod slot_hashes;
|
||||||
pub mod slot_history;
|
pub mod slot_history;
|
||||||
pub mod stake_history;
|
pub mod stake_history;
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
pub fn is_sysvar_id(id: &Pubkey) -> bool {
|
pub fn is_sysvar_id(id: &Pubkey) -> bool {
|
||||||
clock::check_id(id)
|
clock::check_id(id)
|
||||||
|| epoch_schedule::check_id(id)
|
|| epoch_schedule::check_id(id)
|
||||||
|
|
|
@ -1,26 +1,38 @@
|
||||||
|
#![allow(deprecated)]
|
||||||
#![allow(clippy::integer_arithmetic)]
|
#![allow(clippy::integer_arithmetic)]
|
||||||
use crate::{
|
use crate::{
|
||||||
declare_sysvar_id,
|
declare_deprecated_sysvar_id,
|
||||||
fee_calculator::FeeCalculator,
|
fee_calculator::FeeCalculator,
|
||||||
hash::{hash, Hash},
|
hash::{hash, Hash},
|
||||||
sysvar::Sysvar,
|
sysvar::Sysvar,
|
||||||
};
|
};
|
||||||
use std::{cmp::Ordering, collections::BinaryHeap, iter::FromIterator, ops::Deref};
|
use std::{cmp::Ordering, collections::BinaryHeap, iter::FromIterator, ops::Deref};
|
||||||
|
|
||||||
|
#[deprecated(
|
||||||
|
since = "1.8.0",
|
||||||
|
note = "Please do not use, will no longer be available in the future"
|
||||||
|
)]
|
||||||
pub const MAX_ENTRIES: usize = 150;
|
pub const MAX_ENTRIES: usize = 150;
|
||||||
|
|
||||||
declare_sysvar_id!(
|
#[deprecated(
|
||||||
|
since = "1.8.0",
|
||||||
|
note = "Please do not use, will no longer be available in the future"
|
||||||
|
)]
|
||||||
|
declare_deprecated_sysvar_id!(
|
||||||
"SysvarRecentB1ockHashes11111111111111111111",
|
"SysvarRecentB1ockHashes11111111111111111111",
|
||||||
RecentBlockhashes
|
RecentBlockhashes
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[deprecated(
|
||||||
|
since = "1.8.0",
|
||||||
|
note = "Please do not use, will no longer be available in the future"
|
||||||
|
)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
|
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
|
||||||
pub struct Entry {
|
pub struct Entry {
|
||||||
pub blockhash: Hash,
|
pub blockhash: Hash,
|
||||||
pub fee_calculator: FeeCalculator,
|
pub fee_calculator: FeeCalculator,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Entry {
|
impl Entry {
|
||||||
pub fn new(blockhash: &Hash, fee_calculator: &FeeCalculator) -> Self {
|
pub fn new(blockhash: &Hash, fee_calculator: &FeeCalculator) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
@ -30,6 +42,10 @@ impl Entry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated(
|
||||||
|
since = "1.8.0",
|
||||||
|
note = "Please do not use, will no longer be available in the future"
|
||||||
|
)]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct IterItem<'a>(pub u64, pub &'a Hash, pub &'a FeeCalculator);
|
pub struct IterItem<'a>(pub u64, pub &'a Hash, pub &'a FeeCalculator);
|
||||||
|
|
||||||
|
@ -57,6 +73,10 @@ impl<'a> PartialOrd for IterItem<'a> {
|
||||||
///
|
///
|
||||||
/// The entries are ordered by descending block height, so the first entry holds
|
/// The entries are ordered by descending block height, so the first entry holds
|
||||||
/// the most recent block hash, and the last entry holds an old block hash.
|
/// the most recent block hash, and the last entry holds an old block hash.
|
||||||
|
#[deprecated(
|
||||||
|
since = "1.8.0",
|
||||||
|
note = "Please do not use, will no longer be available in the future"
|
||||||
|
)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
|
||||||
pub struct RecentBlockhashes(Vec<Entry>);
|
pub struct RecentBlockhashes(Vec<Entry>);
|
||||||
|
|
|
@ -13,10 +13,13 @@ use solana_program::{
|
||||||
nonce::{self, state::Versions, State},
|
nonce::{self, state::Versions, State},
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
system_instruction::NonceError,
|
system_instruction::NonceError,
|
||||||
sysvar::{recent_blockhashes::RecentBlockhashes, rent::Rent},
|
sysvar::rent::Rent,
|
||||||
};
|
};
|
||||||
|
#[allow(deprecated)]
|
||||||
|
use solana_sdk::sysvar::recent_blockhashes::RecentBlockhashes;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
pub trait NonceKeyedAccount {
|
pub trait NonceKeyedAccount {
|
||||||
fn advance_nonce_account(
|
fn advance_nonce_account(
|
||||||
&self,
|
&self,
|
||||||
|
@ -49,6 +52,7 @@ pub trait NonceKeyedAccount {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> NonceKeyedAccount for KeyedAccount<'a> {
|
impl<'a> NonceKeyedAccount for KeyedAccount<'a> {
|
||||||
|
#[allow(deprecated)]
|
||||||
fn advance_nonce_account(
|
fn advance_nonce_account(
|
||||||
&self,
|
&self,
|
||||||
recent_blockhashes: &RecentBlockhashes,
|
recent_blockhashes: &RecentBlockhashes,
|
||||||
|
@ -101,6 +105,7 @@ impl<'a> NonceKeyedAccount for KeyedAccount<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
fn withdraw_nonce_account(
|
fn withdraw_nonce_account(
|
||||||
&self,
|
&self,
|
||||||
lamports: u64,
|
lamports: u64,
|
||||||
|
@ -175,6 +180,7 @@ impl<'a> NonceKeyedAccount for KeyedAccount<'a> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
fn initialize_nonce_account(
|
fn initialize_nonce_account(
|
||||||
&self,
|
&self,
|
||||||
nonce_authority: &Pubkey,
|
nonce_authority: &Pubkey,
|
||||||
|
@ -268,6 +274,8 @@ where
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
#[allow(deprecated)]
|
||||||
|
use crate::sysvar::recent_blockhashes::create_test_recent_blockhashes;
|
||||||
use crate::{
|
use crate::{
|
||||||
account::ReadableAccount,
|
account::ReadableAccount,
|
||||||
account_utils::State as AccountUtilsState,
|
account_utils::State as AccountUtilsState,
|
||||||
|
@ -276,7 +284,6 @@ mod test {
|
||||||
nonce_account::verify_nonce_account,
|
nonce_account::verify_nonce_account,
|
||||||
process_instruction::MockInvokeContext,
|
process_instruction::MockInvokeContext,
|
||||||
system_instruction::NonceError,
|
system_instruction::NonceError,
|
||||||
sysvar::recent_blockhashes::create_test_recent_blockhashes,
|
|
||||||
};
|
};
|
||||||
use solana_program::hash::Hash;
|
use solana_program::hash::Hash;
|
||||||
|
|
||||||
|
@ -304,6 +311,7 @@ mod test {
|
||||||
.convert_to_current();
|
.convert_to_current();
|
||||||
// New is in Uninitialzed state
|
// New is in Uninitialzed state
|
||||||
assert_eq!(state, State::Uninitialized);
|
assert_eq!(state, State::Uninitialized);
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(95);
|
let recent_blockhashes = create_test_recent_blockhashes(95);
|
||||||
let authorized = keyed_account.unsigned_key();
|
let authorized = keyed_account.unsigned_key();
|
||||||
keyed_account
|
keyed_account
|
||||||
|
@ -317,6 +325,7 @@ mod test {
|
||||||
let state = AccountUtilsState::<Versions>::state(keyed_account)
|
let state = AccountUtilsState::<Versions>::state(keyed_account)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.convert_to_current();
|
.convert_to_current();
|
||||||
|
#[allow(deprecated)]
|
||||||
let data = nonce::state::Data {
|
let data = nonce::state::Data {
|
||||||
blockhash: recent_blockhashes[0].blockhash,
|
blockhash: recent_blockhashes[0].blockhash,
|
||||||
fee_calculator: recent_blockhashes[0].fee_calculator.clone(),
|
fee_calculator: recent_blockhashes[0].fee_calculator.clone(),
|
||||||
|
@ -324,6 +333,7 @@ mod test {
|
||||||
};
|
};
|
||||||
// First nonce instruction drives state from Uninitialized to Initialized
|
// First nonce instruction drives state from Uninitialized to Initialized
|
||||||
assert_eq!(state, State::Initialized(data.clone()));
|
assert_eq!(state, State::Initialized(data.clone()));
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(63);
|
let recent_blockhashes = create_test_recent_blockhashes(63);
|
||||||
keyed_account
|
keyed_account
|
||||||
.advance_nonce_account(
|
.advance_nonce_account(
|
||||||
|
@ -335,6 +345,7 @@ mod test {
|
||||||
let state = AccountUtilsState::<Versions>::state(keyed_account)
|
let state = AccountUtilsState::<Versions>::state(keyed_account)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.convert_to_current();
|
.convert_to_current();
|
||||||
|
#[allow(deprecated)]
|
||||||
let data = nonce::state::Data {
|
let data = nonce::state::Data {
|
||||||
blockhash: recent_blockhashes[0].blockhash,
|
blockhash: recent_blockhashes[0].blockhash,
|
||||||
fee_calculator: recent_blockhashes[0].fee_calculator.clone(),
|
fee_calculator: recent_blockhashes[0].fee_calculator.clone(),
|
||||||
|
@ -342,6 +353,7 @@ mod test {
|
||||||
};
|
};
|
||||||
// Second nonce instruction consumes and replaces stored nonce
|
// Second nonce instruction consumes and replaces stored nonce
|
||||||
assert_eq!(state, State::Initialized(data.clone()));
|
assert_eq!(state, State::Initialized(data.clone()));
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(31);
|
let recent_blockhashes = create_test_recent_blockhashes(31);
|
||||||
keyed_account
|
keyed_account
|
||||||
.advance_nonce_account(
|
.advance_nonce_account(
|
||||||
|
@ -353,6 +365,7 @@ mod test {
|
||||||
let state = AccountUtilsState::<Versions>::state(keyed_account)
|
let state = AccountUtilsState::<Versions>::state(keyed_account)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.convert_to_current();
|
.convert_to_current();
|
||||||
|
#[allow(deprecated)]
|
||||||
let data = nonce::state::Data {
|
let data = nonce::state::Data {
|
||||||
blockhash: recent_blockhashes[0].blockhash,
|
blockhash: recent_blockhashes[0].blockhash,
|
||||||
fee_calculator: recent_blockhashes[0].fee_calculator.clone(),
|
fee_calculator: recent_blockhashes[0].fee_calculator.clone(),
|
||||||
|
@ -361,6 +374,7 @@ mod test {
|
||||||
// Third nonce instruction for fun and profit
|
// Third nonce instruction for fun and profit
|
||||||
assert_eq!(state, State::Initialized(data));
|
assert_eq!(state, State::Initialized(data));
|
||||||
with_test_keyed_account(42, false, |to_keyed| {
|
with_test_keyed_account(42, false, |to_keyed| {
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(0);
|
let recent_blockhashes = create_test_recent_blockhashes(0);
|
||||||
let withdraw_lamports = keyed_account.account.borrow().lamports();
|
let withdraw_lamports = keyed_account.account.borrow().lamports();
|
||||||
let expect_nonce_lamports =
|
let expect_nonce_lamports =
|
||||||
|
@ -400,6 +414,7 @@ mod test {
|
||||||
};
|
};
|
||||||
let min_lamports = rent.minimum_balance(State::size());
|
let min_lamports = rent.minimum_balance(State::size());
|
||||||
with_test_keyed_account(min_lamports + 42, true, |nonce_account| {
|
with_test_keyed_account(min_lamports + 42, true, |nonce_account| {
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(31);
|
let recent_blockhashes = create_test_recent_blockhashes(31);
|
||||||
let authority = *nonce_account.unsigned_key();
|
let authority = *nonce_account.unsigned_key();
|
||||||
nonce_account
|
nonce_account
|
||||||
|
@ -415,6 +430,7 @@ mod test {
|
||||||
let state = AccountUtilsState::<Versions>::state(&nonce_account)
|
let state = AccountUtilsState::<Versions>::state(&nonce_account)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.convert_to_current();
|
.convert_to_current();
|
||||||
|
#[allow(deprecated)]
|
||||||
let data = nonce::state::Data {
|
let data = nonce::state::Data {
|
||||||
authority,
|
authority,
|
||||||
blockhash: recent_blockhashes[0].blockhash,
|
blockhash: recent_blockhashes[0].blockhash,
|
||||||
|
@ -422,6 +438,7 @@ mod test {
|
||||||
};
|
};
|
||||||
assert_eq!(state, State::Initialized(data));
|
assert_eq!(state, State::Initialized(data));
|
||||||
let signers = HashSet::new();
|
let signers = HashSet::new();
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(0);
|
let recent_blockhashes = create_test_recent_blockhashes(0);
|
||||||
let result = nonce_account.advance_nonce_account(
|
let result = nonce_account.advance_nonce_account(
|
||||||
&recent_blockhashes,
|
&recent_blockhashes,
|
||||||
|
@ -442,6 +459,7 @@ mod test {
|
||||||
with_test_keyed_account(min_lamports + 42, true, |keyed_account| {
|
with_test_keyed_account(min_lamports + 42, true, |keyed_account| {
|
||||||
let mut signers = HashSet::new();
|
let mut signers = HashSet::new();
|
||||||
signers.insert(*keyed_account.signer_key().unwrap());
|
signers.insert(*keyed_account.signer_key().unwrap());
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(0);
|
let recent_blockhashes = create_test_recent_blockhashes(0);
|
||||||
let authorized = *keyed_account.unsigned_key();
|
let authorized = *keyed_account.unsigned_key();
|
||||||
keyed_account
|
keyed_account
|
||||||
|
@ -472,6 +490,7 @@ mod test {
|
||||||
with_test_keyed_account(min_lamports + 42, true, |keyed_account| {
|
with_test_keyed_account(min_lamports + 42, true, |keyed_account| {
|
||||||
let mut signers = HashSet::new();
|
let mut signers = HashSet::new();
|
||||||
signers.insert(*keyed_account.signer_key().unwrap());
|
signers.insert(*keyed_account.signer_key().unwrap());
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(63);
|
let recent_blockhashes = create_test_recent_blockhashes(63);
|
||||||
let authorized = *keyed_account.unsigned_key();
|
let authorized = *keyed_account.unsigned_key();
|
||||||
keyed_account
|
keyed_account
|
||||||
|
@ -501,6 +520,7 @@ mod test {
|
||||||
with_test_keyed_account(min_lamports + 42, true, |keyed_account| {
|
with_test_keyed_account(min_lamports + 42, true, |keyed_account| {
|
||||||
let mut signers = HashSet::new();
|
let mut signers = HashSet::new();
|
||||||
signers.insert(*keyed_account.signer_key().unwrap());
|
signers.insert(*keyed_account.signer_key().unwrap());
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(63);
|
let recent_blockhashes = create_test_recent_blockhashes(63);
|
||||||
let result = keyed_account.advance_nonce_account(
|
let result = keyed_account.advance_nonce_account(
|
||||||
&recent_blockhashes,
|
&recent_blockhashes,
|
||||||
|
@ -522,6 +542,7 @@ mod test {
|
||||||
with_test_keyed_account(42, true, |nonce_authority| {
|
with_test_keyed_account(42, true, |nonce_authority| {
|
||||||
let mut signers = HashSet::new();
|
let mut signers = HashSet::new();
|
||||||
signers.insert(*nonce_account.signer_key().unwrap());
|
signers.insert(*nonce_account.signer_key().unwrap());
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(63);
|
let recent_blockhashes = create_test_recent_blockhashes(63);
|
||||||
let authorized = *nonce_authority.unsigned_key();
|
let authorized = *nonce_authority.unsigned_key();
|
||||||
nonce_account
|
nonce_account
|
||||||
|
@ -534,6 +555,7 @@ mod test {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let mut signers = HashSet::new();
|
let mut signers = HashSet::new();
|
||||||
signers.insert(*nonce_authority.signer_key().unwrap());
|
signers.insert(*nonce_authority.signer_key().unwrap());
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(31);
|
let recent_blockhashes = create_test_recent_blockhashes(31);
|
||||||
let result = nonce_account.advance_nonce_account(
|
let result = nonce_account.advance_nonce_account(
|
||||||
&recent_blockhashes,
|
&recent_blockhashes,
|
||||||
|
@ -556,6 +578,7 @@ mod test {
|
||||||
with_test_keyed_account(42, false, |nonce_authority| {
|
with_test_keyed_account(42, false, |nonce_authority| {
|
||||||
let mut signers = HashSet::new();
|
let mut signers = HashSet::new();
|
||||||
signers.insert(*nonce_account.signer_key().unwrap());
|
signers.insert(*nonce_account.signer_key().unwrap());
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(63);
|
let recent_blockhashes = create_test_recent_blockhashes(63);
|
||||||
let authorized = *nonce_authority.unsigned_key();
|
let authorized = *nonce_authority.unsigned_key();
|
||||||
nonce_account
|
nonce_account
|
||||||
|
@ -591,6 +614,7 @@ mod test {
|
||||||
with_test_keyed_account(42, false, |to_keyed| {
|
with_test_keyed_account(42, false, |to_keyed| {
|
||||||
let mut signers = HashSet::new();
|
let mut signers = HashSet::new();
|
||||||
signers.insert(*nonce_keyed.signer_key().unwrap());
|
signers.insert(*nonce_keyed.signer_key().unwrap());
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(0);
|
let recent_blockhashes = create_test_recent_blockhashes(0);
|
||||||
let withdraw_lamports = nonce_keyed.account.borrow().lamports();
|
let withdraw_lamports = nonce_keyed.account.borrow().lamports();
|
||||||
let expect_nonce_lamports =
|
let expect_nonce_lamports =
|
||||||
|
@ -637,6 +661,7 @@ mod test {
|
||||||
assert_eq!(state, State::Uninitialized);
|
assert_eq!(state, State::Uninitialized);
|
||||||
with_test_keyed_account(42, false, |to_keyed| {
|
with_test_keyed_account(42, false, |to_keyed| {
|
||||||
let signers = HashSet::new();
|
let signers = HashSet::new();
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(0);
|
let recent_blockhashes = create_test_recent_blockhashes(0);
|
||||||
let lamports = nonce_keyed.account.borrow().lamports();
|
let lamports = nonce_keyed.account.borrow().lamports();
|
||||||
let result = nonce_keyed.withdraw_nonce_account(
|
let result = nonce_keyed.withdraw_nonce_account(
|
||||||
|
@ -667,6 +692,7 @@ mod test {
|
||||||
with_test_keyed_account(42, false, |to_keyed| {
|
with_test_keyed_account(42, false, |to_keyed| {
|
||||||
let mut signers = HashSet::new();
|
let mut signers = HashSet::new();
|
||||||
signers.insert(*nonce_keyed.signer_key().unwrap());
|
signers.insert(*nonce_keyed.signer_key().unwrap());
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(0);
|
let recent_blockhashes = create_test_recent_blockhashes(0);
|
||||||
let lamports = nonce_keyed.account.borrow().lamports() + 1;
|
let lamports = nonce_keyed.account.borrow().lamports() + 1;
|
||||||
let result = nonce_keyed.withdraw_nonce_account(
|
let result = nonce_keyed.withdraw_nonce_account(
|
||||||
|
@ -693,6 +719,7 @@ mod test {
|
||||||
with_test_keyed_account(42, false, |to_keyed| {
|
with_test_keyed_account(42, false, |to_keyed| {
|
||||||
let mut signers = HashSet::new();
|
let mut signers = HashSet::new();
|
||||||
signers.insert(*nonce_keyed.signer_key().unwrap());
|
signers.insert(*nonce_keyed.signer_key().unwrap());
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(0);
|
let recent_blockhashes = create_test_recent_blockhashes(0);
|
||||||
let withdraw_lamports = nonce_keyed.account.borrow().lamports() / 2;
|
let withdraw_lamports = nonce_keyed.account.borrow().lamports() / 2;
|
||||||
let nonce_expect_lamports =
|
let nonce_expect_lamports =
|
||||||
|
@ -754,6 +781,7 @@ mod test {
|
||||||
with_test_keyed_account(min_lamports + 42, true, |nonce_keyed| {
|
with_test_keyed_account(min_lamports + 42, true, |nonce_keyed| {
|
||||||
let mut signers = HashSet::new();
|
let mut signers = HashSet::new();
|
||||||
signers.insert(*nonce_keyed.signer_key().unwrap());
|
signers.insert(*nonce_keyed.signer_key().unwrap());
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(31);
|
let recent_blockhashes = create_test_recent_blockhashes(31);
|
||||||
let authority = *nonce_keyed.unsigned_key();
|
let authority = *nonce_keyed.unsigned_key();
|
||||||
nonce_keyed
|
nonce_keyed
|
||||||
|
@ -767,6 +795,7 @@ mod test {
|
||||||
let state = AccountUtilsState::<Versions>::state(nonce_keyed)
|
let state = AccountUtilsState::<Versions>::state(nonce_keyed)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.convert_to_current();
|
.convert_to_current();
|
||||||
|
#[allow(deprecated)]
|
||||||
let data = nonce::state::Data {
|
let data = nonce::state::Data {
|
||||||
authority,
|
authority,
|
||||||
blockhash: recent_blockhashes[0].blockhash,
|
blockhash: recent_blockhashes[0].blockhash,
|
||||||
|
@ -791,6 +820,7 @@ mod test {
|
||||||
let state = AccountUtilsState::<Versions>::state(nonce_keyed)
|
let state = AccountUtilsState::<Versions>::state(nonce_keyed)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.convert_to_current();
|
.convert_to_current();
|
||||||
|
#[allow(deprecated)]
|
||||||
let data = nonce::state::Data {
|
let data = nonce::state::Data {
|
||||||
blockhash: recent_blockhashes[0].blockhash,
|
blockhash: recent_blockhashes[0].blockhash,
|
||||||
fee_calculator: recent_blockhashes[0].fee_calculator.clone(),
|
fee_calculator: recent_blockhashes[0].fee_calculator.clone(),
|
||||||
|
@ -802,6 +832,7 @@ mod test {
|
||||||
nonce_expect_lamports
|
nonce_expect_lamports
|
||||||
);
|
);
|
||||||
assert_eq!(to_keyed.account.borrow().lamports(), to_expect_lamports);
|
assert_eq!(to_keyed.account.borrow().lamports(), to_expect_lamports);
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(0);
|
let recent_blockhashes = create_test_recent_blockhashes(0);
|
||||||
let withdraw_lamports = nonce_keyed.account.borrow().lamports();
|
let withdraw_lamports = nonce_keyed.account.borrow().lamports();
|
||||||
let nonce_expect_lamports =
|
let nonce_expect_lamports =
|
||||||
|
@ -838,6 +869,7 @@ mod test {
|
||||||
};
|
};
|
||||||
let min_lamports = rent.minimum_balance(State::size());
|
let min_lamports = rent.minimum_balance(State::size());
|
||||||
with_test_keyed_account(min_lamports + 42, true, |nonce_keyed| {
|
with_test_keyed_account(min_lamports + 42, true, |nonce_keyed| {
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(0);
|
let recent_blockhashes = create_test_recent_blockhashes(0);
|
||||||
let authorized = *nonce_keyed.unsigned_key();
|
let authorized = *nonce_keyed.unsigned_key();
|
||||||
nonce_keyed
|
nonce_keyed
|
||||||
|
@ -873,6 +905,7 @@ mod test {
|
||||||
};
|
};
|
||||||
let min_lamports = rent.minimum_balance(State::size());
|
let min_lamports = rent.minimum_balance(State::size());
|
||||||
with_test_keyed_account(min_lamports + 42, true, |nonce_keyed| {
|
with_test_keyed_account(min_lamports + 42, true, |nonce_keyed| {
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(95);
|
let recent_blockhashes = create_test_recent_blockhashes(95);
|
||||||
let authorized = *nonce_keyed.unsigned_key();
|
let authorized = *nonce_keyed.unsigned_key();
|
||||||
nonce_keyed
|
nonce_keyed
|
||||||
|
@ -884,6 +917,7 @@ mod test {
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
with_test_keyed_account(42, false, |to_keyed| {
|
with_test_keyed_account(42, false, |to_keyed| {
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(63);
|
let recent_blockhashes = create_test_recent_blockhashes(63);
|
||||||
let mut signers = HashSet::new();
|
let mut signers = HashSet::new();
|
||||||
signers.insert(*nonce_keyed.signer_key().unwrap());
|
signers.insert(*nonce_keyed.signer_key().unwrap());
|
||||||
|
@ -909,6 +943,7 @@ mod test {
|
||||||
};
|
};
|
||||||
let min_lamports = rent.minimum_balance(State::size());
|
let min_lamports = rent.minimum_balance(State::size());
|
||||||
with_test_keyed_account(min_lamports + 42, true, |nonce_keyed| {
|
with_test_keyed_account(min_lamports + 42, true, |nonce_keyed| {
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(95);
|
let recent_blockhashes = create_test_recent_blockhashes(95);
|
||||||
let authorized = *nonce_keyed.unsigned_key();
|
let authorized = *nonce_keyed.unsigned_key();
|
||||||
nonce_keyed
|
nonce_keyed
|
||||||
|
@ -920,6 +955,7 @@ mod test {
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
with_test_keyed_account(42, false, |to_keyed| {
|
with_test_keyed_account(42, false, |to_keyed| {
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(63);
|
let recent_blockhashes = create_test_recent_blockhashes(63);
|
||||||
let mut signers = HashSet::new();
|
let mut signers = HashSet::new();
|
||||||
signers.insert(*nonce_keyed.signer_key().unwrap());
|
signers.insert(*nonce_keyed.signer_key().unwrap());
|
||||||
|
@ -945,6 +981,7 @@ mod test {
|
||||||
};
|
};
|
||||||
let min_lamports = rent.minimum_balance(State::size());
|
let min_lamports = rent.minimum_balance(State::size());
|
||||||
with_test_keyed_account(min_lamports + 42, true, |nonce_keyed| {
|
with_test_keyed_account(min_lamports + 42, true, |nonce_keyed| {
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(95);
|
let recent_blockhashes = create_test_recent_blockhashes(95);
|
||||||
let authorized = *nonce_keyed.unsigned_key();
|
let authorized = *nonce_keyed.unsigned_key();
|
||||||
nonce_keyed
|
nonce_keyed
|
||||||
|
@ -956,6 +993,7 @@ mod test {
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
with_test_keyed_account(55, false, |to_keyed| {
|
with_test_keyed_account(55, false, |to_keyed| {
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(63);
|
let recent_blockhashes = create_test_recent_blockhashes(63);
|
||||||
let mut signers = HashSet::new();
|
let mut signers = HashSet::new();
|
||||||
signers.insert(*nonce_keyed.signer_key().unwrap());
|
signers.insert(*nonce_keyed.signer_key().unwrap());
|
||||||
|
@ -987,6 +1025,7 @@ mod test {
|
||||||
assert_eq!(state, State::Uninitialized);
|
assert_eq!(state, State::Uninitialized);
|
||||||
let mut signers = HashSet::new();
|
let mut signers = HashSet::new();
|
||||||
signers.insert(*keyed_account.signer_key().unwrap());
|
signers.insert(*keyed_account.signer_key().unwrap());
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(0);
|
let recent_blockhashes = create_test_recent_blockhashes(0);
|
||||||
let authority = *keyed_account.unsigned_key();
|
let authority = *keyed_account.unsigned_key();
|
||||||
let result = keyed_account.initialize_nonce_account(
|
let result = keyed_account.initialize_nonce_account(
|
||||||
|
@ -995,6 +1034,7 @@ mod test {
|
||||||
&rent,
|
&rent,
|
||||||
&MockInvokeContext::new(vec![]),
|
&MockInvokeContext::new(vec![]),
|
||||||
);
|
);
|
||||||
|
#[allow(deprecated)]
|
||||||
let data = nonce::state::Data {
|
let data = nonce::state::Data {
|
||||||
authority,
|
authority,
|
||||||
blockhash: recent_blockhashes[0].blockhash,
|
blockhash: recent_blockhashes[0].blockhash,
|
||||||
|
@ -1038,6 +1078,7 @@ mod test {
|
||||||
};
|
};
|
||||||
let min_lamports = rent.minimum_balance(State::size());
|
let min_lamports = rent.minimum_balance(State::size());
|
||||||
with_test_keyed_account(min_lamports + 42, true, |keyed_account| {
|
with_test_keyed_account(min_lamports + 42, true, |keyed_account| {
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(31);
|
let recent_blockhashes = create_test_recent_blockhashes(31);
|
||||||
let authorized = *keyed_account.unsigned_key();
|
let authorized = *keyed_account.unsigned_key();
|
||||||
keyed_account
|
keyed_account
|
||||||
|
@ -1048,6 +1089,7 @@ mod test {
|
||||||
&MockInvokeContext::new(vec![]),
|
&MockInvokeContext::new(vec![]),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(0);
|
let recent_blockhashes = create_test_recent_blockhashes(0);
|
||||||
let result = keyed_account.initialize_nonce_account(
|
let result = keyed_account.initialize_nonce_account(
|
||||||
&authorized,
|
&authorized,
|
||||||
|
@ -1067,6 +1109,7 @@ mod test {
|
||||||
};
|
};
|
||||||
let min_lamports = rent.minimum_balance(State::size());
|
let min_lamports = rent.minimum_balance(State::size());
|
||||||
with_test_keyed_account(min_lamports - 42, true, |keyed_account| {
|
with_test_keyed_account(min_lamports - 42, true, |keyed_account| {
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(63);
|
let recent_blockhashes = create_test_recent_blockhashes(63);
|
||||||
let authorized = *keyed_account.unsigned_key();
|
let authorized = *keyed_account.unsigned_key();
|
||||||
let result = keyed_account.initialize_nonce_account(
|
let result = keyed_account.initialize_nonce_account(
|
||||||
|
@ -1089,6 +1132,7 @@ mod test {
|
||||||
with_test_keyed_account(min_lamports + 42, true, |nonce_account| {
|
with_test_keyed_account(min_lamports + 42, true, |nonce_account| {
|
||||||
let mut signers = HashSet::new();
|
let mut signers = HashSet::new();
|
||||||
signers.insert(*nonce_account.signer_key().unwrap());
|
signers.insert(*nonce_account.signer_key().unwrap());
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(31);
|
let recent_blockhashes = create_test_recent_blockhashes(31);
|
||||||
let authorized = *nonce_account.unsigned_key();
|
let authorized = *nonce_account.unsigned_key();
|
||||||
nonce_account
|
nonce_account
|
||||||
|
@ -1100,6 +1144,7 @@ mod test {
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let authority = Pubkey::default();
|
let authority = Pubkey::default();
|
||||||
|
#[allow(deprecated)]
|
||||||
let data = nonce::state::Data {
|
let data = nonce::state::Data {
|
||||||
authority,
|
authority,
|
||||||
blockhash: recent_blockhashes[0].blockhash,
|
blockhash: recent_blockhashes[0].blockhash,
|
||||||
|
@ -1147,6 +1192,7 @@ mod test {
|
||||||
with_test_keyed_account(min_lamports + 42, true, |nonce_account| {
|
with_test_keyed_account(min_lamports + 42, true, |nonce_account| {
|
||||||
let mut signers = HashSet::new();
|
let mut signers = HashSet::new();
|
||||||
signers.insert(*nonce_account.signer_key().unwrap());
|
signers.insert(*nonce_account.signer_key().unwrap());
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(31);
|
let recent_blockhashes = create_test_recent_blockhashes(31);
|
||||||
let authorized = &Pubkey::default().clone();
|
let authorized = &Pubkey::default().clone();
|
||||||
nonce_account
|
nonce_account
|
||||||
|
@ -1174,6 +1220,7 @@ mod test {
|
||||||
let state: State = nonce_account.state().unwrap();
|
let state: State = nonce_account.state().unwrap();
|
||||||
// New is in Uninitialzed state
|
// New is in Uninitialzed state
|
||||||
assert_eq!(state, State::Uninitialized);
|
assert_eq!(state, State::Uninitialized);
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(0);
|
let recent_blockhashes = create_test_recent_blockhashes(0);
|
||||||
let authorized = nonce_account.unsigned_key();
|
let authorized = nonce_account.unsigned_key();
|
||||||
nonce_account
|
nonce_account
|
||||||
|
@ -1186,6 +1233,7 @@ mod test {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert!(verify_nonce_account(
|
assert!(verify_nonce_account(
|
||||||
&nonce_account.account.borrow(),
|
&nonce_account.account.borrow(),
|
||||||
|
#[allow(deprecated)]
|
||||||
&recent_blockhashes[0].blockhash,
|
&recent_blockhashes[0].blockhash,
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
@ -1209,6 +1257,7 @@ mod test {
|
||||||
let state: State = nonce_account.state().unwrap();
|
let state: State = nonce_account.state().unwrap();
|
||||||
// New is in Uninitialzed state
|
// New is in Uninitialzed state
|
||||||
assert_eq!(state, State::Uninitialized);
|
assert_eq!(state, State::Uninitialized);
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes = create_test_recent_blockhashes(0);
|
let recent_blockhashes = create_test_recent_blockhashes(0);
|
||||||
let authorized = nonce_account.unsigned_key();
|
let authorized = nonce_account.unsigned_key();
|
||||||
nonce_account
|
nonce_account
|
||||||
|
@ -1221,6 +1270,7 @@ mod test {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert!(!verify_nonce_account(
|
assert!(!verify_nonce_account(
|
||||||
&nonce_account.account.borrow(),
|
&nonce_account.account.borrow(),
|
||||||
|
#[allow(deprecated)]
|
||||||
&recent_blockhashes[1].blockhash,
|
&recent_blockhashes[1].blockhash,
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,11 +3,17 @@ use crate::account::{
|
||||||
InheritableAccountFields, DUMMY_INHERITABLE_ACCOUNT_FIELDS,
|
InheritableAccountFields, DUMMY_INHERITABLE_ACCOUNT_FIELDS,
|
||||||
};
|
};
|
||||||
use crate::clock::INITIAL_RENT_EPOCH;
|
use crate::clock::INITIAL_RENT_EPOCH;
|
||||||
|
#[allow(deprecated)]
|
||||||
use solana_program::sysvar::recent_blockhashes::{
|
use solana_program::sysvar::recent_blockhashes::{
|
||||||
IntoIterSorted, IterItem, RecentBlockhashes, MAX_ENTRIES,
|
IntoIterSorted, IterItem, RecentBlockhashes, MAX_ENTRIES,
|
||||||
};
|
};
|
||||||
use std::{collections::BinaryHeap, iter::FromIterator};
|
use std::{collections::BinaryHeap, iter::FromIterator};
|
||||||
|
|
||||||
|
#[deprecated(
|
||||||
|
since = "1.8.0",
|
||||||
|
note = "Please do not use, will no longer be available in the future"
|
||||||
|
)]
|
||||||
|
#[allow(deprecated)]
|
||||||
pub fn update_account<'a, I>(
|
pub fn update_account<'a, I>(
|
||||||
account: &mut AccountSharedData,
|
account: &mut AccountSharedData,
|
||||||
recent_blockhash_iter: I,
|
recent_blockhash_iter: I,
|
||||||
|
@ -16,8 +22,11 @@ where
|
||||||
I: IntoIterator<Item = IterItem<'a>>,
|
I: IntoIterator<Item = IterItem<'a>>,
|
||||||
{
|
{
|
||||||
let sorted = BinaryHeap::from_iter(recent_blockhash_iter);
|
let sorted = BinaryHeap::from_iter(recent_blockhash_iter);
|
||||||
|
#[allow(deprecated)]
|
||||||
let sorted_iter = IntoIterSorted::new(sorted);
|
let sorted_iter = IntoIterSorted::new(sorted);
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhash_iter = sorted_iter.take(MAX_ENTRIES);
|
let recent_blockhash_iter = sorted_iter.take(MAX_ENTRIES);
|
||||||
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes: RecentBlockhashes = recent_blockhash_iter.collect();
|
let recent_blockhashes: RecentBlockhashes = recent_blockhash_iter.collect();
|
||||||
to_account(&recent_blockhashes, account)
|
to_account(&recent_blockhashes, account)
|
||||||
}
|
}
|
||||||
|
@ -26,13 +35,20 @@ where
|
||||||
since = "1.5.17",
|
since = "1.5.17",
|
||||||
note = "Please use `create_account_with_data_for_test` instead"
|
note = "Please use `create_account_with_data_for_test` instead"
|
||||||
)]
|
)]
|
||||||
|
#[allow(deprecated)]
|
||||||
pub fn create_account_with_data<'a, I>(lamports: u64, recent_blockhash_iter: I) -> AccountSharedData
|
pub fn create_account_with_data<'a, I>(lamports: u64, recent_blockhash_iter: I) -> AccountSharedData
|
||||||
where
|
where
|
||||||
I: IntoIterator<Item = IterItem<'a>>,
|
I: IntoIterator<Item = IterItem<'a>>,
|
||||||
{
|
{
|
||||||
|
#[allow(deprecated)]
|
||||||
create_account_with_data_and_fields(recent_blockhash_iter, (lamports, INITIAL_RENT_EPOCH))
|
create_account_with_data_and_fields(recent_blockhash_iter, (lamports, INITIAL_RENT_EPOCH))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated(
|
||||||
|
since = "1.8.0",
|
||||||
|
note = "Please do not use, will no longer be available in the future"
|
||||||
|
)]
|
||||||
|
#[allow(deprecated)]
|
||||||
pub fn create_account_with_data_and_fields<'a, I>(
|
pub fn create_account_with_data_and_fields<'a, I>(
|
||||||
recent_blockhash_iter: I,
|
recent_blockhash_iter: I,
|
||||||
fields: InheritableAccountFields,
|
fields: InheritableAccountFields,
|
||||||
|
@ -48,6 +64,11 @@ where
|
||||||
account
|
account
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated(
|
||||||
|
since = "1.8.0",
|
||||||
|
note = "Please do not use, will no longer be available in the future"
|
||||||
|
)]
|
||||||
|
#[allow(deprecated)]
|
||||||
pub fn create_account_with_data_for_test<'a, I>(recent_blockhash_iter: I) -> AccountSharedData
|
pub fn create_account_with_data_for_test<'a, I>(recent_blockhash_iter: I) -> AccountSharedData
|
||||||
where
|
where
|
||||||
I: IntoIterator<Item = IterItem<'a>>,
|
I: IntoIterator<Item = IterItem<'a>>,
|
||||||
|
@ -57,6 +78,7 @@ where
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
#![allow(deprecated)]
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::account::from_account;
|
use crate::account::from_account;
|
||||||
use rand::{seq::SliceRandom, thread_rng};
|
use rand::{seq::SliceRandom, thread_rng};
|
||||||
|
|
Loading…
Reference in New Issue