deprecate fees sysvar (#18960)
This commit is contained in:
parent
da480bdb5f
commit
dfbb0c559b
|
@ -5,7 +5,7 @@ use crate::{
|
||||||
use bincode::deserialize;
|
use bincode::deserialize;
|
||||||
use bv::BitVec;
|
use bv::BitVec;
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
use solana_sdk::sysvar::recent_blockhashes::RecentBlockhashes;
|
use solana_sdk::sysvar::{fees::Fees, 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,
|
||||||
|
@ -14,7 +14,7 @@ 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, rewards::Rewards},
|
sysvar::{self, rewards::Rewards},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn parse_sysvar(data: &[u8], pubkey: &Pubkey) -> Result<SysvarAccountType, ParseAccountError> {
|
pub fn parse_sysvar(data: &[u8], pubkey: &Pubkey) -> Result<SysvarAccountType, ParseAccountError> {
|
||||||
|
@ -94,7 +94,9 @@ pub fn parse_sysvar(data: &[u8], pubkey: &Pubkey) -> Result<SysvarAccountType, P
|
||||||
pub enum SysvarAccountType {
|
pub enum SysvarAccountType {
|
||||||
Clock(UiClock),
|
Clock(UiClock),
|
||||||
EpochSchedule(EpochSchedule),
|
EpochSchedule(EpochSchedule),
|
||||||
|
#[allow(deprecated)]
|
||||||
Fees(UiFees),
|
Fees(UiFees),
|
||||||
|
#[allow(deprecated)]
|
||||||
RecentBlockhashes(Vec<UiRecentBlockhashesEntry>),
|
RecentBlockhashes(Vec<UiRecentBlockhashesEntry>),
|
||||||
Rent(UiRent),
|
Rent(UiRent),
|
||||||
Rewards(UiRewards),
|
Rewards(UiRewards),
|
||||||
|
@ -130,6 +132,7 @@ impl From<Clock> for UiClock {
|
||||||
pub struct UiFees {
|
pub struct UiFees {
|
||||||
pub fee_calculator: UiFeeCalculator,
|
pub fee_calculator: UiFeeCalculator,
|
||||||
}
|
}
|
||||||
|
#[allow(deprecated)]
|
||||||
impl From<Fees> for UiFees {
|
impl From<Fees> for UiFees {
|
||||||
fn from(fees: Fees) -> Self {
|
fn from(fees: Fees) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
@ -222,6 +225,8 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_sysvars() {
|
fn test_parse_sysvars() {
|
||||||
|
let hash = Hash::new(&[1; 32]);
|
||||||
|
|
||||||
let clock_sysvar = create_account_for_test(&Clock::default());
|
let clock_sysvar = create_account_for_test(&Clock::default());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_sysvar(&clock_sysvar.data, &sysvar::clock::id()).unwrap(),
|
parse_sysvar(&clock_sysvar.data, &sysvar::clock::id()).unwrap(),
|
||||||
|
@ -241,33 +246,33 @@ mod test {
|
||||||
SysvarAccountType::EpochSchedule(epoch_schedule),
|
SysvarAccountType::EpochSchedule(epoch_schedule),
|
||||||
);
|
);
|
||||||
|
|
||||||
let fees_sysvar = create_account_for_test(&Fees::default());
|
|
||||||
assert_eq!(
|
|
||||||
parse_sysvar(&fees_sysvar.data, &sysvar::fees::id()).unwrap(),
|
|
||||||
SysvarAccountType::Fees(UiFees::default()),
|
|
||||||
);
|
|
||||||
|
|
||||||
let hash = Hash::new(&[1; 32]);
|
|
||||||
let fee_calculator = FeeCalculator {
|
|
||||||
lamports_per_signature: 10,
|
|
||||||
};
|
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
let recent_blockhashes: RecentBlockhashes = vec![IterItem(0, &hash, &fee_calculator)]
|
{
|
||||||
.into_iter()
|
let fees_sysvar = create_account_for_test(&Fees::default());
|
||||||
.collect();
|
assert_eq!(
|
||||||
let recent_blockhashes_sysvar = create_account_for_test(&recent_blockhashes);
|
parse_sysvar(&fees_sysvar.data, &sysvar::fees::id()).unwrap(),
|
||||||
assert_eq!(
|
SysvarAccountType::Fees(UiFees::default()),
|
||||||
parse_sysvar(
|
);
|
||||||
&recent_blockhashes_sysvar.data,
|
|
||||||
#[allow(deprecated)]
|
let fee_calculator = FeeCalculator {
|
||||||
&sysvar::recent_blockhashes::id()
|
lamports_per_signature: 10,
|
||||||
)
|
};
|
||||||
.unwrap(),
|
let recent_blockhashes: RecentBlockhashes = vec![IterItem(0, &hash, &fee_calculator)]
|
||||||
SysvarAccountType::RecentBlockhashes(vec![UiRecentBlockhashesEntry {
|
.into_iter()
|
||||||
blockhash: hash.to_string(),
|
.collect();
|
||||||
fee_calculator: fee_calculator.into(),
|
let recent_blockhashes_sysvar = create_account_for_test(&recent_blockhashes);
|
||||||
}]),
|
assert_eq!(
|
||||||
);
|
parse_sysvar(
|
||||||
|
&recent_blockhashes_sysvar.data,
|
||||||
|
&sysvar::recent_blockhashes::id()
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
|
SysvarAccountType::RecentBlockhashes(vec![UiRecentBlockhashesEntry {
|
||||||
|
blockhash: hash.to_string(),
|
||||||
|
fee_calculator: fee_calculator.into(),
|
||||||
|
}]),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let rent = Rent {
|
let rent = Rent {
|
||||||
lamports_per_byte_year: 10,
|
lamports_per_byte_year: 10,
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
//! The solana-program-test provides a BanksClient-based test framework BPF programs
|
//! The solana-program-test provides a BanksClient-based test framework BPF programs
|
||||||
#![allow(clippy::integer_arithmetic)]
|
#![allow(clippy::integer_arithmetic)]
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
|
use solana_sdk::sysvar::fees::Fees;
|
||||||
use {
|
use {
|
||||||
async_trait::async_trait,
|
async_trait::async_trait,
|
||||||
chrono_humanize::{Accuracy, HumanTime, Tense},
|
chrono_humanize::{Accuracy, HumanTime, Tense},
|
||||||
|
@ -34,7 +36,7 @@ use {
|
||||||
signature::{Keypair, Signer},
|
signature::{Keypair, Signer},
|
||||||
sysvar::{
|
sysvar::{
|
||||||
clock, epoch_schedule,
|
clock, epoch_schedule,
|
||||||
fees::{self, Fees},
|
fees::{self},
|
||||||
rent, Sysvar,
|
rent, Sysvar,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -377,6 +379,7 @@ impl solana_sdk::program_stubs::SyscallStubs for SyscallStubs {
|
||||||
get_sysvar::<EpochSchedule>(&epoch_schedule::id(), var_addr)
|
get_sysvar::<EpochSchedule>(&epoch_schedule::id(), var_addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
fn sol_get_fees_sysvar(&self, var_addr: *mut u8) -> u64 {
|
fn sol_get_fees_sysvar(&self, var_addr: *mut u8) -> u64 {
|
||||||
get_sysvar::<Fees>(&fees::id(), var_addr)
|
get_sysvar::<Fees>(&fees::id(), var_addr)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,11 @@
|
||||||
|
#[allow(deprecated)]
|
||||||
|
use solana_sdk::sysvar::fees::Fees;
|
||||||
use {
|
use {
|
||||||
solana_program_test::{processor, ProgramTest},
|
solana_program_test::{processor, ProgramTest},
|
||||||
solana_sdk::{
|
solana_sdk::{
|
||||||
account_info::AccountInfo,
|
account_info::AccountInfo, clock::Clock, entrypoint::ProgramResult,
|
||||||
clock::Clock,
|
epoch_schedule::EpochSchedule, fee_calculator::FeeCalculator, instruction::Instruction,
|
||||||
entrypoint::ProgramResult,
|
msg, pubkey::Pubkey, rent::Rent, signature::Signer, sysvar::Sysvar,
|
||||||
epoch_schedule::EpochSchedule,
|
|
||||||
fee_calculator::FeeCalculator,
|
|
||||||
instruction::Instruction,
|
|
||||||
msg,
|
|
||||||
pubkey::Pubkey,
|
|
||||||
rent::Rent,
|
|
||||||
signature::Signer,
|
|
||||||
sysvar::{fees::Fees, Sysvar},
|
|
||||||
transaction::Transaction,
|
transaction::Transaction,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -30,13 +24,16 @@ fn sysvar_getter_process_instruction(
|
||||||
let epoch_schedule = EpochSchedule::get()?;
|
let epoch_schedule = EpochSchedule::get()?;
|
||||||
assert_eq!(epoch_schedule, EpochSchedule::default());
|
assert_eq!(epoch_schedule, EpochSchedule::default());
|
||||||
|
|
||||||
let fees = Fees::get()?;
|
#[allow(deprecated)]
|
||||||
assert_eq!(
|
{
|
||||||
fees.fee_calculator,
|
let fees = Fees::get()?;
|
||||||
FeeCalculator {
|
assert_eq!(
|
||||||
lamports_per_signature: 5000
|
fees.fee_calculator,
|
||||||
}
|
FeeCalculator {
|
||||||
);
|
lamports_per_signature: 5000
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let rent = Rent::get()?;
|
let rent = Rent::get()?;
|
||||||
assert_eq!(rent, Rent::default());
|
assert_eq!(rent, Rent::default());
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
extern crate solana_program;
|
extern crate solana_program;
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
use solana_program::sysvar::recent_blockhashes::RecentBlockhashes;
|
use solana_program::sysvar::{fees::Fees, recent_blockhashes::RecentBlockhashes};
|
||||||
use solana_program::{
|
use solana_program::{
|
||||||
account_info::AccountInfo,
|
account_info::AccountInfo,
|
||||||
entrypoint,
|
entrypoint,
|
||||||
|
@ -12,7 +12,7 @@ use solana_program::{
|
||||||
program_error::ProgramError,
|
program_error::ProgramError,
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
sysvar::{
|
sysvar::{
|
||||||
self, clock::Clock, epoch_schedule::EpochSchedule, fees::Fees, instructions, rent::Rent,
|
self, clock::Clock, epoch_schedule::EpochSchedule, instructions, rent::Rent,
|
||||||
slot_hashes::SlotHashes, slot_history::SlotHistory, stake_history::StakeHistory, Sysvar,
|
slot_hashes::SlotHashes, slot_history::SlotHistory, stake_history::StakeHistory, Sysvar,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -45,6 +45,7 @@ pub fn process_instruction(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fees
|
// Fees
|
||||||
|
#[allow(deprecated)]
|
||||||
{
|
{
|
||||||
msg!("Fees identifier:");
|
msg!("Fees identifier:");
|
||||||
sysvar::fees::id().log();
|
sysvar::fees::id().log();
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
use solana_bpf_rust_sysvar::process_instruction;
|
use solana_bpf_rust_sysvar::process_instruction;
|
||||||
use solana_program_test::*;
|
use solana_program_test::*;
|
||||||
|
use solana_sdk::sysvar::{fees, recent_blockhashes};
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
instruction::{AccountMeta, Instruction},
|
instruction::{AccountMeta, Instruction},
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
signature::Signer,
|
signature::Signer,
|
||||||
sysvar::{
|
sysvar::{clock, epoch_schedule, instructions, rent, slot_hashes, slot_history, stake_history},
|
||||||
clock, epoch_schedule, fees, instructions, recent_blockhashes, rent, slot_hashes,
|
|
||||||
slot_history, stake_history,
|
|
||||||
},
|
|
||||||
transaction::Transaction,
|
transaction::Transaction,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -30,8 +28,10 @@ async fn test_sysvars() {
|
||||||
AccountMeta::new(Pubkey::new_unique(), false),
|
AccountMeta::new(Pubkey::new_unique(), false),
|
||||||
AccountMeta::new_readonly(clock::id(), false),
|
AccountMeta::new_readonly(clock::id(), false),
|
||||||
AccountMeta::new_readonly(epoch_schedule::id(), false),
|
AccountMeta::new_readonly(epoch_schedule::id(), false),
|
||||||
|
#[allow(deprecated)]
|
||||||
AccountMeta::new_readonly(fees::id(), false),
|
AccountMeta::new_readonly(fees::id(), false),
|
||||||
AccountMeta::new_readonly(instructions::id(), false),
|
AccountMeta::new_readonly(instructions::id(), 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(slot_hashes::id(), false),
|
AccountMeta::new_readonly(slot_hashes::id(), false),
|
||||||
|
|
|
@ -2,12 +2,8 @@
|
||||||
|
|
||||||
extern crate solana_program;
|
extern crate solana_program;
|
||||||
use solana_program::{
|
use solana_program::{
|
||||||
account_info::AccountInfo,
|
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, msg, pubkey::Pubkey,
|
||||||
entrypoint,
|
sysvar::clock,
|
||||||
entrypoint::ProgramResult,
|
|
||||||
msg,
|
|
||||||
pubkey::Pubkey,
|
|
||||||
sysvar::{clock, fees},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
entrypoint!(process_instruction);
|
entrypoint!(process_instruction);
|
||||||
|
@ -17,9 +13,8 @@ fn process_instruction(
|
||||||
_instruction_data: &[u8],
|
_instruction_data: &[u8],
|
||||||
) -> ProgramResult {
|
) -> ProgramResult {
|
||||||
msg!("Upgradeable program");
|
msg!("Upgradeable program");
|
||||||
assert_eq!(accounts.len(), 3);
|
assert_eq!(accounts.len(), 2);
|
||||||
assert_eq!(accounts[0].key, program_id);
|
assert_eq!(accounts[0].key, program_id);
|
||||||
assert_eq!(*accounts[1].key, clock::id());
|
assert_eq!(*accounts[1].key, clock::id());
|
||||||
assert_eq!(*accounts[2].key, fees::id());
|
|
||||||
Err(42.into())
|
Err(42.into())
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,8 @@
|
||||||
|
|
||||||
extern crate solana_program;
|
extern crate solana_program;
|
||||||
use solana_program::{
|
use solana_program::{
|
||||||
account_info::AccountInfo,
|
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, msg, pubkey::Pubkey,
|
||||||
entrypoint,
|
sysvar::clock,
|
||||||
entrypoint::ProgramResult,
|
|
||||||
msg,
|
|
||||||
pubkey::Pubkey,
|
|
||||||
sysvar::{clock, fees},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
entrypoint!(process_instruction);
|
entrypoint!(process_instruction);
|
||||||
|
@ -17,9 +13,8 @@ fn process_instruction(
|
||||||
_instruction_data: &[u8],
|
_instruction_data: &[u8],
|
||||||
) -> ProgramResult {
|
) -> ProgramResult {
|
||||||
msg!("Upgraded program");
|
msg!("Upgraded program");
|
||||||
assert_eq!(accounts.len(), 3);
|
assert_eq!(accounts.len(), 2);
|
||||||
assert_eq!(accounts[0].key, program_id);
|
assert_eq!(accounts[0].key, program_id);
|
||||||
assert_eq!(*accounts[1].key, clock::id());
|
assert_eq!(*accounts[1].key, clock::id());
|
||||||
assert_eq!(*accounts[2].key, fees::id());
|
|
||||||
Err(43.into())
|
Err(43.into())
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ use solana_sdk::{
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
signature::{keypair_from_seed, Keypair, Signer},
|
signature::{keypair_from_seed, Keypair, Signer},
|
||||||
system_instruction,
|
system_instruction,
|
||||||
sysvar::{clock, fees, rent},
|
sysvar::{clock, rent},
|
||||||
transaction::{Transaction, TransactionError},
|
transaction::{Transaction, TransactionError},
|
||||||
};
|
};
|
||||||
use solana_transaction_status::{
|
use solana_transaction_status::{
|
||||||
|
@ -1258,11 +1258,8 @@ fn test_program_bpf_call_depth() {
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
|
|
||||||
let instruction = Instruction::new_with_bincode(
|
let instruction =
|
||||||
program_id,
|
Instruction::new_with_bincode(program_id, &ComputeBudget::default().max_call_depth, vec![]);
|
||||||
&ComputeBudget::default().max_call_depth,
|
|
||||||
vec![],
|
|
||||||
);
|
|
||||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
}
|
}
|
||||||
|
@ -1701,7 +1698,6 @@ fn test_program_bpf_upgrade() {
|
||||||
vec![
|
vec![
|
||||||
AccountMeta::new(program_id.clone(), false),
|
AccountMeta::new(program_id.clone(), false),
|
||||||
AccountMeta::new(clock::id(), false),
|
AccountMeta::new(clock::id(), false),
|
||||||
AccountMeta::new(fees::id(), false),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1797,7 +1793,6 @@ fn test_program_bpf_upgrade_and_invoke_in_same_tx() {
|
||||||
vec![
|
vec![
|
||||||
AccountMeta::new(program_id.clone(), false),
|
AccountMeta::new(program_id.clone(), false),
|
||||||
AccountMeta::new(clock::id(), false),
|
AccountMeta::new(clock::id(), false),
|
||||||
AccountMeta::new(fees::id(), false),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1886,7 +1881,6 @@ fn test_program_bpf_invoke_upgradeable_via_cpi() {
|
||||||
AccountMeta::new(program_id, false),
|
AccountMeta::new(program_id, false),
|
||||||
AccountMeta::new(program_id, false),
|
AccountMeta::new(program_id, false),
|
||||||
AccountMeta::new(clock::id(), false),
|
AccountMeta::new(clock::id(), false),
|
||||||
AccountMeta::new(fees::id(), false),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -2077,7 +2071,6 @@ fn test_program_bpf_upgrade_via_cpi() {
|
||||||
AccountMeta::new(program_id, false),
|
AccountMeta::new(program_id, false),
|
||||||
AccountMeta::new(program_id, false),
|
AccountMeta::new(program_id, false),
|
||||||
AccountMeta::new(clock::id(), false),
|
AccountMeta::new(clock::id(), false),
|
||||||
AccountMeta::new(fees::id(), false),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -2182,7 +2175,6 @@ fn test_program_bpf_upgrade_self_via_cpi() {
|
||||||
AccountMeta::new(noop_program_id, false),
|
AccountMeta::new(noop_program_id, false),
|
||||||
AccountMeta::new(noop_program_id, false),
|
AccountMeta::new(noop_program_id, false),
|
||||||
AccountMeta::new(clock::id(), false),
|
AccountMeta::new(clock::id(), false),
|
||||||
AccountMeta::new(fees::id(), false),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@ use solana_rbpf::{
|
||||||
vm::{EbpfVm, SyscallObject, SyscallRegistry},
|
vm::{EbpfVm, SyscallObject, SyscallRegistry},
|
||||||
};
|
};
|
||||||
use solana_runtime::message_processor::MessageProcessor;
|
use solana_runtime::message_processor::MessageProcessor;
|
||||||
|
#[allow(deprecated)]
|
||||||
|
use solana_sdk::sysvar::fees::Fees;
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account::{Account, AccountSharedData, ReadableAccount},
|
account::{Account, AccountSharedData, ReadableAccount},
|
||||||
account_info::AccountInfo,
|
account_info::AccountInfo,
|
||||||
|
@ -35,7 +37,7 @@ use solana_sdk::{
|
||||||
secp256k1_recover::{
|
secp256k1_recover::{
|
||||||
Secp256k1RecoverError, SECP256K1_PUBLIC_KEY_LENGTH, SECP256K1_SIGNATURE_LENGTH,
|
Secp256k1RecoverError, SECP256K1_PUBLIC_KEY_LENGTH, SECP256K1_SIGNATURE_LENGTH,
|
||||||
},
|
},
|
||||||
sysvar::{self, fees::Fees, Sysvar, SysvarId},
|
sysvar::{self, Sysvar, SysvarId},
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
alloc::Layout,
|
alloc::Layout,
|
||||||
|
@ -1114,6 +1116,7 @@ struct SyscallGetFeesSysvar<'a> {
|
||||||
invoke_context: Rc<RefCell<&'a mut dyn InvokeContext>>,
|
invoke_context: Rc<RefCell<&'a mut dyn InvokeContext>>,
|
||||||
loader_id: &'a Pubkey,
|
loader_id: &'a Pubkey,
|
||||||
}
|
}
|
||||||
|
#[allow(deprecated)]
|
||||||
impl<'a> SyscallObject<BpfError> for SyscallGetFeesSysvar<'a> {
|
impl<'a> SyscallObject<BpfError> for SyscallGetFeesSysvar<'a> {
|
||||||
fn call(
|
fn call(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
@ -3365,6 +3368,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test fees sysvar
|
// Test fees sysvar
|
||||||
|
#[allow(deprecated)]
|
||||||
{
|
{
|
||||||
let got_fees = Fees::default();
|
let got_fees = Fees::default();
|
||||||
let got_fees_va = 2048;
|
let got_fees_va = 2048;
|
||||||
|
|
|
@ -1752,6 +1752,7 @@ impl Bank {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
fn update_fees(&self) {
|
fn update_fees(&self) {
|
||||||
self.update_sysvar_account(&sysvar::fees::id(), |account| {
|
self.update_sysvar_account(&sysvar::fees::id(), |account| {
|
||||||
create_account(
|
create_account(
|
||||||
|
@ -5300,6 +5301,7 @@ impl Bank {
|
||||||
for sysvar_id in &[
|
for sysvar_id in &[
|
||||||
sysvar::clock::id(),
|
sysvar::clock::id(),
|
||||||
sysvar::epoch_schedule::id(),
|
sysvar::epoch_schedule::id(),
|
||||||
|
#[allow(deprecated)]
|
||||||
sysvar::fees::id(),
|
sysvar::fees::id(),
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
sysvar::recent_blockhashes::id(),
|
sysvar::recent_blockhashes::id(),
|
||||||
|
@ -5574,6 +5576,8 @@ pub(crate) mod tests {
|
||||||
status_cache::MAX_CACHE_ENTRIES,
|
status_cache::MAX_CACHE_ENTRIES,
|
||||||
};
|
};
|
||||||
use crossbeam_channel::{bounded, unbounded};
|
use crossbeam_channel::{bounded, unbounded};
|
||||||
|
#[allow(deprecated)]
|
||||||
|
use solana_sdk::sysvar::fees::Fees;
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account::Account,
|
account::Account,
|
||||||
clock::{DEFAULT_SLOTS_PER_EPOCH, DEFAULT_TICKS_PER_SLOT},
|
clock::{DEFAULT_SLOTS_PER_EPOCH, DEFAULT_TICKS_PER_SLOT},
|
||||||
|
@ -5594,7 +5598,7 @@ pub(crate) mod tests {
|
||||||
},
|
},
|
||||||
system_instruction::{self, SystemError},
|
system_instruction::{self, SystemError},
|
||||||
system_program,
|
system_program,
|
||||||
sysvar::{fees::Fees, rewards::Rewards},
|
sysvar::rewards::Rewards,
|
||||||
timing::duration_as_s,
|
timing::duration_as_s,
|
||||||
};
|
};
|
||||||
use solana_vote_program::{
|
use solana_vote_program::{
|
||||||
|
@ -9378,6 +9382,7 @@ pub(crate) mod tests {
|
||||||
assert!(stake_delegations.get(&stake_keypair.pubkey()).is_some());
|
assert!(stake_delegations.get(&stake_keypair.pubkey()).is_some());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_bank_fees_account() {
|
fn test_bank_fees_account() {
|
||||||
let (mut genesis_config, _) = create_genesis_config(500);
|
let (mut genesis_config, _) = create_genesis_config(500);
|
||||||
|
@ -11992,6 +11997,7 @@ pub(crate) mod tests {
|
||||||
&[
|
&[
|
||||||
sysvar::clock::id(),
|
sysvar::clock::id(),
|
||||||
sysvar::epoch_schedule::id(),
|
sysvar::epoch_schedule::id(),
|
||||||
|
#[allow(deprecated)]
|
||||||
sysvar::fees::id(),
|
sysvar::fees::id(),
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
sysvar::recent_blockhashes::id(),
|
sysvar::recent_blockhashes::id(),
|
||||||
|
@ -12103,6 +12109,7 @@ pub(crate) mod tests {
|
||||||
&[
|
&[
|
||||||
sysvar::clock::id(),
|
sysvar::clock::id(),
|
||||||
sysvar::epoch_schedule::id(),
|
sysvar::epoch_schedule::id(),
|
||||||
|
#[allow(deprecated)]
|
||||||
sysvar::fees::id(),
|
sysvar::fees::id(),
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
sysvar::recent_blockhashes::id(),
|
sysvar::recent_blockhashes::id(),
|
||||||
|
@ -13619,9 +13626,11 @@ 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::fees::id();
|
#[allow(deprecated)]
|
||||||
let orig_lamports = bank.get_account(&sysvar::fees::id()).unwrap().lamports();
|
let blockhash_sysvar = sysvar::clock::id();
|
||||||
info!("{:?}", bank.get_account(&sysvar::fees::id()));
|
#[allow(deprecated)]
|
||||||
|
let orig_lamports = bank.get_account(&sysvar::clock::id()).unwrap().lamports();
|
||||||
|
info!("{:?}", bank.get_account(&sysvar::clock::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),
|
||||||
|
@ -13630,11 +13639,13 @@ pub(crate) mod tests {
|
||||||
InstructionError::ReadonlyLamportChange
|
InstructionError::ReadonlyLamportChange
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
|
#[allow(deprecated)]
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
bank.get_account(&sysvar::fees::id()).unwrap().lamports(),
|
bank.get_account(&sysvar::clock::id()).unwrap().lamports(),
|
||||||
orig_lamports
|
orig_lamports
|
||||||
);
|
);
|
||||||
info!("{:?}", bank.get_account(&sysvar::fees::id()));
|
#[allow(deprecated)]
|
||||||
|
info!("{:?}", bank.get_account(&sysvar::clock::id()));
|
||||||
|
|
||||||
let accounts = vec![
|
let accounts = vec![
|
||||||
AccountMeta::new(mint_keypair.pubkey(), true),
|
AccountMeta::new(mint_keypair.pubkey(), true),
|
||||||
|
|
|
@ -1,11 +1,17 @@
|
||||||
//! This account contains the current cluster fees
|
//! This account contains the current cluster fees
|
||||||
//!
|
//!
|
||||||
|
#![allow(deprecated)]
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
fee_calculator::FeeCalculator, impl_sysvar_get, program_error::ProgramError, sysvar::Sysvar,
|
fee_calculator::FeeCalculator, impl_sysvar_get, program_error::ProgramError, sysvar::Sysvar,
|
||||||
};
|
};
|
||||||
|
|
||||||
crate::declare_sysvar_id!("SysvarFees111111111111111111111111111111111", Fees);
|
crate::declare_deprecated_sysvar_id!("SysvarFees111111111111111111111111111111111", Fees);
|
||||||
|
|
||||||
|
#[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 Fees {
|
pub struct Fees {
|
||||||
|
@ -13,6 +19,7 @@ pub struct Fees {
|
||||||
}
|
}
|
||||||
impl Fees {
|
impl Fees {
|
||||||
pub fn new(fee_calculator: &FeeCalculator) -> Self {
|
pub fn new(fee_calculator: &FeeCalculator) -> Self {
|
||||||
|
#[allow(deprecated)]
|
||||||
Self {
|
Self {
|
||||||
fee_calculator: fee_calculator.clone(),
|
fee_calculator: fee_calculator.clone(),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue