Skip to content

Commit 39b317a

Browse files
authored
program: Update to sdk v3 crates (#110)
#### Problem The program is still on sdk v2, but sdk v3 is out. #### Summary of changes Update dependencies, and use split-up dependencies while we're at it. The new version reduces CUs for a good amount of instructions! The client crate needs to stay on v2 because we eliminated borsh v0.10 support in v3, and kaigan requires v0.10 of borsh until metaplex-foundation/kaigan#9 lands.
1 parent 204f32e commit 39b317a

File tree

12 files changed

+1556
-684
lines changed

12 files changed

+1556
-684
lines changed

Cargo.lock

Lines changed: 1440 additions & 620 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,29 @@ assert_matches = "1.5.0"
1818
bincode = "1.3.3"
1919
borsh = "0.10"
2020
kaigan = "0.2.6"
21-
mollusk-svm = "0.4.2"
22-
mollusk-svm-bencher = "0.4.2"
21+
mollusk-svm = "0.7.0"
22+
mollusk-svm-bencher = "0.7.0"
2323
num-derive = "0.4"
2424
num-traits = "0.2"
2525
serde = "1.0.228"
2626
serde_derive = "1.0.193"
2727
solana-account = "3.1.0"
28+
solana-account-info = "3.0.0"
29+
solana-bincode = "3.0.0"
2830
solana-client = "2.3.4"
29-
solana-config-interface = { version = "1.0.0" }
31+
solana-config-interface = { version = "2.0.0" }
32+
solana-hash = "3.0.0"
3033
solana-instruction = "3.0.0"
31-
solana-program = "2.3.0"
34+
solana-msg = "3.0.0"
35+
solana-program = "2.0.0"
36+
solana-program-entrypoint = "3.0.0"
37+
solana-program-error = "3.0.0"
3238
solana-pubkey = "3.0.0"
33-
solana-sdk = "2.2.1"
39+
solana-sdk = "2.0.0"
3440
solana-sdk-ids = "3.0.0"
3541
solana-short-vec = "3.0.0"
3642
solana-system-interface = "2.0.0"
43+
solana-rent = "3.0.0"
3744
thiserror = "2.0.17"
3845

3946
[workspace.metadata.spellcheck]

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
RUST_TOOLCHAIN_NIGHTLY = nightly-2025-02-16
2-
SOLANA_CLI_VERSION = 2.3.4
2+
SOLANA_CLI_VERSION = 3.0.0
33

44
nightly = +${RUST_TOOLCHAIN_NIGHTLY}
55

clients/rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ borsh = { workspace = true }
2424
kaigan = { workspace = true }
2525
serde = { workspace = true, features = ["derive"], optional = true }
2626
solana-client = { workspace = true, optional = true }
27-
solana-config-interface = { workspace = true, optional = true }
27+
solana-config-interface = { version = "1", optional = true }
2828
solana-program = { workspace = true, features = ["borsh"] }
2929
solana-sdk = { workspace = true, optional = true }
3030

program/Cargo.toml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,24 @@ bincode = { workspace = true }
1616
num-derive = { workspace = true }
1717
num-traits = { workspace = true }
1818
serde = { workspace = true, features = ["derive"] }
19+
solana-account-info = { workspace = true }
20+
solana-bincode = { workspace = true }
1921
solana-config-interface = { workspace = true, features = ["serde"] }
20-
solana-program = { workspace = true }
22+
solana-msg = { workspace = true }
23+
solana-program-entrypoint = { workspace = true }
24+
solana-program-error = { workspace = true }
25+
solana-pubkey = { workspace = true }
26+
solana-short-vec = { workspace = true }
2127
thiserror = { workspace = true }
2228

2329
[dev-dependencies]
2430
mollusk-svm = { workspace = true, features = ["fuzz"] }
2531
mollusk-svm-bencher = { workspace = true }
32+
solana-account = { workspace = true }
2633
solana-config-interface = { workspace = true, features = ["bincode", "serde"] }
27-
solana-sdk = { workspace = true }
34+
solana-hash = { workspace = true }
35+
solana-instruction = { workspace = true }
36+
solana-rent = { workspace = true }
2837

2938
[lib]
3039
crate-type = ["cdylib", "lib"]

program/benches/compute_units.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,46 @@
1+
#### 2025-10-29 22:42:22.511198962 UTC
2+
3+
Solana CLI Version: solana-cli 3.0.7 (src:ea24c1fd; feat:3604001754, client:Agave)
4+
5+
| Name | CUs | Delta |
6+
|------|------|-------|
7+
| config_small_init_0_keys | 655 | +11 |
8+
| config_small_init_1_keys | 1131 | +2 |
9+
| config_small_init_5_keys | 2763 | -150 |
10+
| config_small_init_10_keys | 4783 | -335 |
11+
| config_small_init_25_keys | 11289 | -1,043 |
12+
| config_small_init_37_keys | 16199 | -1,560 |
13+
| config_small_store_0_keys | 655 | +11 |
14+
| config_small_store_1_keys | 1414 | +4 |
15+
| config_small_store_5_keys | 4066 | -128 |
16+
| config_small_store_10_keys | 7361 | -288 |
17+
| config_small_store_25_keys | 17692 | -921 |
18+
| config_small_store_37_keys | 25662 | -1,378 |
19+
| config_medium_init_0_keys | 655 | +11 |
20+
| config_medium_init_1_keys | 1131 | +2 |
21+
| config_medium_init_5_keys | 2763 | -150 |
22+
| config_medium_init_10_keys | 4783 | -335 |
23+
| config_medium_init_25_keys | 11289 | -1,043 |
24+
| config_medium_init_37_keys | 16199 | -1,560 |
25+
| config_medium_store_0_keys | 655 | +11 |
26+
| config_medium_store_1_keys | 1414 | +4 |
27+
| config_medium_store_5_keys | 4066 | -128 |
28+
| config_medium_store_10_keys | 7361 | -288 |
29+
| config_medium_store_25_keys | 17692 | -921 |
30+
| config_medium_store_37_keys | 25662 | -1,378 |
31+
| config_large_init_0_keys | 776 | +11 |
32+
| config_large_init_1_keys | 1252 | +2 |
33+
| config_large_init_5_keys | 2884 | -150 |
34+
| config_large_init_10_keys | 4905 | -335 |
35+
| config_large_init_25_keys | 11413 | -1,043 |
36+
| config_large_init_37_keys | 16324 | -1,560 |
37+
| config_large_store_0_keys | 776 | +11 |
38+
| config_large_store_1_keys | 1535 | +4 |
39+
| config_large_store_5_keys | 4187 | -128 |
40+
| config_large_store_10_keys | 7483 | -288 |
41+
| config_large_store_25_keys | 17816 | -921 |
42+
| config_large_store_37_keys | 25787 | -1,378 |
43+
144
#### 2025-07-14 17:12:46.523897668 UTC
245

346
Solana CLI Version: solana-cli 2.3.4 (src:bbf10bfb; feat:3640012085, client:Agave)

program/benches/setup.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
use {
22
mollusk_svm_bencher::Bench,
33
serde::Serialize,
4+
solana_account::Account,
45
solana_config_interface::{instruction::store, state::ConfigKeys},
5-
solana_sdk::{
6-
account::Account,
7-
hash::Hash,
8-
instruction::{AccountMeta, Instruction},
9-
pubkey::Pubkey,
10-
rent::Rent,
11-
},
6+
solana_hash::Hash,
7+
solana_instruction::{AccountMeta, Instruction},
8+
solana_pubkey::Pubkey,
9+
solana_rent::Rent,
1210
};
1311

1412
/// Helper struct to convert to a `Bench`.

program/src/entrypoint.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
33
use {
44
crate::{error::ConfigError, processor},
5-
solana_program::{
6-
account_info::AccountInfo, entrypoint::ProgramResult, program_error::PrintProgramError,
7-
pubkey::Pubkey,
8-
},
5+
solana_account_info::AccountInfo,
6+
solana_msg::msg,
7+
solana_program_error::ProgramResult,
8+
solana_pubkey::Pubkey,
99
};
1010

11-
solana_program::entrypoint!(process_instruction);
11+
solana_program_entrypoint::entrypoint!(process_instruction);
1212
fn process_instruction(
1313
program_id: &Pubkey,
1414
accounts: &[AccountInfo],
1515
instruction_data: &[u8],
1616
) -> ProgramResult {
1717
if let Err(error) = processor::process(program_id, accounts, instruction_data) {
18-
error.print::<ConfigError>();
18+
msg!(error.to_str::<ConfigError>());
1919
return Err(error);
2020
}
2121
Ok(())

program/src/error.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,36 @@
22
33
use {
44
num_derive::FromPrimitive,
5-
solana_program::{
6-
decode_error::DecodeError,
7-
msg,
8-
program_error::{PrintProgramError, ProgramError},
9-
},
5+
solana_program_error::{ProgramError, ToStr},
106
thiserror::Error,
117
};
128

139
/// Errors that can be returned by the Config program.
10+
#[repr(u32)]
1411
#[derive(Error, Clone, Debug, Eq, PartialEq, FromPrimitive)]
1512
pub enum ConfigError {
1613
/// Instruction modified data of a read-only account.
1714
#[error("Instruction modified data of a read-only account")]
1815
ReadonlyDataModified,
1916
}
2017

21-
impl PrintProgramError for ConfigError {
22-
fn print<E>(&self) {
23-
msg!(&self.to_string());
24-
}
25-
}
26-
2718
impl From<ConfigError> for ProgramError {
2819
fn from(e: ConfigError) -> Self {
2920
ProgramError::Custom(e as u32)
3021
}
3122
}
3223

33-
impl<T> DecodeError<T> for ConfigError {
34-
fn type_of() -> &'static str {
35-
"ConfigError"
24+
impl ToStr for ConfigError {
25+
fn to_str(&self) -> &'static str {
26+
match self {
27+
Self::ReadonlyDataModified => "Instruction modified data of a read-only account",
28+
}
29+
}
30+
}
31+
32+
impl TryFrom<u32> for ConfigError {
33+
type Error = ProgramError;
34+
fn try_from(code: u32) -> Result<Self, Self::Error> {
35+
num_traits::FromPrimitive::from_u32(code).ok_or(ProgramError::InvalidArgument)
3636
}
3737
}

program/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ mod entrypoint;
55
pub mod error;
66
pub mod processor;
77

8-
solana_program::declare_id!("Config1111111111111111111111111111111111111");
8+
solana_pubkey::declare_id!("Config1111111111111111111111111111111111111");

0 commit comments

Comments
 (0)