Cleanup old features (#15391)
This commit is contained in:
parent
82850781c9
commit
02432a548f
|
@ -1374,7 +1374,7 @@ fn read_and_verify_elf(program_location: &str) -> Result<Vec<u8>, Box<dyn std::e
|
|||
// Verify the program
|
||||
Executable::<BPFError, ThisInstructionMeter>::from_elf(
|
||||
&program_data,
|
||||
Some(|x| bpf_verifier::check(x, false)),
|
||||
Some(|x| bpf_verifier::check(x)),
|
||||
Config::default(),
|
||||
)
|
||||
.map_err(|err| format!("ELF error: {}", err))?;
|
||||
|
|
|
@ -27,7 +27,7 @@ use solana_sdk::{
|
|||
client::SyncClient,
|
||||
clock::{DEFAULT_SLOTS_PER_EPOCH, MAX_PROCESSING_AGE},
|
||||
entrypoint::{MAX_PERMITTED_DATA_INCREASE, SUCCESS},
|
||||
feature_set::try_find_program_address_syscall_enabled,
|
||||
feature_set::ristretto_mul_syscall_enabled,
|
||||
instruction::{AccountMeta, CompiledInstruction, Instruction, InstructionError},
|
||||
keyed_account::KeyedAccount,
|
||||
message::Message,
|
||||
|
@ -1216,7 +1216,7 @@ fn assert_instruction_count() {
|
|||
("noop", 57),
|
||||
("relative_call", 10),
|
||||
("sanity", 176),
|
||||
("sanity++", 176),
|
||||
("sanity++", 177),
|
||||
("struct_pass", 8),
|
||||
("struct_ret", 22),
|
||||
]);
|
||||
|
@ -2195,7 +2195,7 @@ fn test_program_bpf_syscall_feature_activation() {
|
|||
..
|
||||
} = create_genesis_config(50);
|
||||
let mut bank = Bank::new(&genesis_config);
|
||||
bank.deactivate_feature(&try_find_program_address_syscall_enabled::id());
|
||||
bank.deactivate_feature(&ristretto_mul_syscall_enabled::id());
|
||||
let (name, id, entrypoint) = solana_bpf_loader_program!();
|
||||
bank.add_builtin(&name, id, entrypoint);
|
||||
let bank = Arc::new(bank);
|
||||
|
@ -2212,7 +2212,7 @@ fn test_program_bpf_syscall_feature_activation() {
|
|||
assert!(result.is_ok());
|
||||
|
||||
let mut bank = Bank::new_from_parent(&bank, &Pubkey::default(), 1);
|
||||
bank.activate_feature(&try_find_program_address_syscall_enabled::id());
|
||||
bank.activate_feature(&ristretto_mul_syscall_enabled::id());
|
||||
|
||||
let bank = Arc::new(bank);
|
||||
let bank_client = BankClient::new_shared(&bank);
|
||||
|
|
|
@ -58,11 +58,11 @@ fn adj_insn_ptr(insn_ptr: usize) -> usize {
|
|||
insn_ptr + ebpf::ELF_INSN_DUMP_OFFSET
|
||||
}
|
||||
|
||||
fn check_prog_len(prog: &[u8], is_program_size_cap: bool) -> Result<(), BPFError> {
|
||||
fn check_prog_len(prog: &[u8]) -> Result<(), BPFError> {
|
||||
if prog.len() % ebpf::INSN_SIZE != 0 {
|
||||
return Err(VerifierError::ProgramLengthNotMultiple.into());
|
||||
}
|
||||
if is_program_size_cap && prog.len() > ebpf::PROG_MAX_SIZE {
|
||||
if prog.len() > ebpf::PROG_MAX_SIZE {
|
||||
return Err(VerifierError::ProgramTooLarge(prog.len() / ebpf::INSN_SIZE).into());
|
||||
}
|
||||
|
||||
|
@ -149,8 +149,8 @@ fn check_imm_register(insn: &ebpf::Insn, insn_ptr: usize) -> Result<(), Verifier
|
|||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
pub fn check(prog: &[u8], is_program_size_cap: bool) -> Result<(), BPFError> {
|
||||
check_prog_len(prog, is_program_size_cap)?;
|
||||
pub fn check(prog: &[u8]) -> Result<(), BPFError> {
|
||||
check_prog_len(prog)?;
|
||||
|
||||
let mut insn_ptr: usize = 0;
|
||||
while insn_ptr * ebpf::INSN_SIZE < prog.len() {
|
||||
|
|
|
@ -27,10 +27,7 @@ use solana_sdk::{
|
|||
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
|
||||
clock::Clock,
|
||||
entrypoint::SUCCESS,
|
||||
feature_set::{
|
||||
bpf_compute_budget_balancing, matching_buffer_upgrade_authorities,
|
||||
prevent_upgrade_and_invoke,
|
||||
},
|
||||
feature_set::matching_buffer_upgrade_authorities,
|
||||
ic_logger_msg, ic_msg,
|
||||
instruction::InstructionError,
|
||||
keyed_account::{from_keyed_account, next_keyed_account, KeyedAccount},
|
||||
|
@ -90,11 +87,8 @@ pub fn create_and_cache_executor(
|
|||
let (_, elf_bytes) = program
|
||||
.get_text_bytes()
|
||||
.map_err(|e| map_ebpf_error(invoke_context, e))?;
|
||||
bpf_verifier::check(
|
||||
elf_bytes,
|
||||
!invoke_context.is_feature_active(&bpf_compute_budget_balancing::id()),
|
||||
)
|
||||
.map_err(|e| map_ebpf_error(invoke_context, EbpfError::UserError(e)))?;
|
||||
bpf_verifier::check(elf_bytes)
|
||||
.map_err(|e| map_ebpf_error(invoke_context, EbpfError::UserError(e)))?;
|
||||
let syscall_registry = syscalls::register_syscalls(invoke_context).map_err(|e| {
|
||||
ic_msg!(invoke_context, "Failed to register syscalls: {}", e);
|
||||
InstructionError::ProgramEnvironmentSetupFailure
|
||||
|
@ -491,9 +485,7 @@ fn process_loader_upgradeable_instruction(
|
|||
ic_logger_msg!(logger, "Program account not executable");
|
||||
return Err(InstructionError::AccountNotExecutable);
|
||||
}
|
||||
if !program.is_writable()
|
||||
&& invoke_context.is_feature_active(&prevent_upgrade_and_invoke::id())
|
||||
{
|
||||
if !program.is_writable() {
|
||||
ic_logger_msg!(logger, "Program account not writeable");
|
||||
return Err(InstructionError::InvalidArgument);
|
||||
}
|
||||
|
@ -911,7 +903,7 @@ mod tests {
|
|||
let prog = &[
|
||||
0x18, 0x00, 0x00, 0x00, 0x88, 0x77, 0x66, 0x55, // first half of lddw
|
||||
];
|
||||
bpf_verifier::check(prog, true).unwrap();
|
||||
bpf_verifier::check(prog).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -16,25 +16,18 @@ use solana_sdk::{
|
|||
bpf_loader, bpf_loader_deprecated,
|
||||
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
|
||||
entrypoint::{MAX_PERMITTED_DATA_INCREASE, SUCCESS},
|
||||
feature_set::{
|
||||
abort_on_all_cpi_failures, limit_cpi_loader_invoke, per_byte_logging_cost,
|
||||
pubkey_log_syscall_enabled, ristretto_mul_syscall_enabled, sha256_syscall_enabled,
|
||||
sol_log_compute_units_syscall, try_find_program_address_syscall_enabled,
|
||||
use_loaded_executables, use_loaded_program_accounts,
|
||||
},
|
||||
feature_set::{per_byte_logging_cost, ristretto_mul_syscall_enabled, use_loaded_executables},
|
||||
hash::{Hasher, HASH_BYTES},
|
||||
ic_msg,
|
||||
instruction::{AccountMeta, Instruction, InstructionError},
|
||||
keyed_account::KeyedAccount,
|
||||
native_loader,
|
||||
process_instruction::{stable_log, ComputeMeter, InvokeContext, Logger},
|
||||
program_error::ProgramError,
|
||||
pubkey::{Pubkey, PubkeyError, MAX_SEEDS},
|
||||
};
|
||||
use std::{
|
||||
alloc::Layout,
|
||||
cell::{Ref, RefCell, RefMut},
|
||||
convert::TryFrom,
|
||||
mem::{align_of, size_of},
|
||||
rc::Rc,
|
||||
slice::from_raw_parts_mut,
|
||||
|
@ -110,18 +103,12 @@ pub fn register_syscalls(
|
|||
syscall_registry.register_syscall_by_name(b"sol_log_", SyscallLog::call)?;
|
||||
syscall_registry.register_syscall_by_name(b"sol_log_64_", SyscallLogU64::call)?;
|
||||
|
||||
if invoke_context.is_feature_active(&sol_log_compute_units_syscall::id()) {
|
||||
syscall_registry
|
||||
.register_syscall_by_name(b"sol_log_compute_units_", SyscallLogBpfComputeUnits::call)?;
|
||||
}
|
||||
syscall_registry
|
||||
.register_syscall_by_name(b"sol_log_compute_units_", SyscallLogBpfComputeUnits::call)?;
|
||||
|
||||
if invoke_context.is_feature_active(&pubkey_log_syscall_enabled::id()) {
|
||||
syscall_registry.register_syscall_by_name(b"sol_log_pubkey", SyscallLogPubkey::call)?;
|
||||
}
|
||||
syscall_registry.register_syscall_by_name(b"sol_log_pubkey", SyscallLogPubkey::call)?;
|
||||
|
||||
if invoke_context.is_feature_active(&sha256_syscall_enabled::id()) {
|
||||
syscall_registry.register_syscall_by_name(b"sol_sha256", SyscallSha256::call)?;
|
||||
}
|
||||
syscall_registry.register_syscall_by_name(b"sol_sha256", SyscallSha256::call)?;
|
||||
|
||||
if invoke_context.is_feature_active(&ristretto_mul_syscall_enabled::id()) {
|
||||
syscall_registry
|
||||
|
@ -132,12 +119,10 @@ pub fn register_syscalls(
|
|||
b"sol_create_program_address",
|
||||
SyscallCreateProgramAddress::call,
|
||||
)?;
|
||||
if invoke_context.is_feature_active(&try_find_program_address_syscall_enabled::id()) {
|
||||
syscall_registry.register_syscall_by_name(
|
||||
b"sol_try_find_program_address",
|
||||
SyscallTryFindProgramAddress::call,
|
||||
)?;
|
||||
}
|
||||
syscall_registry.register_syscall_by_name(
|
||||
b"sol_try_find_program_address",
|
||||
SyscallTryFindProgramAddress::call,
|
||||
)?;
|
||||
syscall_registry
|
||||
.register_syscall_by_name(b"sol_invoke_signed_c", SyscallInvokeSignedC::call)?;
|
||||
syscall_registry
|
||||
|
@ -202,40 +187,34 @@ pub fn bind_syscall_context_objects<'a>(
|
|||
None,
|
||||
)?;
|
||||
|
||||
bind_feature_gated_syscall_context_object!(
|
||||
vm,
|
||||
invoke_context,
|
||||
&sol_log_compute_units_syscall::id(),
|
||||
vm.bind_syscall_context_object(
|
||||
Box::new(SyscallLogBpfComputeUnits {
|
||||
cost: 0,
|
||||
compute_meter: invoke_context.get_compute_meter(),
|
||||
logger: invoke_context.get_logger(),
|
||||
}),
|
||||
);
|
||||
None,
|
||||
)?;
|
||||
|
||||
bind_feature_gated_syscall_context_object!(
|
||||
vm,
|
||||
invoke_context,
|
||||
&pubkey_log_syscall_enabled::id(),
|
||||
vm.bind_syscall_context_object(
|
||||
Box::new(SyscallLogPubkey {
|
||||
cost: bpf_compute_budget.log_pubkey_units,
|
||||
compute_meter: invoke_context.get_compute_meter(),
|
||||
logger: invoke_context.get_logger(),
|
||||
loader_id,
|
||||
}),
|
||||
);
|
||||
None,
|
||||
)?;
|
||||
|
||||
bind_feature_gated_syscall_context_object!(
|
||||
vm,
|
||||
invoke_context,
|
||||
&sha256_syscall_enabled::id(),
|
||||
vm.bind_syscall_context_object(
|
||||
Box::new(SyscallSha256 {
|
||||
sha256_base_cost: bpf_compute_budget.sha256_base_cost,
|
||||
sha256_byte_cost: bpf_compute_budget.sha256_byte_cost,
|
||||
compute_meter: invoke_context.get_compute_meter(),
|
||||
loader_id,
|
||||
}),
|
||||
);
|
||||
None,
|
||||
)?;
|
||||
|
||||
bind_feature_gated_syscall_context_object!(
|
||||
vm,
|
||||
|
@ -257,16 +236,14 @@ pub fn bind_syscall_context_objects<'a>(
|
|||
None,
|
||||
)?;
|
||||
|
||||
bind_feature_gated_syscall_context_object!(
|
||||
vm,
|
||||
invoke_context,
|
||||
&try_find_program_address_syscall_enabled::id(),
|
||||
vm.bind_syscall_context_object(
|
||||
Box::new(SyscallTryFindProgramAddress {
|
||||
cost: bpf_compute_budget.create_program_address_units,
|
||||
compute_meter: invoke_context.get_compute_meter(),
|
||||
loader_id,
|
||||
}),
|
||||
);
|
||||
None,
|
||||
)?;
|
||||
|
||||
// Cross-program invocation syscalls
|
||||
|
||||
|
@ -1450,8 +1427,7 @@ where
|
|||
SyscallError::InstructionError(InstructionError::MissingAccount)
|
||||
})?;
|
||||
|
||||
if (invoke_context.is_feature_active(&use_loaded_program_accounts::id())
|
||||
&& i == program_account_index)
|
||||
if i == program_account_index
|
||||
|| (invoke_context.is_feature_active(&use_loaded_executables::id())
|
||||
&& account.borrow().executable)
|
||||
{
|
||||
|
@ -1511,7 +1487,6 @@ fn check_account_infos(
|
|||
> invoke_context
|
||||
.get_bpf_compute_budget()
|
||||
.max_cpi_instruction_size
|
||||
&& invoke_context.is_feature_active(&use_loaded_program_accounts::id())
|
||||
{
|
||||
// Cap the number of account_infos a caller can pass to approximate
|
||||
// maximum that accounts that could be passed in an instruction
|
||||
|
@ -1580,14 +1555,7 @@ fn call<'a>(
|
|||
signers_seeds_len: u64,
|
||||
memory_mapping: &MemoryMapping,
|
||||
) -> Result<u64, EbpfError<BPFError>> {
|
||||
let (
|
||||
message,
|
||||
executables,
|
||||
accounts,
|
||||
account_refs,
|
||||
caller_privileges,
|
||||
abort_on_all_cpi_failures,
|
||||
) = {
|
||||
let (message, executables, accounts, account_refs, caller_privileges) = {
|
||||
let invoke_context = syscall.get_context()?;
|
||||
|
||||
invoke_context
|
||||
|
@ -1633,9 +1601,7 @@ fn call<'a>(
|
|||
}
|
||||
})
|
||||
.collect::<Vec<bool>>();
|
||||
if invoke_context.is_feature_active(&limit_cpi_loader_invoke::id()) {
|
||||
check_authorized_program(&callee_program_id, &instruction.data)?;
|
||||
}
|
||||
check_authorized_program(&callee_program_id, &instruction.data)?;
|
||||
let (accounts, account_refs) = syscall.translate_accounts(
|
||||
&message.account_keys,
|
||||
callee_program_id_index,
|
||||
|
@ -1668,7 +1634,6 @@ fn call<'a>(
|
|||
accounts,
|
||||
account_refs,
|
||||
caller_privileges,
|
||||
invoke_context.is_feature_active(&abort_on_all_cpi_failures::id()),
|
||||
)
|
||||
};
|
||||
|
||||
|
@ -1684,14 +1649,7 @@ fn call<'a>(
|
|||
) {
|
||||
Ok(()) => (),
|
||||
Err(err) => {
|
||||
if abort_on_all_cpi_failures {
|
||||
return Err(SyscallError::InstructionError(err).into());
|
||||
} else {
|
||||
match ProgramError::try_from(err) {
|
||||
Ok(err) => return Ok(err.into()),
|
||||
Err(err) => return Err(SyscallError::InstructionError(err).into()),
|
||||
}
|
||||
}
|
||||
return Err(SyscallError::InstructionError(err).into());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2879,7 +2879,7 @@ impl Bank {
|
|||
let mut transaction_log_messages = Vec::with_capacity(txs.len());
|
||||
let bpf_compute_budget = self
|
||||
.bpf_compute_budget
|
||||
.unwrap_or_else(|| BpfComputeBudget::new(&self.feature_set));
|
||||
.unwrap_or_else(BpfComputeBudget::new);
|
||||
|
||||
let executed: Vec<TransactionExecutionResult> = loaded_accounts
|
||||
.iter_mut()
|
||||
|
|
|
@ -1645,7 +1645,7 @@ mod tests {
|
|||
executors.clone(),
|
||||
None,
|
||||
Arc::new(FeatureSet::all_enabled()),
|
||||
BpfComputeBudget::new(&FeatureSet::all_enabled()),
|
||||
BpfComputeBudget::new(),
|
||||
);
|
||||
assert_eq!(result, Ok(()));
|
||||
assert_eq!(accounts[0].borrow().lamports, 100);
|
||||
|
@ -1670,7 +1670,7 @@ mod tests {
|
|||
executors.clone(),
|
||||
None,
|
||||
Arc::new(FeatureSet::all_enabled()),
|
||||
BpfComputeBudget::new(&FeatureSet::all_enabled()),
|
||||
BpfComputeBudget::new(),
|
||||
);
|
||||
assert_eq!(
|
||||
result,
|
||||
|
@ -1699,7 +1699,7 @@ mod tests {
|
|||
executors,
|
||||
None,
|
||||
Arc::new(FeatureSet::all_enabled()),
|
||||
BpfComputeBudget::new(&FeatureSet::all_enabled()),
|
||||
BpfComputeBudget::new(),
|
||||
);
|
||||
assert_eq!(
|
||||
result,
|
||||
|
@ -1812,7 +1812,7 @@ mod tests {
|
|||
executors.clone(),
|
||||
None,
|
||||
Arc::new(FeatureSet::all_enabled()),
|
||||
BpfComputeBudget::new(&FeatureSet::all_enabled()),
|
||||
BpfComputeBudget::new(),
|
||||
);
|
||||
assert_eq!(
|
||||
result,
|
||||
|
@ -1841,7 +1841,7 @@ mod tests {
|
|||
executors.clone(),
|
||||
None,
|
||||
Arc::new(FeatureSet::all_enabled()),
|
||||
BpfComputeBudget::new(&FeatureSet::all_enabled()),
|
||||
BpfComputeBudget::new(),
|
||||
);
|
||||
assert_eq!(result, Ok(()));
|
||||
|
||||
|
@ -1867,7 +1867,7 @@ mod tests {
|
|||
executors,
|
||||
None,
|
||||
Arc::new(FeatureSet::all_enabled()),
|
||||
BpfComputeBudget::new(&FeatureSet::all_enabled()),
|
||||
BpfComputeBudget::new(),
|
||||
);
|
||||
assert_eq!(result, Ok(()));
|
||||
assert_eq!(accounts[0].borrow().lamports, 80);
|
||||
|
|
|
@ -47,18 +47,6 @@ pub mod spl_token_v2_multisig_fix {
|
|||
solana_sdk::declare_id!("E5JiFDQCwyC6QfT9REFyMpfK2mHcmv1GUDySU1Ue7TYv");
|
||||
}
|
||||
|
||||
pub mod bpf_loader2_program {
|
||||
solana_sdk::declare_id!("DFBnrgThdzH4W6wZ12uGPoWcMnvfZj11EHnxHcVxLPhD");
|
||||
}
|
||||
|
||||
pub mod bpf_compute_budget_balancing {
|
||||
solana_sdk::declare_id!("HxvjqDSiF5sYdSYuCXsUnS8UeAoWsMT9iGoFP8pgV1mB");
|
||||
}
|
||||
|
||||
pub mod sha256_syscall_enabled {
|
||||
solana_sdk::declare_id!("D7KfP7bZxpkYtD4Pc38t9htgs1k5k47Yhxe4rp6WDVi8");
|
||||
}
|
||||
|
||||
pub mod no_overflow_rent_distribution {
|
||||
solana_sdk::declare_id!("4kpdyrcj5jS47CZb2oJGfVxjYbsMm2Kx97gFyZrxxwXz");
|
||||
}
|
||||
|
@ -67,26 +55,10 @@ pub mod ristretto_mul_syscall_enabled {
|
|||
solana_sdk::declare_id!("HRe7A6aoxgjKzdjbBv6HTy7tJ4YWqE6tVmYCGho6S9Aq");
|
||||
}
|
||||
|
||||
pub mod max_invoke_depth_4 {
|
||||
solana_sdk::declare_id!("EdM9xggY5y7AhNMskRG8NgGMnaP4JFNsWi8ZZtyT1af5");
|
||||
}
|
||||
|
||||
pub mod max_program_call_depth_64 {
|
||||
solana_sdk::declare_id!("YCKSgA6XmjtkQrHBQjpyNrX6EMhJPcYcLWMVgWn36iv");
|
||||
}
|
||||
|
||||
pub mod cumulative_rent_related_fixes {
|
||||
solana_sdk::declare_id!("FtjnuAtJTWwX3Kx9m24LduNEhzaGuuPfDW6e14SX2Fy5");
|
||||
}
|
||||
|
||||
pub mod sol_log_compute_units_syscall {
|
||||
solana_sdk::declare_id!("BHuZqHAj7JdZc68wVgZZcy51jZykvgrx4zptR44RyChe");
|
||||
}
|
||||
|
||||
pub mod pubkey_log_syscall_enabled {
|
||||
solana_sdk::declare_id!("MoqiU1vryuCGQSxFKA1SZ316JdLEFFhoAu6cKUNk7dN");
|
||||
}
|
||||
|
||||
pub mod pull_request_ping_pong_check {
|
||||
solana_sdk::declare_id!("5RzEHTnf6D7JPZCvwEzjM19kzBsyjSU3HoMfXaQmVgnZ");
|
||||
}
|
||||
|
@ -111,30 +83,10 @@ pub mod bpf_loader_upgradeable_program {
|
|||
solana_sdk::declare_id!("FbhK8HN9qvNHvJcoFVHAEUCNkagHvu7DTWzdnLuVQ5u4");
|
||||
}
|
||||
|
||||
pub mod try_find_program_address_syscall_enabled {
|
||||
solana_sdk::declare_id!("EMsMNadQNhCYDyGpYH5Tx6dGHxiUqKHk782PU5XaWfmi");
|
||||
}
|
||||
|
||||
pub mod stake_program_v3 {
|
||||
solana_sdk::declare_id!("Ego6nTu7WsBcZBvVqJQKp6Yku2N3mrfG8oYCfaLZkAeK");
|
||||
}
|
||||
|
||||
pub mod max_cpi_instruction_size_ipv6_mtu {
|
||||
solana_sdk::declare_id!("5WLtuUJA5VVA1Cc28qULPfGs8anhoBev8uNqaaXeasnf");
|
||||
}
|
||||
|
||||
pub mod limit_cpi_loader_invoke {
|
||||
solana_sdk::declare_id!("xGbcW7EEC7zMRJ6LaJCob65EJxKryWjwM4rv8f57SRM");
|
||||
}
|
||||
|
||||
pub mod use_loaded_program_accounts {
|
||||
solana_sdk::declare_id!("FLjgLeg1PJkZimQCVa5sVFtaq6VmSDPw3NvH8iQ3nyHn");
|
||||
}
|
||||
|
||||
pub mod abort_on_all_cpi_failures {
|
||||
solana_sdk::declare_id!("ED5D5a2hQaECHaMmKpnU48GdsfafdCjkb3pgAw5RKbb2");
|
||||
}
|
||||
|
||||
pub mod use_loaded_executables {
|
||||
solana_sdk::declare_id!("3Jq7mE2chDpf6oeEDsuGK7orTYEgyQjCPvaRppTNdVGK");
|
||||
}
|
||||
|
@ -143,10 +95,6 @@ pub mod turbine_retransmit_peers_patch {
|
|||
solana_sdk::declare_id!("5Lu3JnWSFwRYpXzwDMkanWSk6XqSuF2i5fpnVhzB5CTc");
|
||||
}
|
||||
|
||||
pub mod prevent_upgrade_and_invoke {
|
||||
solana_sdk::declare_id!("BiNjYd8jCYDgAwMqP91uwZs6skWpuHtKrZbckuKESs8N");
|
||||
}
|
||||
|
||||
pub mod track_writable_deescalation {
|
||||
solana_sdk::declare_id!("HVPSxqskEtRLRT2ZeEMmkmt9FWqoFX4vrN6f5VaadLED");
|
||||
}
|
||||
|
@ -181,31 +129,18 @@ lazy_static! {
|
|||
(pico_inflation::id(), "pico inflation"),
|
||||
(full_inflation::devnet_and_testnet::id(), "full inflation on devnet and testnet"),
|
||||
(spl_token_v2_multisig_fix::id(), "spl-token multisig fix"),
|
||||
(bpf_loader2_program::id(), "bpf_loader2 program"),
|
||||
(bpf_compute_budget_balancing::id(), "compute budget balancing"),
|
||||
(sha256_syscall_enabled::id(), "sha256 syscall"),
|
||||
(no_overflow_rent_distribution::id(), "no overflow rent distribution"),
|
||||
(ristretto_mul_syscall_enabled::id(), "ristretto multiply syscall"),
|
||||
(max_invoke_depth_4::id(), "max invoke call depth 4"),
|
||||
(max_program_call_depth_64::id(), "max program call depth 64"),
|
||||
(cumulative_rent_related_fixes::id(), "rent fixes (#10206, #10468, #11342)"),
|
||||
(sol_log_compute_units_syscall::id(), "sol_log_compute_units syscall (#13243)"),
|
||||
(pubkey_log_syscall_enabled::id(), "pubkey log syscall"),
|
||||
(pull_request_ping_pong_check::id(), "ping-pong packet check #12794"),
|
||||
(stake_program_v2::id(), "solana_stake_program v2"),
|
||||
(rewrite_stake::id(), "rewrite stake"),
|
||||
(filter_stake_delegation_accounts::id(), "filter stake_delegation_accounts #14062"),
|
||||
(simple_capitalization::id(), "simple capitalization"),
|
||||
(bpf_loader_upgradeable_program::id(), "upgradeable bpf loader"),
|
||||
(try_find_program_address_syscall_enabled::id(), "add try_find_program_address syscall"),
|
||||
(stake_program_v3::id(), "solana_stake_program v3"),
|
||||
(max_cpi_instruction_size_ipv6_mtu::id(), "max cross-program invocation size 1280"),
|
||||
(limit_cpi_loader_invoke::id(), "loader not authorized via CPI"),
|
||||
(use_loaded_program_accounts::id(), "use loaded program accounts"),
|
||||
(abort_on_all_cpi_failures::id(), "abort on all CPI failures"),
|
||||
(use_loaded_executables::id(), "use loaded executable accounts"),
|
||||
(turbine_retransmit_peers_patch::id(), "turbine retransmit peers patch #14631"),
|
||||
(prevent_upgrade_and_invoke::id(), "prevent upgrade and invoke in same tx batch"),
|
||||
(track_writable_deescalation::id(), "track account writable deescalation"),
|
||||
(require_custodian_for_locked_stake_authorize::id(), "require custodian to authorize withdrawer change for locked stake"),
|
||||
(spl_token_v2_self_transfer_fix::id(), "spl-token self-transfer fix"),
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
use solana_sdk::{
|
||||
account::Account,
|
||||
feature_set::{
|
||||
bpf_compute_budget_balancing, max_cpi_instruction_size_ipv6_mtu, max_invoke_depth_4,
|
||||
max_program_call_depth_64, pubkey_log_syscall_enabled, FeatureSet,
|
||||
},
|
||||
instruction::{CompiledInstruction, Instruction, InstructionError},
|
||||
keyed_account::KeyedAccount,
|
||||
message::Message,
|
||||
|
@ -127,64 +123,25 @@ pub struct BpfComputeBudget {
|
|||
}
|
||||
impl Default for BpfComputeBudget {
|
||||
fn default() -> Self {
|
||||
Self::new(&FeatureSet::all_enabled())
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
impl BpfComputeBudget {
|
||||
pub fn new(feature_set: &FeatureSet) -> Self {
|
||||
let mut bpf_compute_budget =
|
||||
// Original
|
||||
pub fn new() -> Self {
|
||||
BpfComputeBudget {
|
||||
max_units: 100_000,
|
||||
log_units: 0,
|
||||
log_64_units: 0,
|
||||
create_program_address_units: 0,
|
||||
invoke_units: 0,
|
||||
max_invoke_depth: 1,
|
||||
max_units: 200_000,
|
||||
log_units: 100,
|
||||
log_64_units: 100,
|
||||
create_program_address_units: 1500,
|
||||
invoke_units: 1000,
|
||||
max_invoke_depth: 4,
|
||||
sha256_base_cost: 85,
|
||||
sha256_byte_cost: 1,
|
||||
max_call_depth: 20,
|
||||
max_call_depth: 64,
|
||||
stack_frame_size: 4_096,
|
||||
log_pubkey_units: 0,
|
||||
max_cpi_instruction_size: std::usize::MAX,
|
||||
};
|
||||
|
||||
if feature_set.is_active(&bpf_compute_budget_balancing::id()) {
|
||||
bpf_compute_budget = BpfComputeBudget {
|
||||
max_units: 200_000,
|
||||
log_units: 100,
|
||||
log_64_units: 100,
|
||||
create_program_address_units: 1500,
|
||||
invoke_units: 1000,
|
||||
..bpf_compute_budget
|
||||
};
|
||||
log_pubkey_units: 100,
|
||||
max_cpi_instruction_size: 1280, // IPv6 Min MTU size
|
||||
}
|
||||
if feature_set.is_active(&max_invoke_depth_4::id()) {
|
||||
bpf_compute_budget = BpfComputeBudget {
|
||||
max_invoke_depth: 4,
|
||||
..bpf_compute_budget
|
||||
};
|
||||
}
|
||||
|
||||
if feature_set.is_active(&max_program_call_depth_64::id()) {
|
||||
bpf_compute_budget = BpfComputeBudget {
|
||||
max_call_depth: 64,
|
||||
..bpf_compute_budget
|
||||
};
|
||||
}
|
||||
if feature_set.is_active(&pubkey_log_syscall_enabled::id()) {
|
||||
bpf_compute_budget = BpfComputeBudget {
|
||||
log_pubkey_units: 100,
|
||||
..bpf_compute_budget
|
||||
};
|
||||
}
|
||||
if feature_set.is_active(&max_cpi_instruction_size_ipv6_mtu::id()) {
|
||||
bpf_compute_budget = BpfComputeBudget {
|
||||
max_cpi_instruction_size: 1280, // IPv6 Min MTU size
|
||||
..bpf_compute_budget
|
||||
};
|
||||
}
|
||||
bpf_compute_budget
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue