Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated symbols from solana-sdk #1953

Merged
merged 7 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions sdk/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,15 +675,6 @@ impl AccountSharedData {
pub type InheritableAccountFields = (u64, Epoch);
pub const DUMMY_INHERITABLE_ACCOUNT_FIELDS: InheritableAccountFields = (1, INITIAL_RENT_EPOCH);

/// Create an `Account` from a `Sysvar`.
#[deprecated(
since = "1.5.17",
note = "Please use `create_account_for_test` instead"
)]
pub fn create_account<S: Sysvar>(sysvar: &S, lamports: u64) -> Account {
create_account_with_fields(sysvar, (lamports, INITIAL_RENT_EPOCH))
}

pub fn create_account_with_fields<S: Sysvar>(
sysvar: &S,
(lamports, rent_epoch): InheritableAccountFields,
Expand All @@ -700,17 +691,6 @@ pub fn create_account_for_test<S: Sysvar>(sysvar: &S) -> Account {
}

/// Create an `Account` from a `Sysvar`.
#[deprecated(
since = "1.5.17",
note = "Please use `create_account_shared_data_for_test` instead"
)]
pub fn create_account_shared_data<S: Sysvar>(sysvar: &S, lamports: u64) -> AccountSharedData {
AccountSharedData::from(create_account_with_fields(
sysvar,
(lamports, INITIAL_RENT_EPOCH),
))
}

pub fn create_account_shared_data_with_fields<S: Sysvar>(
sysvar: &S,
fields: InheritableAccountFields,
Expand Down
27 changes: 0 additions & 27 deletions sdk/src/entrypoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,3 @@
//! [`bpf_loader`]: crate::bpf_loader
pub use solana_program::entrypoint::*;

#[macro_export]
#[deprecated(
since = "1.4.3",
note = "use solana_program::entrypoint::entrypoint instead"
)]
macro_rules! entrypoint {
($process_instruction:ident) => {
#[cfg(all(not(feature = "custom-heap"), not(test)))]
#[global_allocator]
static A: $crate::entrypoint::BumpAllocator = $crate::entrypoint::BumpAllocator {
start: $crate::entrypoint::HEAP_START_ADDRESS,
len: $crate::entrypoint::HEAP_LENGTH,
};

/// # Safety
#[no_mangle]
pub unsafe extern "C" fn entrypoint(input: *mut u8) -> u64 {
let (program_id, accounts, instruction_data) =
unsafe { $crate::entrypoint::deserialize(input) };
match $process_instruction(&program_id, &accounts, &instruction_data) {
Ok(()) => $crate::entrypoint::SUCCESS,
Err(error) => error.into(),
}
}
};
}
20 changes: 0 additions & 20 deletions sdk/src/entrypoint_deprecated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,3 @@
//! [`bpf_loader_deprecated`]: crate::bpf_loader_deprecated
pub use solana_program::entrypoint_deprecated::*;

#[macro_export]
#[deprecated(
since = "1.4.3",
note = "use solana_program::entrypoint::entrypoint instead"
)]
macro_rules! entrypoint_deprecated {
($process_instruction:ident) => {
/// # Safety
#[no_mangle]
pub unsafe extern "C" fn entrypoint(input: *mut u8) -> u64 {
let (program_id, accounts, instruction_data) =
unsafe { $crate::entrypoint_deprecated::deserialize(input) };
match $process_instruction(&program_id, &accounts, &instruction_data) {
Ok(()) => $crate::entrypoint_deprecated::SUCCESS,
Err(error) => error.into(),
}
}
};
}
10 changes: 0 additions & 10 deletions sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,6 @@ pub use solana_sdk_macro::pubkey;
/// Convenience macro to define multiple static public keys.
pub use solana_sdk_macro::pubkeys;

// Unused `solana_sdk::program_stubs!()` macro retained for source backwards compatibility with older programs
#[macro_export]
#[deprecated(
since = "1.4.3",
note = "program_stubs macro is obsolete and can be safely removed"
)]
macro_rules! program_stubs {
() => {};
}

/// Convenience macro for `AddAssign` with saturating arithmetic.
/// Replace by `std::num::Saturating` once stable
#[macro_export]
Expand Down
11 changes: 0 additions & 11 deletions sdk/src/log.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
#![cfg(feature = "program")]

pub use solana_program::log::*;

#[macro_export]
#[deprecated(
since = "1.4.3",
note = "Please use `solana_program::log::info` instead"
)]
macro_rules! info {
($msg:expr) => {
$crate::log::sol_log($msg)
};
}
15 changes: 2 additions & 13 deletions sdk/src/native_loader.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
//! The native loader native program.
use crate::{
account::{
Account, AccountSharedData, InheritableAccountFields, DUMMY_INHERITABLE_ACCOUNT_FIELDS,
},
clock::INITIAL_RENT_EPOCH,
use crate::account::{
Account, AccountSharedData, InheritableAccountFields, DUMMY_INHERITABLE_ACCOUNT_FIELDS,
};

crate::declare_id!("NativeLoader1111111111111111111111111111111");

/// Create an executable account with the given shared object name.
#[deprecated(
since = "1.5.17",
note = "Please use `create_loadable_account_for_test` instead"
)]
pub fn create_loadable_account(name: &str, lamports: u64) -> AccountSharedData {
create_loadable_account_with_fields(name, (lamports, INITIAL_RENT_EPOCH))
}

pub fn create_loadable_account_with_fields(
name: &str,
(lamports, rent_epoch): InheritableAccountFields,
Expand Down
8 changes: 0 additions & 8 deletions sdk/src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ pub struct Signature(GenericArray<u8, U64>);
impl solana_sanitize::Sanitize for Signature {}

impl Signature {
#[deprecated(
since = "1.16.4",
note = "Please use 'Signature::from' or 'Signature::try_from' instead"
)]
pub fn new(signature_slice: &[u8]) -> Self {
Self(GenericArray::clone_from_slice(signature_slice))
}

pub fn new_unique() -> Self {
Self::from(std::array::from_fn(|_| rand::random()))
}
Expand Down
39 changes: 0 additions & 39 deletions sdk/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1125,17 +1125,6 @@ pub fn uses_durable_nonce(tx: &Transaction) -> Option<&CompiledInstruction> {
})
}

#[deprecated]
pub fn get_nonce_pubkey_from_instruction<'a>(
ix: &CompiledInstruction,
tx: &'a Transaction,
) -> Option<&'a Pubkey> {
ix.accounts.first().and_then(|idx| {
let idx = *idx as usize;
tx.message().account_keys.get(idx)
})
}

#[cfg(test)]
mod tests {
#![allow(deprecated)]
Expand Down Expand Up @@ -1630,34 +1619,6 @@ mod tests {
assert!(uses_durable_nonce(&tx).is_none());
}

#[test]
fn get_nonce_pub_from_ix_ok() {
let (_, nonce_pubkey, tx) = nonced_transfer_tx();
let nonce_ix = uses_durable_nonce(&tx).unwrap();
assert_eq!(
get_nonce_pubkey_from_instruction(nonce_ix, &tx),
Some(&nonce_pubkey),
);
}

#[test]
fn get_nonce_pub_from_ix_no_accounts_fail() {
let (_, _, tx) = nonced_transfer_tx();
let nonce_ix = uses_durable_nonce(&tx).unwrap();
let mut nonce_ix = nonce_ix.clone();
nonce_ix.accounts.clear();
assert_eq!(get_nonce_pubkey_from_instruction(&nonce_ix, &tx), None,);
}

#[test]
fn get_nonce_pub_from_ix_bad_acc_idx_fail() {
let (_, _, tx) = nonced_transfer_tx();
let nonce_ix = uses_durable_nonce(&tx).unwrap();
let mut nonce_ix = nonce_ix.clone();
nonce_ix.accounts[0] = 255u8;
assert_eq!(get_nonce_pubkey_from_instruction(&nonce_ix, &tx), None,);
}

#[test]
fn tx_keypair_pubkey_mismatch() {
let from_keypair = Keypair::new();
Expand Down