* Remove native id check in pda creation (#19595)
(cherry picked from commit 529fefc7cc
)
# Conflicts:
# programs/bpf/rust/invoke/src/lib.rs
# programs/bpf_loader/src/syscalls.rs
# sdk/src/feature_set.rs
* resolve conflicts
Co-authored-by: Jack May <jack@solana.com>
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
#![allow(clippy::integer_arithmetic)]
|
||||
use crate::{
|
||||
bpf_loader, bpf_loader_deprecated, config, decode_error::DecodeError, feature, hash::hashv,
|
||||
secp256k1_program, stake, system_program, sysvar, vote,
|
||||
};
|
||||
use crate::{decode_error::DecodeError, hash::hashv};
|
||||
|
||||
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
|
||||
use num_derive::{FromPrimitive, ToPrimitive};
|
||||
@@ -214,10 +211,6 @@ impl Pubkey {
|
||||
}
|
||||
}
|
||||
|
||||
if program_id.is_native_program_id() {
|
||||
return Err(PubkeyError::IllegalOwner);
|
||||
}
|
||||
|
||||
// Perform the calculation inline, calling this from within a program is
|
||||
// not supported
|
||||
#[cfg(not(target_arch = "bpf"))]
|
||||
@@ -368,22 +361,6 @@ impl Pubkey {
|
||||
#[cfg(not(target_arch = "bpf"))]
|
||||
crate::program_stubs::sol_log(&self.to_string());
|
||||
}
|
||||
|
||||
pub fn is_native_program_id(&self) -> bool {
|
||||
let all_program_ids = [
|
||||
bpf_loader::id(),
|
||||
bpf_loader_deprecated::id(),
|
||||
feature::id(),
|
||||
config::program::id(),
|
||||
stake::program::id(),
|
||||
stake::config::id(),
|
||||
vote::program::id(),
|
||||
secp256k1_program::id(),
|
||||
system_program::id(),
|
||||
sysvar::id(),
|
||||
];
|
||||
all_program_ids.contains(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<[u8]> for Pubkey {
|
||||
@@ -600,20 +577,6 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_native_program_id() {
|
||||
assert!(bpf_loader::id().is_native_program_id());
|
||||
assert!(bpf_loader_deprecated::id().is_native_program_id());
|
||||
assert!(config::program::id().is_native_program_id());
|
||||
assert!(feature::id().is_native_program_id());
|
||||
assert!(secp256k1_program::id().is_native_program_id());
|
||||
assert!(stake::program::id().is_native_program_id());
|
||||
assert!(stake::config::id().is_native_program_id());
|
||||
assert!(system_program::id().is_native_program_id());
|
||||
assert!(sysvar::id().is_native_program_id());
|
||||
assert!(vote::program::id().is_native_program_id());
|
||||
}
|
||||
|
||||
fn pubkey_from_seed_by_marker(marker: &[u8]) -> Result<Pubkey, PubkeyError> {
|
||||
let key = Pubkey::new_unique();
|
||||
let owner = Pubkey::default();
|
||||
|
@@ -191,6 +191,10 @@ pub mod demote_program_write_locks {
|
||||
solana_sdk::declare_id!("3E3jV7v9VcdJL8iYZUMax9DiDno8j7EWUVbhm9RtShj2");
|
||||
}
|
||||
|
||||
pub mod allow_native_ids {
|
||||
solana_sdk::declare_id!("GVnDbNkECwrzLM7aVBGWpBYo3yH1ACaXB4ottNX8pedZ");
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
/// Map of feature identifiers to user-visible description
|
||||
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
|
||||
@@ -239,6 +243,7 @@ lazy_static! {
|
||||
(close_upgradeable_program_accounts::id(), "enable closing upgradeable program accounts"),
|
||||
(stake_program_advance_activating_credits_observed::id(), "Enable advancing credits observed for activation epoch #19309"),
|
||||
(demote_program_write_locks::id(), "demote program write locks to readonly #19593"),
|
||||
(allow_native_ids::id(), "allow native program ids in program derived addresses"),
|
||||
/*************** ADD NEW FEATURES HERE ***************/
|
||||
]
|
||||
.iter()
|
||||
|
Reference in New Issue
Block a user