From 2573b7acc99bc277d8f65320ee1452a251685393 Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Thu, 16 Nov 2023 09:59:53 +0800 Subject: [PATCH] clean feature: libsecp256k1_0_5_upgrade_enabled (#34080) --- programs/bpf_loader/src/syscalls/mod.rs | 17 ++------ sdk/src/secp256k1_instruction.rs | 52 +++++-------------------- 2 files changed, 13 insertions(+), 56 deletions(-) diff --git a/programs/bpf_loader/src/syscalls/mod.rs b/programs/bpf_loader/src/syscalls/mod.rs index a10693bb9fc91a..8e4a0da2f2593c 100644 --- a/programs/bpf_loader/src/syscalls/mod.rs +++ b/programs/bpf_loader/src/syscalls/mod.rs @@ -40,9 +40,9 @@ use { disable_fees_sysvar, enable_alt_bn128_compression_syscall, enable_alt_bn128_syscall, enable_big_mod_exp_syscall, enable_partitioned_epoch_reward, enable_poseidon_syscall, error_on_syscall_bpf_function_hash_collisions, last_restart_slot_sysvar, - libsecp256k1_0_5_upgrade_enabled, reject_callx_r10, - remaining_compute_units_syscall_enabled, stop_sibling_instruction_search_at_parent, - stop_truncating_strings_in_syscalls, switch_to_new_elf_parser, + reject_callx_r10, remaining_compute_units_syscall_enabled, + stop_sibling_instruction_search_at_parent, stop_truncating_strings_in_syscalls, + switch_to_new_elf_parser, }, hash::{Hash, Hasher}, instruction::{ @@ -849,16 +849,7 @@ declare_builtin_function!( let Ok(recovery_id) = libsecp256k1::RecoveryId::parse(adjusted_recover_id_val) else { return Ok(Secp256k1RecoverError::InvalidRecoveryId.into()); }; - let sig_parse_result = if invoke_context - .feature_set - .is_active(&libsecp256k1_0_5_upgrade_enabled::id()) - { - libsecp256k1::Signature::parse_standard_slice(signature) - } else { - libsecp256k1::Signature::parse_overflowing_slice(signature) - }; - - let Ok(signature) = sig_parse_result else { + let Ok(signature) = libsecp256k1::Signature::parse_standard_slice(signature) else { return Ok(Secp256k1RecoverError::InvalidSignature.into()); }; diff --git a/sdk/src/secp256k1_instruction.rs b/sdk/src/secp256k1_instruction.rs index fc7cfaf7456116..e1407d1fb29359 100644 --- a/sdk/src/secp256k1_instruction.rs +++ b/sdk/src/secp256k1_instruction.rs @@ -790,8 +790,7 @@ use { crate::{ feature_set::{ - libsecp256k1_0_5_upgrade_enabled, libsecp256k1_fail_on_bad_count, - libsecp256k1_fail_on_bad_count2, FeatureSet, + libsecp256k1_fail_on_bad_count, libsecp256k1_fail_on_bad_count2, FeatureSet, }, instruction::Instruction, precompiles::PrecompileError, @@ -973,17 +972,10 @@ pub fn verify( return Err(PrecompileError::InvalidSignature); } - let sig_parse_result = if feature_set.is_active(&libsecp256k1_0_5_upgrade_enabled::id()) { - libsecp256k1::Signature::parse_standard_slice( - &signature_instruction[sig_start..sig_end], - ) - } else { - libsecp256k1::Signature::parse_overflowing_slice( - &signature_instruction[sig_start..sig_end], - ) - }; - - let signature = sig_parse_result.map_err(|_| PrecompileError::InvalidSignature)?; + let signature = libsecp256k1::Signature::parse_standard_slice( + &signature_instruction[sig_start..sig_end], + ) + .map_err(|_| PrecompileError::InvalidSignature)?; let recovery_id = libsecp256k1::RecoveryId::parse(signature_instruction[sig_end]) .map_err(|_| PrecompileError::InvalidRecoveryId)?; @@ -1068,14 +1060,7 @@ pub mod test { instruction_data[0] = num_signatures; let writer = std::io::Cursor::new(&mut instruction_data[1..]); bincode::serialize_into(writer, &offsets).unwrap(); - let mut feature_set = FeatureSet::all_enabled(); - feature_set - .active - .remove(&libsecp256k1_0_5_upgrade_enabled::id()); - feature_set - .inactive - .insert(libsecp256k1_0_5_upgrade_enabled::id()); - + let feature_set = FeatureSet::all_enabled(); verify(&instruction_data, &[&[0u8; 100]], &feature_set) } @@ -1089,13 +1074,7 @@ pub mod test { let writer = std::io::Cursor::new(&mut instruction_data[1..]); bincode::serialize_into(writer, &offsets).unwrap(); instruction_data.truncate(instruction_data.len() - 1); - let mut feature_set = FeatureSet::all_enabled(); - feature_set - .active - .remove(&libsecp256k1_0_5_upgrade_enabled::id()); - feature_set - .inactive - .insert(libsecp256k1_0_5_upgrade_enabled::id()); + let feature_set = FeatureSet::all_enabled(); assert_eq!( verify(&instruction_data, &[&[0u8; 100]], &feature_set), @@ -1224,13 +1203,7 @@ pub mod test { instruction_data[0] = 0; let writer = std::io::Cursor::new(&mut instruction_data[1..]); bincode::serialize_into(writer, &offsets).unwrap(); - let mut feature_set = FeatureSet::all_enabled(); - feature_set - .active - .remove(&libsecp256k1_0_5_upgrade_enabled::id()); - feature_set - .inactive - .insert(libsecp256k1_0_5_upgrade_enabled::id()); + let feature_set = FeatureSet::all_enabled(); assert_eq!( verify(&instruction_data, &[&[0u8; 100]], &feature_set), @@ -1251,14 +1224,7 @@ pub mod test { let message_arr = b"hello"; let mut secp_instruction = new_secp256k1_instruction(&secp_privkey, message_arr); let mint_keypair = Keypair::new(); - let mut feature_set = feature_set::FeatureSet::all_enabled(); - feature_set - .active - .remove(&feature_set::libsecp256k1_0_5_upgrade_enabled::id()); - feature_set - .inactive - .insert(feature_set::libsecp256k1_0_5_upgrade_enabled::id()); - let feature_set = feature_set; + let feature_set = feature_set::FeatureSet::all_enabled(); let tx = Transaction::new_signed_with_payer( &[secp_instruction.clone()],