Skip to content

Commit 5972367

Browse files
committed
Deprecate re-exports more loudly
#### Problem There are many different crates and types that we would like to remove from the sdk, but they are still re-exported from solana-sdk and solana-program. The re-exports have a `#[deprecated(...)]` attribute, but they aren't flagged to downstream users. #### Summary of changes Make the re-export deprecations louder by creating a deprecated module and re-exporting from in there. These are the types affected * `DecodeError`: this trait isn't all that useful, and is set to be removed entirely with anza-xyz#104, so deprecate it here These are the crates to no longer re-export from solana-program because they will be moved to program-specific repos: * `address_lookup_table` -> `solana_address_lookup_table_interface` * `bpf_loader_upgradeable` -> `solana_loader_v3_interface` * `loader_upgradeable_instruction` -> `solana_loader_v3_interface::instruction` * `loader_v4` -> `solana_loader_v4_interface` * `loader_v4_instruction` -> `solana_loader_v4_interface::instruction` * `nonce` -> `solana_nonce` * `feature` -> `solana_feature_gate_interface` * `loader_instruction` -> `solana_loader_v2_interface` * `vote` -> `solana_vote_interface` * `stake` -> `solana_stake_interface` * `stake_history` -> `solana_stake_interface::stake_history` * `system_instruction` -> `solana_system_interface` * `system_program` -> `solana_sdk_ids::system_program` (not sure about this one) Separately, `solana_message` and `solana_sanitize` are no longer re-exported. They never quite fit in `solana_program`, and caused more annoyance than anything else. The re-exports remain in `solana_sdk`. `solana-decode-error` will be removed entirely, so its deprecation is louder too. For `solana-sdk`, there are many types that just don't belong, so stop re-exporting these: * `commitment_config` -> `solana_commitment_config` * `genesis_config` -> `solana_genesis_config` * `hard_forks` -> `solana_hard_forks` * `rent_collector` -> `solana_rent_collector` * `alt_bn128` -> `solana_bn254` * `client` -> `solana_client_traits` * `compute_budget` -> `solana_compute_budget_interface` * `derivation_path` -> `solana_derivation_path` * `ed25519_instruction` -> `solana_ed25519_program` * `nonce_account` -> `solana_nonce_account` * `packet` -> `solana_packet` * `poh_config` -> `solana_poh_config` * `quic` -> `solana_quic_definitions` * `rent_debits` -> `solana_rent_debits` * `secp256k1_instruction` -> `solana_secp256k1_program` * `secp256k1_recover` -> `solana_secp256k1_recover` * `system_transaction` -> `solana_system_transaction` * `exit` -> `solana_validator_exit`
1 parent 691d306 commit 5972367

File tree

19 files changed

+264
-107
lines changed

19 files changed

+264
-107
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

decode-error/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use num_traits::FromPrimitive;
2121
/// [`ProgramError`]: https://docs.rs/solana-program-error/latest/solana_program_error/enum.ProgramError.html
2222
/// [`ProgramError::Custom`]: https://docs.rs/solana-program-error/latest/solana_program_error/enum.ProgramError.html#variant.Custom
2323
/// [`ToPrimitive`]: num_traits::ToPrimitive
24+
#[deprecated(since = "2.3.0", note = "Use `num_traits::FromPrimitive` instead")]
2425
pub trait DecodeError<E> {
2526
fn decode_custom_error_to_enum(custom: u32) -> Option<E>
2627
where
@@ -32,6 +33,7 @@ pub trait DecodeError<E> {
3233
}
3334

3435
#[cfg(test)]
36+
#[allow(deprecated)]
3537
mod tests {
3638
use {super::*, num_derive::FromPrimitive};
3739

precompile-error/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// Precompile errors
2-
use {core::fmt, solana_decode_error::DecodeError};
2+
use core::fmt;
33

44
/// Precompile errors
55
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -69,7 +69,8 @@ impl fmt::Display for PrecompileError {
6969
}
7070
}
7171

72-
impl<T> DecodeError<T> for PrecompileError {
72+
#[allow(deprecated)]
73+
impl<T> solana_decode_error::DecodeError<T> for PrecompileError {
7374
fn type_of() -> &'static str {
7475
"PrecompileError"
7576
}

program-error/src/lib.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use serde_derive::{Deserialize, Serialize};
99
use {
1010
core::fmt,
1111
num_traits::FromPrimitive,
12-
solana_decode_error::DecodeError,
1312
solana_instruction::error::{
1413
InstructionError, ACCOUNT_ALREADY_INITIALIZED, ACCOUNT_BORROW_FAILED,
1514
ACCOUNT_DATA_TOO_SMALL, ACCOUNT_NOT_RENT_EXEMPT, ARITHMETIC_OVERFLOW, BORSH_IO_ERROR,
@@ -126,17 +125,26 @@ impl fmt::Display for ProgramError {
126125
since = "2.2.2",
127126
note = "Use `ToStr` instead with `solana_msg::msg!` or any other logging"
128127
)]
128+
#[allow(deprecated)]
129129
pub trait PrintProgramError {
130130
fn print<E>(&self)
131131
where
132-
E: 'static + std::error::Error + DecodeError<E> + PrintProgramError + FromPrimitive;
132+
E: 'static
133+
+ std::error::Error
134+
+ solana_decode_error::DecodeError<E>
135+
+ PrintProgramError
136+
+ FromPrimitive;
133137
}
134138

135139
#[allow(deprecated)]
136140
impl PrintProgramError for ProgramError {
137141
fn print<E>(&self)
138142
where
139-
E: 'static + std::error::Error + DecodeError<E> + PrintProgramError + FromPrimitive,
143+
E: 'static
144+
+ std::error::Error
145+
+ solana_decode_error::DecodeError<E>
146+
+ PrintProgramError
147+
+ FromPrimitive,
140148
{
141149
match self {
142150
Self::Custom(error) => {

program/src/address_lookup_table.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
#[deprecated(
2-
since = "2.2.0",
3-
note = "Use solana-address-lookup-table interface instead"
1+
#![deprecated(
2+
since = "2.3.0",
3+
note = "Use solana-address-lookup-table-interface and solana-message instead"
44
)]
5-
pub use solana_address_lookup_table_interface::{error, instruction, program, state};
6-
pub use solana_message::AddressLookupTableAccount;
5+
6+
pub use {
7+
solana_address_lookup_table_interface::{error, instruction, program, state},
8+
solana_message::AddressLookupTableAccount,
9+
};

program/src/bpf_loader_upgradeable.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#[deprecated(since = "2.2.0", note = "Use solana-loader-v3-interface instead")]
1+
#![deprecated(since = "2.3.0", note = "Use solana-loader-v3-interface instead")]
2+
23
#[allow(deprecated)]
34
pub use solana_loader_v3_interface::{
45
get_program_data_address,

program/src/lib.rs

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -483,19 +483,19 @@ pub mod hash;
483483
pub mod incinerator;
484484
pub mod instruction;
485485
pub mod lamports;
486+
#[deprecated(
487+
since = "2.3.0",
488+
note = "Use solana_loader_v3_interface::instruction instead"
489+
)]
486490
pub mod loader_upgradeable_instruction {
487-
#[deprecated(
488-
since = "2.2.0",
489-
note = "Use solana_loader_v3_interface::instruction instead"
490-
)]
491491
pub use solana_loader_v3_interface::instruction::UpgradeableLoaderInstruction;
492492
}
493493
pub mod loader_v4;
494+
#[deprecated(
495+
since = "2.3.0",
496+
note = "Use solana_loader_v4_interface::instruction instead"
497+
)]
494498
pub mod loader_v4_instruction {
495-
#[deprecated(
496-
since = "2.2.0",
497-
note = "Use solana_loader_v4_interface::instruction instead"
498-
)]
499499
pub use solana_loader_v4_interface::instruction::LoaderV4Instruction;
500500
}
501501
pub mod log;
@@ -530,29 +530,37 @@ pub use solana_borsh::v1 as borsh1;
530530
#[deprecated(since = "2.1.0", note = "Use `solana-epoch-rewards` crate instead")]
531531
pub use solana_epoch_rewards as epoch_rewards;
532532
#[deprecated(
533-
since = "2.2.0",
533+
since = "2.3.0",
534534
note = "Use `solana-feature-gate-interface` crate instead"
535535
)]
536-
pub use solana_feature_gate_interface as feature;
536+
pub mod feature {
537+
pub use solana_feature_gate_interface::*;
538+
}
537539
#[deprecated(since = "2.1.0", note = "Use `solana-fee-calculator` crate instead")]
538540
pub use solana_fee_calculator as fee_calculator;
539541
#[deprecated(since = "2.2.0", note = "Use `solana-keccak-hasher` crate instead")]
540542
pub use solana_keccak_hasher as keccak;
541543
#[deprecated(since = "2.1.0", note = "Use `solana-last-restart-slot` crate instead")]
542544
pub use solana_last_restart_slot as last_restart_slot;
543545
#[deprecated(
544-
since = "2.2.0",
546+
since = "2.3.0",
545547
note = "Use `solana-loader-v2-interface` crate instead"
546548
)]
547-
pub use solana_loader_v2_interface as loader_instruction;
548-
#[deprecated(since = "2.2.0", note = "Use `solana-message` crate instead")]
549-
pub use solana_message as message;
549+
pub mod loader_instruction {
550+
pub use solana_loader_v2_interface::*;
551+
}
552+
#[deprecated(since = "2.3.0", note = "Use `solana-message` crate instead")]
553+
pub mod message {
554+
pub use solana_message::*;
555+
}
550556
#[deprecated(since = "2.1.0", note = "Use `solana-program-memory` crate instead")]
551557
pub use solana_program_memory as program_memory;
552558
#[deprecated(since = "2.1.0", note = "Use `solana-program-pack` crate instead")]
553559
pub use solana_program_pack as program_pack;
554-
#[deprecated(since = "2.1.0", note = "Use `solana-sanitize` crate instead")]
555-
pub use solana_sanitize as sanitize;
560+
#[deprecated(since = "2.3.0", note = "Use `solana-sanitize` crate instead")]
561+
pub mod sanitize {
562+
pub use solana_sanitize::*;
563+
}
556564
#[deprecated(since = "2.1.0", note = "Use `solana-secp256k1-recover` crate instead")]
557565
pub use solana_secp256k1_recover as secp256k1_recover;
558566
#[deprecated(since = "2.1.0", note = "Use `solana-serde-varint` crate instead")]
@@ -565,8 +573,10 @@ pub use solana_short_vec as short_vec;
565573
pub use solana_stable_layout as stable_layout;
566574
#[cfg(not(target_os = "solana"))]
567575
pub use solana_sysvar::program_stubs;
568-
#[deprecated(since = "2.2.0", note = "Use `solana-vote-interface` crate instead")]
569-
pub use solana_vote_interface as vote;
576+
#[deprecated(since = "2.3.0", note = "Use `solana-vote-interface` crate instead")]
577+
pub mod vote {
578+
pub use solana_vote_interface::*;
579+
}
570580
#[cfg(target_arch = "wasm32")]
571581
pub use wasm_bindgen::prelude::wasm_bindgen;
572582
pub use {
@@ -632,8 +642,10 @@ pub mod sdk_ids {
632642
}
633643
}
634644

635-
#[deprecated(since = "2.1.0", note = "Use `solana-decode-error` crate instead")]
636-
pub use solana_decode_error as decode_error;
645+
#[deprecated(since = "2.3.0", note = "Use `num_traits::FromPrimitive` instead")]
646+
pub mod decode_error {
647+
pub use solana_decode_error::*;
648+
}
637649
pub use solana_pubkey::{declare_deprecated_id, declare_id, pubkey};
638650
#[deprecated(since = "2.1.0", note = "Use `solana-sysvar-id` crate instead")]
639651
pub use solana_sysvar_id::{declare_deprecated_sysvar_id, declare_sysvar_id};

program/src/loader_v4.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
#[deprecated(since = "2.2.0", note = "Use solana-loader-v4-interface instead")]
2-
pub use solana_loader_v4_interface::{
3-
instruction::{
4-
create_buffer, deploy, deploy_from_source, finalize, is_deploy_instruction,
5-
is_finalize_instruction, is_retract_instruction, is_set_program_length_instruction,
6-
is_set_program_length_instruction as is_truncate_instruction,
7-
is_transfer_authority_instruction, is_write_instruction, retract,
8-
set_program_length as truncate, set_program_length as truncate_uninitialized,
9-
set_program_length, transfer_authority, write,
1+
#![deprecated(since = "2.3.0", note = "Use solana-loader-v4-interface instead")]
2+
pub use {
3+
solana_loader_v4_interface::{
4+
instruction::{
5+
create_buffer, deploy, deploy_from_source, finalize, is_deploy_instruction,
6+
is_finalize_instruction, is_retract_instruction, is_set_program_length_instruction,
7+
is_transfer_authority_instruction, is_write_instruction, retract,
8+
set_program_length as truncate, transfer_authority, write,
9+
},
10+
state::{LoaderV4State, LoaderV4Status},
11+
DEPLOYMENT_COOLDOWN_IN_SLOTS,
1012
},
11-
state::{LoaderV4State, LoaderV4Status},
12-
DEPLOYMENT_COOLDOWN_IN_SLOTS,
13+
solana_sdk_ids::loader_v4::{check_id, id, ID},
1314
};
14-
pub use solana_sdk_ids::loader_v4::{check_id, id, ID};

program/src/nonce.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deprecated(since = "2.3.0", note = "Use solana_nonce instead")]
2+
13
pub use solana_nonce::{state::State, NONCED_TX_MARKER_IX_INDEX};
24
pub mod state {
35
pub use solana_nonce::{

program/src/stake.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
#[deprecated(since = "2.2.0", note = "Use solana-stake-interface instead")]
1+
#![deprecated(since = "2.3.0", note = "Use solana-stake-interface instead")]
22
pub use solana_stake_interface::{
33
config, stake_flags, state, tools, MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION,
44
};
55

66
pub mod instruction {
7-
#[deprecated(since = "2.2.0", note = "Use solana-stake-interface instead")]
87
pub use solana_stake_interface::{error::StakeError, instruction::*};
98
}
109

program/src/stake_history.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![deprecated(since = "2.3.0", note = "Use `solana-stake-interface` crate instead")]
12
pub use {
23
crate::sysvar::stake_history::{
34
StakeHistory, StakeHistoryEntry, StakeHistoryGetEntry, MAX_ENTRIES,

program/src/system_instruction.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#[deprecated(since = "2.2.0", note = "Use `solana_system_interface` crate instead")]
1+
#![deprecated(since = "2.3.0", note = "Use `solana_system_interface` crate instead")]
2+
23
pub use solana_system_interface::{
34
error::SystemError,
45
instruction::{

program/src/system_program.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![deprecated(since = "2.3.0", note = "Use `solana_sdk_ids::system_program` instead")]
12
//! The [system native program][np].
23
//!
34
//! [np]: https://docs.solanalabs.com/runtime/programs#system-program

pubkey/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use {
2929
str::{from_utf8, FromStr},
3030
},
3131
num_traits::{FromPrimitive, ToPrimitive},
32-
solana_decode_error::DecodeError,
3332
};
3433
#[cfg(target_arch = "wasm32")]
3534
use {
@@ -120,7 +119,8 @@ impl fmt::Display for PubkeyError {
120119
}
121120
}
122121

123-
impl<T> DecodeError<T> for PubkeyError {
122+
#[allow(deprecated)]
123+
impl<T> solana_decode_error::DecodeError<T> for PubkeyError {
124124
fn type_of() -> &'static str {
125125
"PubkeyError"
126126
}
@@ -381,7 +381,8 @@ impl From<Infallible> for ParsePubkeyError {
381381
}
382382
}
383383

384-
impl<T> DecodeError<T> for ParsePubkeyError {
384+
#[allow(deprecated)]
385+
impl<T> solana_decode_error::DecodeError<T> for ParsePubkeyError {
385386
fn type_of() -> &'static str {
386387
"ParsePubkeyError"
387388
}

sdk/src/feature.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
#[allow(deprecated)]
12
pub use solana_program::feature::*;

0 commit comments

Comments
 (0)