Feature disable fees sysvar (#18981)
* Feature disable fees sysvar * nudge
This commit is contained in:
parent
9d2f0e237b
commit
77861e2d40
|
@ -1,12 +1,9 @@
|
|||
#[allow(deprecated)]
|
||||
use solana_sdk::sysvar::fees::Fees;
|
||||
use {
|
||||
solana_program_test::{processor, ProgramTest},
|
||||
solana_sdk::{
|
||||
account_info::AccountInfo, clock::Clock, entrypoint::ProgramResult,
|
||||
epoch_schedule::EpochSchedule, fee_calculator::FeeCalculator, instruction::Instruction,
|
||||
msg, pubkey::Pubkey, rent::Rent, signature::Signer, sysvar::Sysvar,
|
||||
transaction::Transaction,
|
||||
epoch_schedule::EpochSchedule, instruction::Instruction, msg, pubkey::Pubkey, rent::Rent,
|
||||
signature::Signer, sysvar::Sysvar, transaction::Transaction,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -24,17 +21,6 @@ fn sysvar_getter_process_instruction(
|
|||
let epoch_schedule = EpochSchedule::get()?;
|
||||
assert_eq!(epoch_schedule, EpochSchedule::default());
|
||||
|
||||
#[allow(deprecated)]
|
||||
{
|
||||
let fees = Fees::get()?;
|
||||
assert_eq!(
|
||||
fees.fee_calculator,
|
||||
FeeCalculator {
|
||||
lamports_per_signature: 5000
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
let rent = Rent::get()?;
|
||||
assert_eq!(rent, Rent::default());
|
||||
|
||||
|
|
|
@ -2,12 +2,11 @@
|
|||
|
||||
extern crate solana_program;
|
||||
#[allow(deprecated)]
|
||||
use solana_program::sysvar::{fees::Fees, recent_blockhashes::RecentBlockhashes};
|
||||
use solana_program::sysvar::recent_blockhashes::RecentBlockhashes;
|
||||
use solana_program::{
|
||||
account_info::AccountInfo,
|
||||
entrypoint,
|
||||
entrypoint::ProgramResult,
|
||||
fee_calculator::FeeCalculator,
|
||||
msg,
|
||||
program_error::ProgramError,
|
||||
pubkey::Pubkey,
|
||||
|
@ -44,22 +43,10 @@ pub fn process_instruction(
|
|||
assert_eq!(epoch_schedule, got_epoch_schedule);
|
||||
}
|
||||
|
||||
// Fees
|
||||
#[allow(deprecated)]
|
||||
{
|
||||
msg!("Fees identifier:");
|
||||
sysvar::fees::id().log();
|
||||
let fees = Fees::from_account_info(&accounts[4]).unwrap();
|
||||
let fee_calculator = fees.fee_calculator.clone();
|
||||
assert_ne!(fee_calculator, FeeCalculator::default());
|
||||
let got_fees = Fees::get()?;
|
||||
assert_eq!(fees, got_fees);
|
||||
}
|
||||
|
||||
// Instructions
|
||||
msg!("Instructions identifier:");
|
||||
sysvar::instructions::id().log();
|
||||
let index = instructions::load_current_index(&accounts[5].try_borrow_data()?);
|
||||
let index = instructions::load_current_index(&accounts[4].try_borrow_data()?);
|
||||
assert_eq!(0, index);
|
||||
|
||||
// Recent Blockhashes
|
||||
|
@ -67,7 +54,7 @@ pub fn process_instruction(
|
|||
{
|
||||
msg!("RecentBlockhashes identifier:");
|
||||
sysvar::recent_blockhashes::id().log();
|
||||
let recent_blockhashes = RecentBlockhashes::from_account_info(&accounts[6]).unwrap();
|
||||
let recent_blockhashes = RecentBlockhashes::from_account_info(&accounts[5]).unwrap();
|
||||
assert_ne!(recent_blockhashes, RecentBlockhashes::default());
|
||||
}
|
||||
|
||||
|
@ -75,7 +62,7 @@ pub fn process_instruction(
|
|||
{
|
||||
msg!("Rent identifier:");
|
||||
sysvar::rent::id().log();
|
||||
let rent = Rent::from_account_info(&accounts[7]).unwrap();
|
||||
let rent = Rent::from_account_info(&accounts[6]).unwrap();
|
||||
assert_eq!(rent, Rent::default());
|
||||
let got_rent = Rent::get()?;
|
||||
assert_eq!(rent, got_rent);
|
||||
|
@ -86,7 +73,7 @@ pub fn process_instruction(
|
|||
sysvar::slot_hashes::id().log();
|
||||
assert_eq!(
|
||||
Err(ProgramError::UnsupportedSysvar),
|
||||
SlotHashes::from_account_info(&accounts[8])
|
||||
SlotHashes::from_account_info(&accounts[7])
|
||||
);
|
||||
|
||||
// Slot History
|
||||
|
@ -94,13 +81,13 @@ pub fn process_instruction(
|
|||
sysvar::slot_history::id().log();
|
||||
assert_eq!(
|
||||
Err(ProgramError::UnsupportedSysvar),
|
||||
SlotHistory::from_account_info(&accounts[9])
|
||||
SlotHistory::from_account_info(&accounts[8])
|
||||
);
|
||||
|
||||
// Stake History
|
||||
msg!("StakeHistory identifier:");
|
||||
sysvar::stake_history::id().log();
|
||||
let _ = StakeHistory::from_account_info(&accounts[10]).unwrap();
|
||||
let _ = StakeHistory::from_account_info(&accounts[9]).unwrap();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -28,8 +28,6 @@ async fn test_sysvars() {
|
|||
AccountMeta::new(Pubkey::new_unique(), false),
|
||||
AccountMeta::new_readonly(clock::id(), false),
|
||||
AccountMeta::new_readonly(epoch_schedule::id(), false),
|
||||
#[allow(deprecated)]
|
||||
AccountMeta::new_readonly(fees::id(), false),
|
||||
AccountMeta::new_readonly(instructions::id(), false),
|
||||
#[allow(deprecated)]
|
||||
AccountMeta::new_readonly(recent_blockhashes::id(), false),
|
||||
|
|
|
@ -21,8 +21,8 @@ use solana_sdk::{
|
|||
entrypoint::{MAX_PERMITTED_DATA_INCREASE, SUCCESS},
|
||||
epoch_schedule::EpochSchedule,
|
||||
feature_set::{
|
||||
blake3_syscall_enabled, enforce_aligned_host_addrs, libsecp256k1_0_5_upgrade_enabled,
|
||||
memory_ops_syscalls, secp256k1_recover_syscall_enabled,
|
||||
blake3_syscall_enabled, disable_fees_sysvar, enforce_aligned_host_addrs,
|
||||
libsecp256k1_0_5_upgrade_enabled, memory_ops_syscalls, secp256k1_recover_syscall_enabled,
|
||||
},
|
||||
hash::{Hasher, HASH_BYTES},
|
||||
ic_msg,
|
||||
|
@ -150,8 +150,10 @@ pub fn register_syscalls(
|
|||
b"sol_get_epoch_schedule_sysvar",
|
||||
SyscallGetEpochScheduleSysvar::call,
|
||||
)?;
|
||||
syscall_registry
|
||||
.register_syscall_by_name(b"sol_get_fees_sysvar", SyscallGetFeesSysvar::call)?;
|
||||
if invoke_context.is_feature_active(&disable_fees_sysvar::id()) {
|
||||
syscall_registry
|
||||
.register_syscall_by_name(b"sol_get_fees_sysvar", SyscallGetFeesSysvar::call)?;
|
||||
}
|
||||
syscall_registry
|
||||
.register_syscall_by_name(b"sol_get_rent_sysvar", SyscallGetRentSysvar::call)?;
|
||||
|
||||
|
@ -346,6 +348,9 @@ pub fn bind_syscall_context_objects<'a>(
|
|||
}),
|
||||
);
|
||||
|
||||
let is_fee_sysvar_via_syscall_active =
|
||||
!invoke_context.is_feature_active(&disable_fees_sysvar::id());
|
||||
|
||||
let invoke_context = Rc::new(RefCell::new(invoke_context));
|
||||
|
||||
vm.bind_syscall_context_object(
|
||||
|
@ -362,13 +367,14 @@ pub fn bind_syscall_context_objects<'a>(
|
|||
}),
|
||||
None,
|
||||
)?;
|
||||
vm.bind_syscall_context_object(
|
||||
bind_feature_gated_syscall_context_object!(
|
||||
vm,
|
||||
is_fee_sysvar_via_syscall_active,
|
||||
Box::new(SyscallGetFeesSysvar {
|
||||
invoke_context: invoke_context.clone(),
|
||||
loader_id,
|
||||
}),
|
||||
None,
|
||||
)?;
|
||||
);
|
||||
vm.bind_syscall_context_object(
|
||||
Box::new(SyscallGetRentSysvar {
|
||||
invoke_context: invoke_context.clone(),
|
||||
|
|
|
@ -1754,12 +1754,17 @@ impl Bank {
|
|||
|
||||
#[allow(deprecated)]
|
||||
fn update_fees(&self) {
|
||||
self.update_sysvar_account(&sysvar::fees::id(), |account| {
|
||||
create_account(
|
||||
&sysvar::fees::Fees::new(&self.fee_calculator),
|
||||
self.inherit_specially_retained_account_fields(account),
|
||||
)
|
||||
});
|
||||
if !self
|
||||
.feature_set
|
||||
.is_active(&feature_set::disable_fees_sysvar::id())
|
||||
{
|
||||
self.update_sysvar_account(&sysvar::fees::id(), |account| {
|
||||
create_account(
|
||||
&sysvar::fees::Fees::new(&self.fee_calculator),
|
||||
self.inherit_specially_retained_account_fields(account),
|
||||
)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn update_rent(&self) {
|
||||
|
@ -7410,8 +7415,8 @@ pub(crate) mod tests {
|
|||
|
||||
bank.collect_rent_in_partition((0, 0, 1)); // all range
|
||||
|
||||
// unrelated 1-lamport account exists
|
||||
assert_eq!(bank.collected_rent.load(Relaxed), rent_collected + 1);
|
||||
// unrelated 1-lamport accounts exists
|
||||
assert_eq!(bank.collected_rent.load(Relaxed), rent_collected + 2);
|
||||
assert_eq!(
|
||||
bank.get_account(&rent_due_pubkey).unwrap().lamports(),
|
||||
little_lamports - rent_collected
|
||||
|
|
|
@ -122,8 +122,8 @@ pub(crate) fn sol_get_epoch_schedule_sysvar(var_addr: *mut u8) -> u64 {
|
|||
.sol_get_epoch_schedule_sysvar(var_addr)
|
||||
}
|
||||
|
||||
pub(crate) fn sol_get_fees_sysvar(var_addr: *mut u8) -> u64 {
|
||||
SYSCALL_STUBS.read().unwrap().sol_get_fees_sysvar(var_addr)
|
||||
pub(crate) fn sol_get_fees_sysvar(_var_addr: *mut u8) -> u64 {
|
||||
UNSUPPORTED_SYSVAR
|
||||
}
|
||||
|
||||
pub(crate) fn sol_get_rent_sysvar(var_addr: *mut u8) -> u64 {
|
||||
|
|
|
@ -179,6 +179,10 @@ pub mod merge_nonce_error_into_system_error {
|
|||
solana_sdk::declare_id!("21AWDosvp3pBamFW91KB35pNoaoZVTM7ess8nr2nt53B");
|
||||
}
|
||||
|
||||
pub mod disable_fees_sysvar {
|
||||
solana_sdk::declare_id!("JAN1trEUEtZjgXYzNBYHU9DYd7GnThhXfFP7SzPXkPsG");
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
/// Map of feature identifiers to user-visible description
|
||||
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
|
||||
|
@ -218,6 +222,7 @@ lazy_static! {
|
|||
(tx_wide_compute_cap::id(), "Transaction wide compute cap"),
|
||||
(spl_token_v2_set_authority_fix::id(), "spl-token set_authority fix"),
|
||||
(merge_nonce_error_into_system_error::id(), "merge NonceError into SystemError"),
|
||||
(disable_fees_sysvar::id(), "disable fees sysvar"),
|
||||
/*************** ADD NEW FEATURES HERE ***************/
|
||||
]
|
||||
.iter()
|
||||
|
|
Loading…
Reference in New Issue