Feature cleanup (#19528)

This commit is contained in:
Jack May
2021-08-31 14:51:26 -07:00
committed by GitHub
parent e1939688c2
commit 5cf8d8795b
7 changed files with 32 additions and 65 deletions

View File

@ -23,7 +23,7 @@ use solana_sdk::{
feature_set::{ feature_set::{
blake3_syscall_enabled, close_upgradeable_program_accounts, disable_fees_sysvar, blake3_syscall_enabled, close_upgradeable_program_accounts, disable_fees_sysvar,
enforce_aligned_host_addrs, libsecp256k1_0_5_upgrade_enabled, mem_overlap_fix, enforce_aligned_host_addrs, libsecp256k1_0_5_upgrade_enabled, mem_overlap_fix,
memory_ops_syscalls, secp256k1_recover_syscall_enabled, secp256k1_recover_syscall_enabled,
}, },
hash::{Hasher, HASH_BYTES}, hash::{Hasher, HASH_BYTES},
ic_msg, ic_msg,
@ -158,12 +158,10 @@ pub fn register_syscalls(
syscall_registry syscall_registry
.register_syscall_by_name(b"sol_get_rent_sysvar", SyscallGetRentSysvar::call)?; .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)?;
syscall_registry.register_syscall_by_name(b"sol_memcpy_", SyscallMemcpy::call)?; syscall_registry.register_syscall_by_name(b"sol_memmove_", SyscallMemmove::call)?;
syscall_registry.register_syscall_by_name(b"sol_memmove_", SyscallMemmove::call)?; syscall_registry.register_syscall_by_name(b"sol_memcmp_", SyscallMemcmp::call)?;
syscall_registry.register_syscall_by_name(b"sol_memcmp_", SyscallMemcmp::call)?; syscall_registry.register_syscall_by_name(b"sol_memset_", SyscallMemset::call)?;
syscall_registry.register_syscall_by_name(b"sol_memset_", SyscallMemset::call)?;
}
// Cross-program invocation syscalls // Cross-program invocation syscalls
syscall_registry syscall_registry
@ -290,43 +288,40 @@ pub fn bind_syscall_context_objects<'a>(
None, None,
)?; )?;
bind_feature_gated_syscall_context_object!( vm.bind_syscall_context_object(
vm,
invoke_context.is_feature_active(&memory_ops_syscalls::id()),
Box::new(SyscallMemcpy { Box::new(SyscallMemcpy {
cost: invoke_context.get_compute_budget().cpi_bytes_per_unit, cost: invoke_context.get_compute_budget().cpi_bytes_per_unit,
compute_meter: invoke_context.get_compute_meter(), compute_meter: invoke_context.get_compute_meter(),
loader_id, loader_id,
mem_overlap_fix: invoke_context.is_feature_active(&mem_overlap_fix::id()), mem_overlap_fix: invoke_context.is_feature_active(&mem_overlap_fix::id()),
}), }),
); None,
bind_feature_gated_syscall_context_object!( )?;
vm, vm.bind_syscall_context_object(
invoke_context.is_feature_active(&memory_ops_syscalls::id()),
Box::new(SyscallMemmove { Box::new(SyscallMemmove {
cost: invoke_context.get_compute_budget().cpi_bytes_per_unit, cost: invoke_context.get_compute_budget().cpi_bytes_per_unit,
compute_meter: invoke_context.get_compute_meter(), compute_meter: invoke_context.get_compute_meter(),
loader_id, loader_id,
}), }),
); None,
bind_feature_gated_syscall_context_object!( )?;
vm, vm.bind_syscall_context_object(
invoke_context.is_feature_active(&memory_ops_syscalls::id()),
Box::new(SyscallMemcmp { Box::new(SyscallMemcmp {
cost: invoke_context.get_compute_budget().cpi_bytes_per_unit, cost: invoke_context.get_compute_budget().cpi_bytes_per_unit,
compute_meter: invoke_context.get_compute_meter(), compute_meter: invoke_context.get_compute_meter(),
loader_id, loader_id,
}), }),
); None,
bind_feature_gated_syscall_context_object!( )?;
vm, vm.bind_syscall_context_object(
invoke_context.is_feature_active(&memory_ops_syscalls::id()),
Box::new(SyscallMemset { Box::new(SyscallMemset {
cost: invoke_context.get_compute_budget().cpi_bytes_per_unit, cost: invoke_context.get_compute_budget().cpi_bytes_per_unit,
compute_meter: invoke_context.get_compute_meter(), compute_meter: invoke_context.get_compute_meter(),
loader_id, loader_id,
}), }),
); None,
)?;
bind_feature_gated_syscall_context_object!( bind_feature_gated_syscall_context_object!(
vm, vm,
invoke_context.is_feature_active(&blake3_syscall_enabled::id()), invoke_context.is_feature_active(&blake3_syscall_enabled::id()),

View File

@ -24,9 +24,7 @@ pub fn process_instruction(
let config_keyed_account = &mut keyed_account_at_index(keyed_accounts, 0)?; let config_keyed_account = &mut keyed_account_at_index(keyed_accounts, 0)?;
let current_data: ConfigKeys = { let current_data: ConfigKeys = {
let config_account = config_keyed_account.try_account_ref_mut()?; let config_account = config_keyed_account.try_account_ref_mut()?;
if invoke_context.is_feature_active(&feature_set::check_program_owner::id()) if config_account.owner() != &crate::id() {
&& config_account.owner() != &crate::id()
{
return Err(InstructionError::InvalidAccountOwner); return Err(InstructionError::InvalidAccountOwner);
} }

View File

@ -38,11 +38,7 @@ pub fn process_instruction(
let me = &keyed_account_at_index(keyed_accounts, 0)?; let me = &keyed_account_at_index(keyed_accounts, 0)?;
if me.owner()? != id() { if me.owner()? != id() {
if invoke_context.is_feature_active(&feature_set::check_program_owner::id()) { return Err(InstructionError::InvalidAccountOwner);
return Err(InstructionError::InvalidAccountOwner);
} else {
return Err(InstructionError::IncorrectProgramId);
}
} }
match limited_deserialize(data)? { match limited_deserialize(data)? {

View File

@ -321,9 +321,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)?;
if invoke_context.is_feature_active(&feature_set::check_program_owner::id()) if me.owner()? != id() {
&& me.owner()? != id()
{
return Err(InstructionError::InvalidAccountOwner); return Err(InstructionError::InvalidAccountOwner);
} }

View File

@ -247,9 +247,7 @@ impl Accounts {
payer_index = Some(i); payer_index = Some(i);
} }
if solana_sdk::sysvar::instructions::check_id(key) if solana_sdk::sysvar::instructions::check_id(key) {
&& feature_set.is_active(&feature_set::instructions_sysvar_enabled::id())
{
if message.is_writable(i) { if message.is_writable(i) {
return Err(TransactionError::InvalidAccountIndex); return Err(TransactionError::InvalidAccountIndex);
} }

View File

@ -10,8 +10,7 @@ use solana_sdk::{
account::{AccountSharedData, ReadableAccount, WritableAccount}, account::{AccountSharedData, ReadableAccount, WritableAccount},
compute_budget::ComputeBudget, compute_budget::ComputeBudget,
feature_set::{ feature_set::{
instructions_sysvar_enabled, neon_evm_compute_budget, tx_wide_compute_cap, neon_evm_compute_budget, tx_wide_compute_cap, updated_verify_policy, FeatureSet,
updated_verify_policy, FeatureSet,
}, },
fee_calculator::FeeCalculator, fee_calculator::FeeCalculator,
hash::Hash, hash::Hash,
@ -477,16 +476,14 @@ impl MessageProcessor {
) -> Result<(), InstructionError> { ) -> Result<(), InstructionError> {
// Fixup the special instructions key if present // Fixup the special instructions key if present
// before the account pre-values are taken care of // before the account pre-values are taken care of
if feature_set.is_active(&instructions_sysvar_enabled::id()) { for (pubkey, accont) in accounts.iter().take(message.account_keys.len()) {
for (pubkey, accont) in accounts.iter().take(message.account_keys.len()) { if instructions::check_id(pubkey) {
if instructions::check_id(pubkey) { let mut mut_account_ref = accont.borrow_mut();
let mut mut_account_ref = accont.borrow_mut(); instructions::store_current_index(
instructions::store_current_index( mut_account_ref.data_as_mut_slice(),
mut_account_ref.data_as_mut_slice(), instruction_index as u16,
instruction_index as u16, );
); break;
break;
}
} }
} }

View File

@ -26,10 +26,6 @@ use solana_sdk::{
}; };
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
pub mod instructions_sysvar_enabled {
solana_sdk::declare_id!("EnvhHCLvg55P7PDtbvR1NwuTuAeodqpusV3MR5QEK8gs");
}
pub mod deprecate_rewards_sysvar { pub mod deprecate_rewards_sysvar {
solana_sdk::declare_id!("GaBtBJvmS4Arjj5W1NmFcyvPjsHN38UGYDq2MDwbs9Qu"); solana_sdk::declare_id!("GaBtBJvmS4Arjj5W1NmFcyvPjsHN38UGYDq2MDwbs9Qu");
} }
@ -87,10 +83,6 @@ pub mod check_init_vote_data {
solana_sdk::declare_id!("3ccR6QpxGYsAbWyfevEtBNGfWV4xBffxRj2tD6A9i39F"); solana_sdk::declare_id!("3ccR6QpxGYsAbWyfevEtBNGfWV4xBffxRj2tD6A9i39F");
} }
pub mod check_program_owner {
solana_sdk::declare_id!("5XnbR5Es9YXEARRuP6mdvoxiW3hx5atNNeBmwVd8P3QD");
}
pub mod enforce_aligned_host_addrs { pub mod enforce_aligned_host_addrs {
solana_sdk::declare_id!("6Qob9Z4RwGdf599FDVCqsjuKjR8ZFR3oVs2ByRLWBsua"); solana_sdk::declare_id!("6Qob9Z4RwGdf599FDVCqsjuKjR8ZFR3oVs2ByRLWBsua");
} }
@ -99,10 +91,6 @@ pub mod stake_program_v4 {
solana_sdk::declare_id!("Dc7djyhP9aLfdq2zktpvskeAjpG56msCU1yexpxXiWZb"); solana_sdk::declare_id!("Dc7djyhP9aLfdq2zktpvskeAjpG56msCU1yexpxXiWZb");
} }
pub mod memory_ops_syscalls {
solana_sdk::declare_id!("ENQi37wsVhTvFz2gUiZAAbqFEWGN2jwFsqdEDTE8A4MU");
}
pub mod secp256k1_recover_syscall_enabled { pub mod secp256k1_recover_syscall_enabled {
solana_sdk::declare_id!("6RvdSWHh8oh72Dp7wMTS2DBkf3fRPtChfNrAo3cZZoXJ"); solana_sdk::declare_id!("6RvdSWHh8oh72Dp7wMTS2DBkf3fRPtChfNrAo3cZZoXJ");
} }
@ -202,8 +190,7 @@ pub mod close_upgradeable_program_accounts {
lazy_static! { lazy_static! {
/// Map of feature identifiers to user-visible description /// Map of feature identifiers to user-visible description
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [ pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
(instructions_sysvar_enabled::id(), "instructions sysvar"), (deprecate_rewards_sysvar::id(), "deprecate unused rewards sysvar"),
(deprecate_rewards_sysvar::id(), "deprecate unused rewards sysvar"),
(pico_inflation::id(), "pico inflation"), (pico_inflation::id(), "pico inflation"),
(full_inflation::devnet_and_testnet::id(), "full inflation on devnet and testnet"), (full_inflation::devnet_and_testnet::id(), "full inflation on devnet and testnet"),
(spl_token_v2_multisig_fix::id(), "spl-token multisig fix"), (spl_token_v2_multisig_fix::id(), "spl-token multisig fix"),
@ -216,10 +203,8 @@ lazy_static! {
(full_inflation::mainnet::certusone::vote::id(), "community vote allowing Certus One to enable full inflation"), (full_inflation::mainnet::certusone::vote::id(), "community vote allowing Certus One to enable full inflation"),
(warp_timestamp_again::id(), "warp timestamp again, adjust bounding to 25% fast 80% slow #15204"), (warp_timestamp_again::id(), "warp timestamp again, adjust bounding to 25% fast 80% slow #15204"),
(check_init_vote_data::id(), "check initialized Vote data"), (check_init_vote_data::id(), "check initialized Vote data"),
(check_program_owner::id(), "limit programs to operating on accounts owned by itself"),
(enforce_aligned_host_addrs::id(), "enforce aligned host addresses"), (enforce_aligned_host_addrs::id(), "enforce aligned host addresses"),
(stake_program_v4::id(), "solana_stake_program v4"), (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"), (secp256k1_recover_syscall_enabled::id(), "secp256k1_recover syscall"),
(add_missing_program_error_mappings::id(), "add missing program error mappings"), (add_missing_program_error_mappings::id(), "add missing program error mappings"),
(system_transfer_zero_check::id(), "perform all checks for transfers of 0 lamports"), (system_transfer_zero_check::id(), "perform all checks for transfers of 0 lamports"),