gate libsecp256k1 upgrade to v0.5.0
This commit is contained in:
committed by
mergify[bot]
parent
3a85b77bb5
commit
abe5a0a349
@ -20,8 +20,8 @@ use solana_sdk::{
|
||||
epoch_schedule::EpochSchedule,
|
||||
feature_set::{
|
||||
blake3_syscall_enabled, cpi_data_cost, enforce_aligned_host_addrs,
|
||||
keccak256_syscall_enabled, memory_ops_syscalls, secp256k1_recover_syscall_enabled,
|
||||
sysvar_via_syscall, update_data_on_realloc,
|
||||
keccak256_syscall_enabled, libsecp256k1_0_5_upgrade_enabled, memory_ops_syscalls,
|
||||
secp256k1_recover_syscall_enabled, sysvar_via_syscall, update_data_on_realloc,
|
||||
},
|
||||
hash::{Hasher, HASH_BYTES},
|
||||
ic_msg,
|
||||
@ -346,6 +346,8 @@ pub fn bind_syscall_context_objects<'a>(
|
||||
cost: bpf_compute_budget.secp256k1_recover_cost,
|
||||
compute_meter: invoke_context.get_compute_meter(),
|
||||
loader_id,
|
||||
libsecp256k1_0_5_upgrade_enabled: invoke_context
|
||||
.is_feature_active(&libsecp256k1_0_5_upgrade_enabled::id()),
|
||||
}),
|
||||
);
|
||||
|
||||
@ -1366,6 +1368,7 @@ pub struct SyscallSecp256k1Recover<'a> {
|
||||
cost: u64,
|
||||
compute_meter: Rc<RefCell<dyn ComputeMeter>>,
|
||||
loader_id: &'a Pubkey,
|
||||
libsecp256k1_0_5_upgrade_enabled: bool,
|
||||
}
|
||||
|
||||
impl<'a> SyscallObject<BpfError> for SyscallSecp256k1Recover<'a> {
|
||||
@ -1426,7 +1429,13 @@ impl<'a> SyscallObject<BpfError> for SyscallSecp256k1Recover<'a> {
|
||||
return;
|
||||
}
|
||||
};
|
||||
let signature = match libsecp256k1::Signature::parse_standard_slice(signature) {
|
||||
let sig_parse_result = if self.libsecp256k1_0_5_upgrade_enabled {
|
||||
libsecp256k1::Signature::parse_standard_slice(signature)
|
||||
} else {
|
||||
libsecp256k1::Signature::parse_overflowing_slice(signature)
|
||||
};
|
||||
|
||||
let signature = match sig_parse_result {
|
||||
Ok(sig) => sig,
|
||||
Err(_) => {
|
||||
*result = Ok(Secp256k1RecoverError::InvalidSignature.into());
|
||||
|
Reference in New Issue
Block a user