Skip to content

Commit 2cc9f89

Browse files
authored
Update mollusk (#10)
* Update mollusk * Allow deprecated * Update Solana and IDL * Fix/disable mollusk tests * Revert Cargo.lock changes * Update compute units again
1 parent a8d0bc0 commit 2cc9f89

File tree

15 files changed

+2101
-3206
lines changed

15 files changed

+2101
-3206
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ resolver = "2"
33
members = ["clients/rust", "program"]
44

55
[workspace.metadata.cli]
6-
solana = "2.0.2"
6+
solana = "2.2.1"
77

88
[workspace.metadata.toolchains]
99
format = "nightly-2024-05-02"

clients/rust/Cargo.toml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,5 @@ num-derive = "^0.3"
1515
num-traits = "^0.2"
1616
serde = { version = "^1.0", features = ["derive"], optional = true }
1717
serde_with = { version = "^3.0", optional = true }
18-
solana-program = "~2.0"
18+
solana-program = "^2.2.1"
1919
thiserror = "^1.0"
20-
21-
[dev-dependencies]
22-
assert_matches = "1.5.0"
23-
solana-program-test = "~2.0"
24-
solana-sdk = "~2.0"

program/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ num-derive = "^0.3"
1919
num-traits = "^0.2"
2020
serde = { version = "1.0.193", features = ["derive"] }
2121
shank = "^0.4.2"
22-
solana-program = "~2.0"
22+
solana-program = "^2.2.1"
2323
thiserror = "^1.0"
2424

2525
[dev-dependencies]
26-
mollusk-svm = { version = "0.0.10-solana-2.0", features = ["fuzz-fd"] }
27-
solana-sdk = "~2.0"
26+
mollusk-svm = { version = "^0.4", features = ["fuzz-fd"] }
27+
solana-sdk = "^2.2.1"
2828

2929
[features]
3030
bpf-entrypoint = []

program/idl.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@
374374
"metadata": {
375375
"origin": "shank",
376376
"address": "CoreBPFLoaderUpgradeab1e1111111111111111111",
377-
"binaryVersion": "0.4.2",
377+
"binaryVersion": "0.4.5",
378378
"libVersion": "^0.4.2"
379379
}
380380
}

program/src/processor.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Program processor.
22
3+
#[allow(deprecated)]
4+
use solana_program::system_instruction::{self, MAX_PERMITTED_DATA_LENGTH};
35
use {
46
crate::{
57
instruction::LoaderV3Instruction,
@@ -15,7 +17,6 @@ use {
1517
program_error::ProgramError,
1618
pubkey::Pubkey,
1719
rent::Rent,
18-
system_instruction::{self, MAX_PERMITTED_DATA_LENGTH},
1920
sysvar::Sysvar,
2021
},
2122
};
@@ -283,6 +284,7 @@ fn process_deploy_with_max_data_len(
283284
}
284285

285286
// Clear the buffer.
287+
#[allow(deprecated)]
286288
buffer_info.realloc(UpgradeableLoaderState::size_of_buffer(0), false)?;
287289
}
288290

@@ -464,6 +466,7 @@ fn process_upgrade(program_id: &Pubkey, accounts: &[AccountInfo]) -> ProgramResu
464466
.fill(0);
465467

466468
// Clear the buffer.
469+
#[allow(deprecated)]
467470
buffer_info.realloc(UpgradeableLoaderState::size_of_buffer(0), false)?;
468471
}
469472

@@ -713,6 +716,7 @@ fn process_close(program_id: &Pubkey, accounts: &[AccountInfo]) -> ProgramResult
713716
**destination_info.try_borrow_mut_lamports()? = new_destination_lamports;
714717
}
715718

719+
#[allow(deprecated)]
716720
buffer_or_programdata_info.realloc(UpgradeableLoaderState::size_of_uninitialized(), true)?;
717721

718722
let mut buffer_or_programdata_data = buffer_or_programdata_info.try_borrow_mut_data()?;
@@ -842,6 +846,7 @@ fn process_extend_program(
842846

843847
// [CORE BPF]: BPF programs can only reallocate a maximum of 10_240 bytes.
844848
// See https://github.com/anza-xyz/agave/blob/ed51e70c2e6528f602ad4f8fde718f60d7da2d0c/sdk/account-info/src/lib.rs#L16-L17
849+
#[allow(deprecated)]
845850
programdata_info.realloc(new_len, true)?;
846851

847852
// [CORE BPF]: We'll see what happens with on-chain verification...

program/tests/close.rs

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use {
1010
state::{get_program_data_address, UpgradeableLoaderState},
1111
},
1212
solana_sdk::{
13-
account::{AccountSharedData, WritableAccount},
13+
account::{Account, WritableAccount},
1414
program_error::ProgramError,
1515
pubkey::Pubkey,
1616
},
@@ -24,10 +24,7 @@ fn fail_recipient_same_as_close_account() {
2424

2525
mollusk.process_and_validate_instruction(
2626
&close(&target, &target, None, None),
27-
&[
28-
(target, AccountSharedData::default()),
29-
(target, AccountSharedData::default()),
30-
],
27+
&[(target, Account::default()), (target, Account::default())],
3128
&[Check::err(ProgramError::InvalidArgument)],
3229
);
3330
}
@@ -53,7 +50,7 @@ fn fail_invalid_account_state() {
5350
true,
5451
),
5552
),
56-
(destination, AccountSharedData::default()),
53+
(destination, Account::default()),
5754
],
5855
&[Check::err(ProgramError::InvalidArgument)],
5956
);
@@ -78,7 +75,7 @@ fn uninitialized_success() {
7875
target,
7976
upgradeable_state_account(&UpgradeableLoaderState::Uninitialized, &[], false),
8077
),
81-
(destination, AccountSharedData::default()),
78+
(destination, Account::default()),
8279
],
8380
&[
8481
Check::success(),
@@ -116,8 +113,8 @@ fn buffer_fail_buffer_immutable() {
116113
false,
117114
),
118115
),
119-
(destination, AccountSharedData::default()),
120-
(authority, AccountSharedData::default()),
116+
(destination, Account::default()),
117+
(authority, Account::default()),
121118
],
122119
&[Check::err(ProgramError::Immutable)],
123120
);
@@ -144,8 +141,8 @@ fn buffer_fail_incorrect_authority() {
144141
false,
145142
),
146143
),
147-
(destination, AccountSharedData::default()),
148-
(authority, AccountSharedData::default()),
144+
(destination, Account::default()),
145+
(authority, Account::default()),
149146
],
150147
&[Check::err(ProgramError::IncorrectAuthority)],
151148
);
@@ -175,8 +172,8 @@ fn buffer_fail_authority_not_signer() {
175172
false,
176173
),
177174
),
178-
(destination, AccountSharedData::default()),
179-
(authority, AccountSharedData::default()),
175+
(destination, Account::default()),
176+
(authority, Account::default()),
180177
],
181178
&[Check::err(ProgramError::MissingRequiredSignature)],
182179
);
@@ -208,12 +205,12 @@ fn buffer_success() {
208205
false,
209206
),
210207
),
211-
(destination, AccountSharedData::default()),
212-
(authority, AccountSharedData::default()),
208+
(destination, Account::default()),
209+
(authority, Account::default()),
213210
],
214211
&[
215212
Check::success(),
216-
Check::compute_units(12_792),
213+
Check::compute_units(3_628),
217214
// Closed, but still owned by the loader.
218215
Check::account(&buffer)
219216
.data(&[0, 0, 0, 0]) // Size of Uninitialized.
@@ -254,8 +251,8 @@ fn programdata_fail_program_not_writable() {
254251
false,
255252
),
256253
),
257-
(destination, AccountSharedData::default()),
258-
(authority, AccountSharedData::default()),
254+
(destination, Account::default()),
255+
(authority, Account::default()),
259256
(
260257
program,
261258
upgradeable_state_account(
@@ -304,8 +301,8 @@ fn programdata_fail_program_not_owned_by_loader() {
304301
false,
305302
),
306303
),
307-
(destination, AccountSharedData::default()),
308-
(authority, AccountSharedData::default()),
304+
(destination, Account::default()),
305+
(authority, Account::default()),
309306
(program, program_account),
310307
],
311308
&[Check::err(ProgramError::IncorrectProgramId)],
@@ -337,8 +334,8 @@ fn programdata_fail_program_deployed_in_slot() {
337334
false,
338335
),
339336
),
340-
(destination, AccountSharedData::default()),
341-
(authority, AccountSharedData::default()),
337+
(destination, Account::default()),
338+
(authority, Account::default()),
342339
(
343340
program,
344341
upgradeable_state_account(
@@ -379,8 +376,8 @@ fn programdata_fail_not_upgradeable() {
379376
false,
380377
),
381378
),
382-
(destination, AccountSharedData::default()),
383-
(authority, AccountSharedData::default()),
379+
(destination, Account::default()),
380+
(authority, Account::default()),
384381
(
385382
program,
386383
upgradeable_state_account(
@@ -421,8 +418,8 @@ fn programdata_fail_incorrect_authority() {
421418
false,
422419
),
423420
),
424-
(destination, AccountSharedData::default()),
425-
(authority, AccountSharedData::default()),
421+
(destination, Account::default()),
422+
(authority, Account::default()),
426423
(
427424
program,
428425
upgradeable_state_account(
@@ -466,8 +463,8 @@ fn programdata_fail_authority_not_signer() {
466463
false,
467464
),
468465
),
469-
(destination, AccountSharedData::default()),
470-
(authority, AccountSharedData::default()),
466+
(destination, Account::default()),
467+
(authority, Account::default()),
471468
(
472469
program,
473470
upgradeable_state_account(
@@ -513,8 +510,8 @@ fn programdata_success() {
513510
false,
514511
),
515512
),
516-
(destination, AccountSharedData::default()),
517-
(authority, AccountSharedData::default()),
513+
(destination, Account::default()),
514+
(authority, Account::default()),
518515
(
519516
program,
520517
upgradeable_state_account(
@@ -528,7 +525,7 @@ fn programdata_success() {
528525
],
529526
&[
530527
Check::success(),
531-
Check::compute_units(14_431),
528+
Check::compute_units(4_995),
532529
// Closed, but still owned by the loader.
533530
Check::account(&programdata)
534531
.data(&[0, 0, 0, 0]) // Size of Uninitialized.

program/tests/common.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
11
#![allow(dead_code)]
22
#![cfg(feature = "test-sbf")]
33

4+
#[allow(deprecated)]
5+
use solana_sdk::system_program;
46
use {
57
mollusk_svm::Mollusk,
68
solana_loader_v3_program::state::UpgradeableLoaderState,
7-
solana_sdk::{
8-
account::{AccountSharedData, WritableAccount},
9-
rent::Rent,
10-
system_program,
11-
},
9+
solana_sdk::{account::Account, rent::Rent},
1210
};
1311

1412
pub fn setup() -> Mollusk {
1513
Mollusk::new(&solana_loader_v3_program::id(), "solana_loader_v3_program")
1614
}
1715

18-
pub fn system_account_with_lamports(lamports: u64) -> AccountSharedData {
19-
AccountSharedData::new(lamports, 0, &system_program::id())
16+
pub fn system_account_with_lamports(lamports: u64) -> Account {
17+
Account::new(lamports, 0, &system_program::id())
2018
}
2119

2220
pub fn upgradeable_state_account(
2321
state: &UpgradeableLoaderState,
2422
additional_bytes: &[u8],
2523
executable: bool,
26-
) -> AccountSharedData {
24+
) -> Account {
2725
// Annoying, but necessary because of the program's layout expectations.
2826
let data_size = match state {
2927
UpgradeableLoaderState::Uninitialized => UpgradeableLoaderState::size_of_uninitialized(),
@@ -41,10 +39,11 @@ pub fn upgradeable_state_account(
4139
let space = data.len();
4240
let lamports = Rent::default().minimum_balance(space);
4341

44-
let mut account = AccountSharedData::new(lamports, space, &solana_loader_v3_program::id());
45-
account.set_data_from_slice(&data);
46-
47-
account.set_executable(executable);
48-
49-
account
42+
Account {
43+
lamports,
44+
owner: solana_loader_v3_program::id(),
45+
data,
46+
executable,
47+
..Account::default()
48+
}
5049
}

0 commit comments

Comments
 (0)