Skip to content

Commit 5f956c9

Browse files
committed
program: Upgrade to v3 crates
#### Problem The interface crate has been on v3 for some time, but the program and tests have been lagging behind. #### Summary of changes Upgrade everything to new CLI, crates, etc, and fix everything that comes up. The biggest change is that it isn't possible to disable direct mapping, because it was removed from the feature set in v3.0.
1 parent 41d5722 commit 5f956c9

File tree

8 files changed

+1445
-1461
lines changed

8 files changed

+1445
-1461
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ check-cfg = [
1616
]
1717

1818
[workspace.metadata.cli]
19-
solana = "2.3.4"
19+
solana = "3.0.0"
2020

2121
# Specify Rust toolchains for rustfmt, clippy, and build.
2222
# Any unprovided toolchains default to stable.
@@ -33,13 +33,13 @@ tag-message = "Publish {{crate_name}} v{{version}}"
3333
consolidate-commits = false
3434

3535
[workspace.dependencies]
36-
mollusk-svm = "0.4.0"
37-
mollusk-svm-fuzz-fixture = "0.4.0"
36+
mollusk-svm = "0.6.3"
37+
mollusk-svm-fuzz-fixture = "0.6.3"
3838
num-traits = "0.2"
3939
pinocchio = "0.9.2"
40-
solana-instruction = "2.3.0"
41-
solana-program-error = "2.2.2"
42-
solana-program-option = "2.2.1"
43-
solana-program-pack = "2.2.1"
44-
solana-pubkey = "2.4.0"
45-
solana-system-interface = { version="1.0", features=["bincode"] }
40+
solana-instruction = "3.0.0"
41+
solana-program-error = "3.0.0"
42+
solana-program-option = "3.0.0"
43+
solana-program-pack = "3.0.0"
44+
solana-pubkey = "3.0.0"
45+
solana-system-interface = { version = "2.0", features=["bincode"] }

pinocchio/program/Cargo.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,28 @@ pinocchio-log = { version = "0.5.1", default-features = false }
2020
pinocchio-token-interface = { version = "^0", path = "../interface" }
2121

2222
[dev-dependencies]
23-
agave-feature-set = "2.2.20"
23+
agave-feature-set = "3.0.0"
2424
assert_matches = "1.5.0"
2525
mollusk-svm = { workspace = true }
2626
mollusk-svm-fuzz-fixture = { workspace = true }
2727
num-traits = { workspace = true }
28-
solana-account = "2.2.1"
28+
solana-account = "3.0.0"
2929
solana-instruction = { workspace = true }
30-
solana-keypair = "2.2.3"
30+
solana-keypair = "3.0.0"
3131
solana-program-error = { workspace = true }
3232
solana-program-option = { workspace = true }
3333
solana-program-pack = { workspace = true }
34-
solana-program-test = "2.3.4"
34+
solana-program-test = "3.0.0"
3535
solana-pubkey = { workspace = true }
36-
solana-rent = "2.2.1"
37-
solana-sdk-ids = "2.2.1"
38-
solana-signature = "2.3.0"
39-
solana-signer = "2.2.1"
40-
solana-transaction = "2.2.3"
41-
solana-transaction-error = "2.2.1"
36+
solana-rent = "3.0.0"
37+
solana-sdk-ids = "3.0.0"
38+
solana-signature = "3.0.0"
39+
solana-signer = "3.0.0"
40+
solana-transaction = "3.0.0"
41+
solana-transaction-error = "3.0.0"
4242
solana-system-interface = { workspace = true }
43-
spl-token-interface = "1"
44-
spl-token-2022-interface = "1"
43+
spl-token-interface = "2"
44+
spl-token-2022-interface = "2"
4545

4646
[lints]
4747
workspace = true

pinocchio/program/tests/batch.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,13 +300,15 @@ fn create_token_account(
300300
}
301301

302302
/// Creates a Mollusk instance with the default feature set, excluding the
303-
/// `bpf_account_data_direct_mapping` feature.
303+
/// `account_data_direct_mapping` feature.
304304
fn mollusk() -> Mollusk {
305305
let feature_set = {
306-
let mut fs = FeatureSet::all_enabled();
307-
fs.active_mut()
308-
.remove(&agave_feature_set::bpf_account_data_direct_mapping::id());
309-
fs
306+
// When upgrading to v3.1, add this back in
307+
//let fs = FeatureSet::all_enabled();
308+
//fs.active_mut()
309+
// .remove(&agave_feature_set::account_data_direct_mapping::id());
310+
//fs
311+
FeatureSet::all_enabled()
310312
};
311313
let mut mollusk = Mollusk {
312314
feature_set,

program/Cargo.toml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ bytemuck = "1.20.0"
1717
num-derive = "0.4"
1818
num-traits = { workspace = true }
1919
num_enum = "0.7.3"
20-
solana-account-info = "2.3.0"
21-
solana-cpi = "2.2.1"
20+
solana-account-info = "3.0.0"
21+
solana-cpi = "3.0.0"
2222
solana-instruction = { workspace = true }
23-
solana-msg = "2.2.1"
24-
solana-program-entrypoint = "2.3.0"
23+
solana-msg = "3.0.0"
24+
solana-program-entrypoint = "3.0.0"
2525
solana-program-error = { workspace = true }
26-
solana-program-memory = "2.3.1"
26+
solana-program-memory = "3.0.0"
2727
solana-program-option = { workspace = true }
2828
solana-program-pack = { workspace = true }
2929
solana-pubkey = { workspace = true, features = ["bytemuck"] }
30-
solana-rent = "2.2.1"
31-
solana-sdk-ids = "2.2.1"
32-
solana-sysvar = { version = "2.2.2", features = ["bincode"] }
33-
spl-token-interface = { version = "1.0" }
30+
solana-rent = "3.0.0"
31+
solana-sdk-ids = "3.0.0"
32+
solana-sysvar = { version = "3.0.0", features = ["bincode"] }
33+
spl-token-interface = { version = "2.0" }
3434
thiserror = "2.0"
3535

3636
[dev-dependencies]
@@ -39,13 +39,12 @@ mollusk-svm = { workspace = true }
3939
mollusk-svm-fuzz-fixture = { workspace = true }
4040
proptest = "1.5"
4141
serial_test = "3.2.0"
42-
solana-account = "2.2.1"
43-
solana-account-info = "2.3.0"
44-
solana-clock = "2.2.2"
45-
solana-native-token = "2.2.1"
46-
solana-program-entrypoint = "2.3.0"
47-
solana-rent = { version = "2.2.1", features = ["sysvar"] }
48-
solana-system-interface = { version="1.0", features=["bincode"] }
42+
solana-account = "3.0.0"
43+
solana-account-info = "3.0.0"
44+
solana-clock = "3.0.0"
45+
solana-native-token = "3.0.0"
46+
solana-rent = { version = "3.0.0", features = ["sysvar"] }
47+
solana-system-interface = { version = "2.0", features=["bincode"] }
4948
strum = "0.24"
5049
strum_macros = "0.24"
5150

program/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![allow(clippy::arithmetic_side_effects)]
22
#![deny(missing_docs)]
3-
#![cfg_attr(not(test), forbid(unsafe_code))]
43

54
//! An ERC20-like Token program for the Solana blockchain
65

program/src/processor.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ use {
1212
solana_cpi::set_return_data,
1313
solana_msg::msg,
1414
solana_program_error::{ProgramError, ProgramResult},
15-
solana_program_memory::sol_memcmp,
15+
solana_program_memory::{sol_memcmp, sol_memset},
1616
solana_program_option::COption,
1717
solana_program_pack::{IsInitialized, Pack},
1818
solana_pubkey::{Pubkey, PUBKEY_BYTES},
1919
solana_rent::Rent,
2020
solana_sdk_ids::system_program,
21-
solana_sysvar::Sysvar,
21+
solana_sysvar::{Sysvar, SysvarSerialize},
2222
};
2323

2424
/// Program state handler.
@@ -976,7 +976,9 @@ impl Processor {
976976
/// Checks two pubkeys for equality in a computationally cheap way using
977977
/// `sol_memcmp`
978978
pub fn cmp_pubkeys(a: &Pubkey, b: &Pubkey) -> bool {
979-
sol_memcmp(a.as_ref(), b.as_ref(), PUBKEY_BYTES) == 0
979+
unsafe {
980+
sol_memcmp(a.as_ref(), b.as_ref(), PUBKEY_BYTES) == 0
981+
}
980982
}
981983

982984
/// Validates owner(s) are present
@@ -1025,7 +1027,9 @@ fn delete_account(account_info: &AccountInfo) -> Result<(), ProgramError> {
10251027
account_info.assign(&system_program::id());
10261028
let mut account_data = account_info.data.borrow_mut();
10271029
let data_len = account_data.len();
1028-
solana_program_memory::sol_memset(*account_data, 0, data_len);
1030+
unsafe {
1031+
sol_memset(*account_data, 0, data_len);
1032+
}
10291033
Ok(())
10301034
}
10311035

@@ -1040,8 +1044,6 @@ fn delete_account(account_info: &AccountInfo) -> Result<(), ProgramError> {
10401044
mod tests {
10411045
use {
10421046
super::*,
1043-
solana_clock::Epoch,
1044-
solana_program_error::ToStr,
10451047
std::sync::{Arc, RwLock},
10461048
};
10471049

@@ -1201,7 +1203,6 @@ mod tests {
12011203
&mut signer_data,
12021204
&program_id,
12031205
false,
1204-
Epoch::default(),
12051206
);
12061207
MAX_SIGNERS + 1
12071208
];
@@ -1224,7 +1225,6 @@ mod tests {
12241225
&mut data,
12251226
&program_id,
12261227
false,
1227-
Epoch::default(),
12281228
);
12291229

12301230
// full 11 of 11
@@ -1326,7 +1326,6 @@ mod tests {
13261326
&mut signer_data,
13271327
&program_id,
13281328
false,
1329-
Epoch::default(),
13301329
);
13311330
MAX_SIGNERS + 1
13321331
];

program/tests/processor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ fn do_process_instruction_dups(
7575
data: account_info.try_borrow_data().unwrap().to_vec(),
7676
owner: *account_info.owner,
7777
executable: account_info.executable,
78-
rent_epoch: account_info.rent_epoch,
78+
rent_epoch: u64::MAX,
7979
};
8080
dedup_accounts.push((*account_info.key, account));
8181
cached_accounts.insert(account_info.key, account_info);

0 commit comments

Comments
 (0)