Cleanup loader features (#18977)
This commit is contained in:
parent
b05fb87f22
commit
ef17cf3bdb
|
@ -31,7 +31,7 @@ use solana_sdk::{
|
|||
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
|
||||
clock::Clock,
|
||||
entrypoint::{HEAP_LENGTH, SUCCESS},
|
||||
feature_set::{add_missing_program_error_mappings, upgradeable_close_instruction},
|
||||
feature_set::add_missing_program_error_mappings,
|
||||
ic_logger_msg, ic_msg,
|
||||
instruction::InstructionError,
|
||||
keyed_account::{from_keyed_account, keyed_account_at_index},
|
||||
|
@ -620,9 +620,6 @@ fn process_loader_upgradeable_instruction(
|
|||
ic_logger_msg!(logger, "New authority {:?}", new_authority);
|
||||
}
|
||||
UpgradeableLoaderInstruction::Close => {
|
||||
if !invoke_context.is_feature_active(&upgradeable_close_instruction::id()) {
|
||||
return Err(InstructionError::InvalidInstructionData);
|
||||
}
|
||||
let close_account = keyed_account_at_index(keyed_accounts, 0)?;
|
||||
let recipient_account = keyed_account_at_index(keyed_accounts, 1)?;
|
||||
let authority = keyed_account_at_index(keyed_accounts, 2)?;
|
||||
|
|
|
@ -21,9 +21,8 @@ use solana_sdk::{
|
|||
entrypoint::{MAX_PERMITTED_DATA_INCREASE, SUCCESS},
|
||||
epoch_schedule::EpochSchedule,
|
||||
feature_set::{
|
||||
blake3_syscall_enabled, cpi_data_cost, enforce_aligned_host_addrs,
|
||||
keccak256_syscall_enabled, libsecp256k1_0_5_upgrade_enabled, memory_ops_syscalls,
|
||||
secp256k1_recover_syscall_enabled, sysvar_via_syscall, update_data_on_realloc,
|
||||
blake3_syscall_enabled, enforce_aligned_host_addrs, libsecp256k1_0_5_upgrade_enabled,
|
||||
memory_ops_syscalls, secp256k1_recover_syscall_enabled,
|
||||
},
|
||||
hash::{Hasher, HASH_BYTES},
|
||||
ic_msg,
|
||||
|
@ -134,10 +133,7 @@ pub fn register_syscalls(
|
|||
)?;
|
||||
|
||||
syscall_registry.register_syscall_by_name(b"sol_sha256", SyscallSha256::call)?;
|
||||
|
||||
if invoke_context.is_feature_active(&keccak256_syscall_enabled::id()) {
|
||||
syscall_registry.register_syscall_by_name(b"sol_keccak256", SyscallKeccak256::call)?;
|
||||
}
|
||||
|
||||
if invoke_context.is_feature_active(&secp256k1_recover_syscall_enabled::id()) {
|
||||
syscall_registry
|
||||
|
@ -148,7 +144,6 @@ pub fn register_syscalls(
|
|||
syscall_registry.register_syscall_by_name(b"sol_blake3", SyscallBlake3::call)?;
|
||||
}
|
||||
|
||||
if invoke_context.is_feature_active(&sysvar_via_syscall::id()) {
|
||||
syscall_registry
|
||||
.register_syscall_by_name(b"sol_get_clock_sysvar", SyscallGetClockSysvar::call)?;
|
||||
syscall_registry.register_syscall_by_name(
|
||||
|
@ -159,7 +154,6 @@ pub fn register_syscalls(
|
|||
.register_syscall_by_name(b"sol_get_fees_sysvar", SyscallGetFeesSysvar::call)?;
|
||||
syscall_registry
|
||||
.register_syscall_by_name(b"sol_get_rent_sysvar", SyscallGetRentSysvar::call)?;
|
||||
}
|
||||
|
||||
if invoke_context.is_feature_active(&memory_ops_syscalls::id()) {
|
||||
syscall_registry.register_syscall_by_name(b"sol_memcpy_", SyscallMemcpy::call)?;
|
||||
|
@ -283,16 +277,15 @@ pub fn bind_syscall_context_objects<'a>(
|
|||
None,
|
||||
)?;
|
||||
|
||||
bind_feature_gated_syscall_context_object!(
|
||||
vm,
|
||||
invoke_context.is_feature_active(&keccak256_syscall_enabled::id()),
|
||||
vm.bind_syscall_context_object(
|
||||
Box::new(SyscallKeccak256 {
|
||||
base_cost: compute_budget.sha256_base_cost,
|
||||
byte_cost: compute_budget.sha256_byte_cost,
|
||||
compute_meter: invoke_context.get_compute_meter(),
|
||||
loader_id,
|
||||
}),
|
||||
);
|
||||
None,
|
||||
)?;
|
||||
|
||||
bind_feature_gated_syscall_context_object!(
|
||||
vm,
|
||||
|
@ -353,42 +346,36 @@ pub fn bind_syscall_context_objects<'a>(
|
|||
}),
|
||||
);
|
||||
|
||||
let is_sysvar_via_syscall_active = invoke_context.is_feature_active(&sysvar_via_syscall::id());
|
||||
|
||||
let invoke_context = Rc::new(RefCell::new(invoke_context));
|
||||
|
||||
bind_feature_gated_syscall_context_object!(
|
||||
vm,
|
||||
is_sysvar_via_syscall_active,
|
||||
vm.bind_syscall_context_object(
|
||||
Box::new(SyscallGetClockSysvar {
|
||||
invoke_context: invoke_context.clone(),
|
||||
loader_id,
|
||||
}),
|
||||
);
|
||||
bind_feature_gated_syscall_context_object!(
|
||||
vm,
|
||||
is_sysvar_via_syscall_active,
|
||||
None,
|
||||
)?;
|
||||
vm.bind_syscall_context_object(
|
||||
Box::new(SyscallGetEpochScheduleSysvar {
|
||||
invoke_context: invoke_context.clone(),
|
||||
loader_id,
|
||||
}),
|
||||
);
|
||||
bind_feature_gated_syscall_context_object!(
|
||||
vm,
|
||||
is_sysvar_via_syscall_active,
|
||||
None,
|
||||
)?;
|
||||
vm.bind_syscall_context_object(
|
||||
Box::new(SyscallGetFeesSysvar {
|
||||
invoke_context: invoke_context.clone(),
|
||||
loader_id,
|
||||
}),
|
||||
);
|
||||
bind_feature_gated_syscall_context_object!(
|
||||
vm,
|
||||
is_sysvar_via_syscall_active,
|
||||
None,
|
||||
)?;
|
||||
vm.bind_syscall_context_object(
|
||||
Box::new(SyscallGetRentSysvar {
|
||||
invoke_context: invoke_context.clone(),
|
||||
loader_id,
|
||||
}),
|
||||
);
|
||||
None,
|
||||
)?;
|
||||
|
||||
// Cross-program invocation syscalls
|
||||
vm.bind_syscall_context_object(
|
||||
|
@ -1690,11 +1677,9 @@ impl<'a> SyscallInvokeSigned<'a> for SyscallInvokeSignedRust<'a> {
|
|||
enforce_aligned_host_addrs,
|
||||
)?;
|
||||
|
||||
if invoke_context.is_feature_active(&cpi_data_cost::id()) {
|
||||
invoke_context.get_compute_meter().consume(
|
||||
data.len() as u64 / invoke_context.get_compute_budget().cpi_bytes_per_unit,
|
||||
)?;
|
||||
}
|
||||
|
||||
let translated = translate(
|
||||
memory_mapping,
|
||||
|
@ -2009,11 +1994,9 @@ impl<'a> SyscallInvokeSigned<'a> for SyscallInvokeSignedC<'a> {
|
|||
)?;
|
||||
let vm_data_addr = account_info.data_addr;
|
||||
|
||||
if invoke_context.is_feature_active(&cpi_data_cost::id()) {
|
||||
invoke_context.get_compute_meter().consume(
|
||||
account_info.data_len / invoke_context.get_compute_budget().cpi_bytes_per_unit,
|
||||
)?;
|
||||
}
|
||||
|
||||
let data = translate_slice_mut::<u8>(
|
||||
memory_mapping,
|
||||
|
@ -2440,7 +2423,6 @@ fn call<'a>(
|
|||
)
|
||||
.into());
|
||||
}
|
||||
if invoke_context.is_feature_active(&update_data_on_realloc::id()) {
|
||||
account_ref.data = translate_slice_mut::<u8>(
|
||||
memory_mapping,
|
||||
account_ref.vm_data_addr,
|
||||
|
@ -2448,14 +2430,6 @@ fn call<'a>(
|
|||
&bpf_loader_deprecated::id(), // Don't care since it is byte aligned
|
||||
true,
|
||||
)?;
|
||||
} else {
|
||||
let _ = translate(
|
||||
memory_mapping,
|
||||
AccessType::Store,
|
||||
account_ref.vm_data_addr,
|
||||
account.data().len() as u64,
|
||||
)?;
|
||||
}
|
||||
*account_ref.ref_to_len_in_vm = account.data().len() as u64;
|
||||
*account_ref.serialized_len_ptr = account.data().len() as u64;
|
||||
}
|
||||
|
|
|
@ -107,30 +107,10 @@ pub mod require_stake_for_gossip {
|
|||
solana_sdk::declare_id!("6oNzd5Z3M2L1xo4Q5hoox7CR2DuW7m1ETLWH5jHJthwa");
|
||||
}
|
||||
|
||||
pub mod cpi_data_cost {
|
||||
solana_sdk::declare_id!("Hrg5bXePPGiAVWZfDHbvjqytSeyBDPAGAQ7v6N5i4gCX");
|
||||
}
|
||||
|
||||
pub mod upgradeable_close_instruction {
|
||||
solana_sdk::declare_id!("FsPaByos3gA9bUEhp3EimQpQPCoSvCEigHod496NmABQ");
|
||||
}
|
||||
|
||||
pub mod sysvar_via_syscall {
|
||||
solana_sdk::declare_id!("7411E6gFQLDhQkdRjmpXwM1hzHMMoYQUjHicmvGPC1Nf");
|
||||
}
|
||||
|
||||
pub mod enforce_aligned_host_addrs {
|
||||
solana_sdk::declare_id!("6Qob9Z4RwGdf599FDVCqsjuKjR8ZFR3oVs2ByRLWBsua");
|
||||
}
|
||||
|
||||
pub mod update_data_on_realloc {
|
||||
solana_sdk::declare_id!("BkPcYCrwHXBoTsv9vMhiRF9gteZmDj3Uwisz9CDjoMKp");
|
||||
}
|
||||
|
||||
pub mod keccak256_syscall_enabled {
|
||||
solana_sdk::declare_id!("7Ua8mFtahVfA3WCY9LoXDAJJdvJRJHckvSSr1dD8FTWc");
|
||||
}
|
||||
|
||||
pub mod stake_program_v4 {
|
||||
solana_sdk::declare_id!("Dc7djyhP9aLfdq2zktpvskeAjpG56msCU1yexpxXiWZb");
|
||||
}
|
||||
|
@ -217,12 +197,7 @@ lazy_static! {
|
|||
(check_init_vote_data::id(), "check initialized Vote data"),
|
||||
(check_program_owner::id(), "limit programs to operating on accounts owned by itself"),
|
||||
(require_stake_for_gossip::id(), "require stakes for propagating crds values through gossip #15561"),
|
||||
(cpi_data_cost::id(), "charge the compute budget for data passed via CPI"),
|
||||
(upgradeable_close_instruction::id(), "close upgradeable buffer accounts"),
|
||||
(sysvar_via_syscall::id(), "provide sysvars via syscalls"),
|
||||
(enforce_aligned_host_addrs::id(), "enforce aligned host addresses"),
|
||||
(update_data_on_realloc::id(), "Retain updated data values modified after realloc via CPI"),
|
||||
(keccak256_syscall_enabled::id(), "keccak256 syscall"),
|
||||
(stake_program_v4::id(), "solana_stake_program v4"),
|
||||
(memory_ops_syscalls::id(), "add syscalls for memory operations"),
|
||||
(secp256k1_recover_syscall_enabled::id(), "secp256k1_recover syscall"),
|
||||
|
|
Loading…
Reference in New Issue