diff --git a/README.md b/README.md index 0ec32b2e..64669f9e 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,8 @@ let instruction = Instruction::new_with_bytes( ); let accounts = vec![ - (key1, AccountSharedData::default()), - (key2, AccountSharedData::default()), + (key1, Account::default()), + (key2, Account::default()), ]; let mollusk = Mollusk::new(program_id, "my_program"); @@ -48,11 +48,11 @@ let instruction = system_instruction::transfer(&sender, &recipient, transfer_amo let accounts = [ ( sender, - AccountSharedData::new(base_lamports, 0, &system_program::id()), + Account::new(base_lamports, 0, &system_program::id()), ), ( recipient, - AccountSharedData::new(base_lamports, 0, &system_program::id()), + Account::new(base_lamports, 0, &system_program::id()), ), ]; let checks = vec![ diff --git a/bencher/src/lib.rs b/bencher/src/lib.rs index 62147807..f0ccd562 100644 --- a/bencher/src/lib.rs +++ b/bencher/src/lib.rs @@ -5,12 +5,12 @@ mod result; use { mollusk_svm::{result::ProgramResult, Mollusk}, result::{write_results, MolluskComputeUnitBenchResult}, - solana_sdk::{account::AccountSharedData, instruction::Instruction, pubkey::Pubkey}, + solana_sdk::{account::Account, instruction::Instruction, pubkey::Pubkey}, std::path::PathBuf, }; /// A bench is a tuple of a name, an instruction, and a list of accounts. -pub type Bench<'a> = (&'a str, &'a Instruction, &'a [(Pubkey, AccountSharedData)]); +pub type Bench<'a> = (&'a str, &'a Instruction, &'a [(Pubkey, Account)]); /// Mollusk's compute unit bencher. /// diff --git a/fuzz/fixture-fd/src/account.rs b/fuzz/fixture-fd/src/account.rs index 044b59d2..eafbd971 100644 --- a/fuzz/fixture-fd/src/account.rs +++ b/fuzz/fixture-fd/src/account.rs @@ -1,12 +1,8 @@ -//! An account with an address: `(Pubkey, AccountSharedData)`. +//! An account with an address: `(Pubkey, Account)`. use { super::proto::{AcctState as ProtoAccount, SeedAddress as ProtoSeedAddress}, - solana_sdk::{ - account::{Account, AccountSharedData}, - keccak::Hasher, - pubkey::Pubkey, - }, + solana_sdk::{account::Account, keccak::Hasher, pubkey::Pubkey}, }; #[derive(Clone, Debug, Default, PartialEq)] @@ -33,7 +29,7 @@ impl From for ProtoSeedAddress { } } -impl From for (Pubkey, AccountSharedData, Option) { +impl From for (Pubkey, Account, Option) { fn from(value: ProtoAccount) -> Self { let ProtoAccount { address, @@ -53,27 +49,27 @@ impl From for (Pubkey, AccountSharedData, Option) { ( pubkey, - AccountSharedData::from(Account { + Account { data, executable, lamports, owner, rent_epoch, - }), + }, seed_addr.map(Into::into), ) } } -impl From<(Pubkey, AccountSharedData, Option)> for ProtoAccount { - fn from(value: (Pubkey, AccountSharedData, Option)) -> Self { +impl From<(Pubkey, Account, Option)> for ProtoAccount { + fn from(value: (Pubkey, Account, Option)) -> Self { let Account { lamports, data, owner, executable, rent_epoch, - } = value.1.into(); + } = value.1; ProtoAccount { address: value.0.to_bytes().to_vec(), @@ -87,15 +83,15 @@ impl From<(Pubkey, AccountSharedData, Option)> for ProtoAccount { } } -impl From<(Pubkey, AccountSharedData)> for ProtoAccount { - fn from(value: (Pubkey, AccountSharedData)) -> Self { +impl From<(Pubkey, Account)> for ProtoAccount { + fn from(value: (Pubkey, Account)) -> Self { let Account { lamports, data, owner, executable, rent_epoch, - } = value.1.into(); + } = value.1; ProtoAccount { address: value.0.to_bytes().to_vec(), diff --git a/fuzz/fixture-fd/src/context.rs b/fuzz/fixture-fd/src/context.rs index b9d64496..b873024f 100644 --- a/fuzz/fixture-fd/src/context.rs +++ b/fuzz/fixture-fd/src/context.rs @@ -5,7 +5,7 @@ use { }, crate::account::SeedAddress, solana_sdk::{ - account::AccountSharedData, feature_set::FeatureSet, keccak::Hasher, pubkey::Pubkey, + account::Account, feature_set::FeatureSet, keccak::Hasher, pubkey::Pubkey, transaction_context::InstructionAccount, }, }; @@ -58,7 +58,7 @@ pub struct Context { /// The program ID of the program being invoked. pub program_id: Pubkey, /// Input accounts with state. - pub accounts: Vec<(Pubkey, AccountSharedData, Option)>, + pub accounts: Vec<(Pubkey, Account, Option)>, /// Accounts to pass to the instruction. pub instruction_accounts: Vec, /// The instruction data. @@ -79,7 +79,7 @@ impl From for Context { .expect("Invalid bytes for program ID"); let program_id = Pubkey::new_from_array(program_id_bytes); - let accounts: Vec<(Pubkey, AccountSharedData, Option)> = + let accounts: Vec<(Pubkey, Account, Option)> = value.accounts.into_iter().map(Into::into).collect(); let instruction_accounts: Vec = diff --git a/fuzz/fixture-fd/src/effects.rs b/fuzz/fixture-fd/src/effects.rs index 2bd94c1a..6c187a7b 100644 --- a/fuzz/fixture-fd/src/effects.rs +++ b/fuzz/fixture-fd/src/effects.rs @@ -3,7 +3,7 @@ use { super::proto::InstrEffects as ProtoEffects, crate::account::SeedAddress, - solana_sdk::{account::AccountSharedData, keccak::Hasher, pubkey::Pubkey}, + solana_sdk::{account::Account, keccak::Hasher, pubkey::Pubkey}, }; /// Represents the effects of a single instruction. @@ -14,7 +14,7 @@ pub struct Effects { // Custom error code, also non-zero if any. pub program_custom_code: u32, /// Copies of accounts that were changed. - pub modified_accounts: Vec<(Pubkey, AccountSharedData, Option)>, + pub modified_accounts: Vec<(Pubkey, Account, Option)>, /// Compute units available after executing the instruction. pub compute_units_available: u64, /// Instruction return data. @@ -31,7 +31,7 @@ impl From for Effects { return_data, } = value; - let modified_accounts: Vec<(Pubkey, AccountSharedData, Option)> = + let modified_accounts: Vec<(Pubkey, Account, Option)> = modified_accounts.into_iter().map(Into::into).collect(); Self { diff --git a/fuzz/fixture-fd/src/lib.rs b/fuzz/fixture-fd/src/lib.rs index f701d1e4..5f01a397 100644 --- a/fuzz/fixture-fd/src/lib.rs +++ b/fuzz/fixture-fd/src/lib.rs @@ -113,7 +113,7 @@ mod tests { }, mollusk_svm_fuzz_fs::SerializableFixture, solana_sdk::{ - account::AccountSharedData, feature_set::FeatureSet, keccak::Hash, pubkey::Pubkey, + account::Account, feature_set::FeatureSet, keccak::Hash, pubkey::Pubkey, transaction_context::InstructionAccount, }, }; @@ -131,22 +131,22 @@ mod tests { let accounts = vec![ ( Pubkey::new_unique(), - AccountSharedData::new(42, 42, &Pubkey::default()), + Account::new(42, 42, &Pubkey::default()), None, ), ( Pubkey::new_unique(), - AccountSharedData::new(42, 42, &Pubkey::default()), + Account::new(42, 42, &Pubkey::default()), None, ), ( Pubkey::new_unique(), - AccountSharedData::new(42, 42, &Pubkey::default()), + Account::new(42, 42, &Pubkey::default()), None, ), ( Pubkey::new_unique(), - AccountSharedData::new(42, 42, &Pubkey::default()), + Account::new(42, 42, &Pubkey::default()), None, ), ]; diff --git a/fuzz/fixture/src/account.rs b/fuzz/fixture/src/account.rs index 0f9f8a78..9ec02da1 100644 --- a/fuzz/fixture/src/account.rs +++ b/fuzz/fixture/src/account.rs @@ -1,15 +1,11 @@ -//! An account with an address: `(Pubkey, AccountSharedData)`. +//! An account with an address: `(Pubkey, Account)`. use { super::proto::AcctState as ProtoAccount, - solana_sdk::{ - account::{Account, AccountSharedData}, - keccak::Hasher, - pubkey::Pubkey, - }, + solana_sdk::{account::Account, keccak::Hasher, pubkey::Pubkey}, }; -impl From for (Pubkey, AccountSharedData) { +impl From for (Pubkey, Account) { fn from(value: ProtoAccount) -> Self { let ProtoAccount { address, @@ -28,26 +24,26 @@ impl From for (Pubkey, AccountSharedData) { ( pubkey, - AccountSharedData::from(Account { + Account { data, executable, lamports, owner, rent_epoch, - }), + }, ) } } -impl From<(Pubkey, AccountSharedData)> for ProtoAccount { - fn from(value: (Pubkey, AccountSharedData)) -> Self { +impl From<(Pubkey, Account)> for ProtoAccount { + fn from(value: (Pubkey, Account)) -> Self { let Account { lamports, data, owner, executable, rent_epoch, - } = value.1.into(); + } = value.1; ProtoAccount { address: value.0.to_bytes().to_vec(), diff --git a/fuzz/fixture/src/context.rs b/fuzz/fixture/src/context.rs index 5c334a4d..0f32f547 100644 --- a/fuzz/fixture/src/context.rs +++ b/fuzz/fixture/src/context.rs @@ -7,8 +7,8 @@ use { }, solana_compute_budget::compute_budget::ComputeBudget, solana_sdk::{ - account::AccountSharedData, feature_set::FeatureSet, instruction::AccountMeta, - keccak::Hasher, pubkey::Pubkey, + account::Account, feature_set::FeatureSet, instruction::AccountMeta, keccak::Hasher, + pubkey::Pubkey, }, }; @@ -28,7 +28,7 @@ pub struct Context { /// The instruction data. pub instruction_data: Vec, /// Input accounts with state. - pub accounts: Vec<(Pubkey, AccountSharedData)>, + pub accounts: Vec<(Pubkey, Account)>, } impl From for Context { @@ -39,8 +39,7 @@ impl From for Context { .expect("Invalid bytes for program ID"); let program_id = Pubkey::new_from_array(program_id_bytes); - let accounts: Vec<(Pubkey, AccountSharedData)> = - value.accounts.into_iter().map(Into::into).collect(); + let accounts: Vec<(Pubkey, Account)> = value.accounts.into_iter().map(Into::into).collect(); let instruction_accounts: Vec = value .instr_accounts diff --git a/fuzz/fixture/src/effects.rs b/fuzz/fixture/src/effects.rs index 80de330d..a59a8be1 100644 --- a/fuzz/fixture/src/effects.rs +++ b/fuzz/fixture/src/effects.rs @@ -2,7 +2,7 @@ use { super::proto::{AcctState as ProtoAccount, InstrEffects as ProtoEffects}, - solana_sdk::{account::AccountSharedData, keccak::Hasher, pubkey::Pubkey}, + solana_sdk::{account::Account, keccak::Hasher, pubkey::Pubkey}, }; /// Represents the effects of a single instruction. @@ -16,7 +16,7 @@ pub struct Effects { pub program_result: u64, pub return_data: Vec, /// Resulting accounts with state, to be checked post-simulation. - pub resulting_accounts: Vec<(Pubkey, AccountSharedData)>, + pub resulting_accounts: Vec<(Pubkey, Account)>, } impl From for Effects { @@ -29,7 +29,7 @@ impl From for Effects { resulting_accounts, } = value; - let resulting_accounts: Vec<(Pubkey, AccountSharedData)> = + let resulting_accounts: Vec<(Pubkey, Account)> = resulting_accounts.into_iter().map(Into::into).collect(); Self { diff --git a/fuzz/fixture/src/lib.rs b/fuzz/fixture/src/lib.rs index 3399979f..f4f23b27 100644 --- a/fuzz/fixture/src/lib.rs +++ b/fuzz/fixture/src/lib.rs @@ -97,8 +97,8 @@ mod tests { mollusk_svm_fuzz_fs::SerializableFixture, solana_compute_budget::compute_budget::ComputeBudget, solana_sdk::{ - account::AccountSharedData, feature_set::FeatureSet, instruction::AccountMeta, - keccak::Hash, pubkey::Pubkey, + account::Account, feature_set::FeatureSet, instruction::AccountMeta, keccak::Hash, + pubkey::Pubkey, }, }; @@ -124,12 +124,7 @@ mod tests { let instruction_data = vec![4; 24]; let accounts = instruction_accounts .iter() - .map(|meta| { - ( - meta.pubkey, - AccountSharedData::new(42, 42, &Pubkey::default()), - ) - }) + .map(|meta| (meta.pubkey, Account::new(42, 42, &Pubkey::default()))) .collect::>(); let context = Context { diff --git a/harness/benches/ips.rs b/harness/benches/ips.rs index 0c087513..04c4d8fc 100644 --- a/harness/benches/ips.rs +++ b/harness/benches/ips.rs @@ -3,8 +3,8 @@ use { criterion::{criterion_group, criterion_main, Criterion, Throughput}, mollusk_svm::{result::Check, Mollusk}, solana_sdk::{ - account::AccountSharedData, native_token::LAMPORTS_PER_SOL, pubkey::Pubkey, - system_instruction, system_program, + account::Account, native_token::LAMPORTS_PER_SOL, pubkey::Pubkey, system_instruction, + system_program, }, solana_system_program::system_processor::DEFAULT_COMPUTE_UNITS, }; @@ -20,11 +20,11 @@ fn transfer_checked_unchecked(c: &mut Criterion) { let accounts = vec![ ( sender, - AccountSharedData::new(base_lamports, 0, &system_program::id()), + Account::new(base_lamports, 0, &system_program::id()), ), ( recipient, - AccountSharedData::new(base_lamports, 0, &system_program::id()), + Account::new(base_lamports, 0, &system_program::id()), ), ]; let checks = vec![ diff --git a/harness/src/accounts.rs b/harness/src/accounts.rs index 9154586b..c20e1199 100644 --- a/harness/src/accounts.rs +++ b/harness/src/accounts.rs @@ -10,7 +10,7 @@ use { keys::KeyMap, }, solana_sdk::{ - account::{AccountSharedData, WritableAccount}, + account::{Account, WritableAccount}, instruction::Instruction, pubkey::Pubkey, transaction_context::{InstructionAccount, TransactionAccount}, @@ -25,11 +25,11 @@ pub struct CompiledAccounts { pub fn compile_accounts( instruction: &Instruction, - accounts: &[(Pubkey, AccountSharedData)], + accounts: &[(Pubkey, Account)], loader_key: Pubkey, ) -> CompiledAccounts { let stub_out_program_account = move || { - let mut program_account = AccountSharedData::default(); + let mut program_account = Account::default(); program_account.set_owner(loader_key); program_account.set_executable(true); program_account diff --git a/harness/src/fuzz/firedancer.rs b/harness/src/fuzz/firedancer.rs index 5cc9bc41..705978c8 100644 --- a/harness/src/fuzz/firedancer.rs +++ b/harness/src/fuzz/firedancer.rs @@ -21,7 +21,7 @@ use { }, solana_compute_budget::compute_budget::ComputeBudget, solana_sdk::{ - account::AccountSharedData, + account::Account, instruction::{AccountMeta, Instruction, InstructionError}, pubkey::Pubkey, }, @@ -68,7 +68,7 @@ fn num_to_instr_err(num: i32, custom_code: u32) -> InstructionError { fn build_fixture_context( mollusk: &Mollusk, instruction: &Instruction, - accounts: &[(Pubkey, AccountSharedData)], + accounts: &[(Pubkey, Account)], ) -> FuzzContext { let Mollusk { compute_budget, @@ -91,7 +91,7 @@ fn build_fixture_context( let accounts = transaction_accounts .into_iter() - .map(|(key, account)| (key, account, None)) + .map(|(key, account)| (key, account.into(), None)) .collect::>(); FuzzContext { @@ -107,9 +107,7 @@ fn build_fixture_context( } } -fn parse_fixture_context( - context: &FuzzContext, -) -> (Mollusk, Instruction, Vec<(Pubkey, AccountSharedData)>) { +fn parse_fixture_context(context: &FuzzContext) -> (Mollusk, Instruction, Vec<(Pubkey, Account)>) { let FuzzContext { program_id, accounts, @@ -199,7 +197,7 @@ fn build_fixture_effects(context: &FuzzContext, result: &InstructionResult) -> F fn parse_fixture_effects( mollusk: &Mollusk, - accounts: &[(Pubkey, AccountSharedData)], + accounts: &[(Pubkey, Account)], effects: &FuzzEffects, ) -> InstructionResult { let raw_result = if effects.program_result == 0 { @@ -250,7 +248,7 @@ fn instruction_metadata() -> FuzzMetadata { pub fn build_fixture_from_mollusk_test( mollusk: &Mollusk, instruction: &Instruction, - accounts: &[(Pubkey, AccountSharedData)], + accounts: &[(Pubkey, Account)], result: &InstructionResult, _checks: &[Check], ) -> FuzzFixture { @@ -270,7 +268,7 @@ pub fn load_firedancer_fixture( ) -> ( Mollusk, Instruction, - Vec<(Pubkey, AccountSharedData)>, + Vec<(Pubkey, Account)>, InstructionResult, ) { let (mollusk, instruction, accounts) = parse_fixture_context(&fixture.input); diff --git a/harness/src/fuzz/mod.rs b/harness/src/fuzz/mod.rs index 0e3835b2..20ff8889 100644 --- a/harness/src/fuzz/mod.rs +++ b/harness/src/fuzz/mod.rs @@ -9,13 +9,13 @@ use { Mollusk, }, mollusk_svm_fuzz_fs::FsHandler, - solana_sdk::{account::AccountSharedData, instruction::Instruction, pubkey::Pubkey}, + solana_sdk::{account::Account, instruction::Instruction, pubkey::Pubkey}, }; pub fn generate_fixtures_from_mollusk_test( mollusk: &Mollusk, instruction: &Instruction, - accounts: &[(Pubkey, AccountSharedData)], + accounts: &[(Pubkey, Account)], result: &InstructionResult, checks: &[Check], ) { diff --git a/harness/src/fuzz/mollusk.rs b/harness/src/fuzz/mollusk.rs index df528e6e..d13560d7 100644 --- a/harness/src/fuzz/mollusk.rs +++ b/harness/src/fuzz/mollusk.rs @@ -15,7 +15,7 @@ use { sysvars::Sysvars as FuzzSysvars, Fixture as FuzzFixture, }, solana_sdk::{ - account::AccountSharedData, + account::Account, instruction::{Instruction, InstructionError}, pubkey::Pubkey, slot_hashes::SlotHashes, @@ -106,7 +106,7 @@ impl From<&FuzzEffects> for InstructionResult { fn build_fixture_context( mollusk: &Mollusk, instruction: &Instruction, - accounts: &[(Pubkey, AccountSharedData)], + accounts: &[(Pubkey, Account)], ) -> FuzzContext { let Mollusk { compute_budget, @@ -130,9 +130,7 @@ fn build_fixture_context( } } -fn parse_fixture_context( - context: &FuzzContext, -) -> (Mollusk, Instruction, Vec<(Pubkey, AccountSharedData)>) { +fn parse_fixture_context(context: &FuzzContext) -> (Mollusk, Instruction, Vec<(Pubkey, Account)>) { let FuzzContext { compute_budget, feature_set, @@ -161,7 +159,7 @@ fn parse_fixture_context( pub fn build_fixture_from_mollusk_test( mollusk: &Mollusk, instruction: &Instruction, - accounts: &[(Pubkey, AccountSharedData)], + accounts: &[(Pubkey, Account)], result: &InstructionResult, _checks: &[Check], ) -> FuzzFixture { @@ -177,7 +175,7 @@ pub fn load_fixture( ) -> ( Mollusk, Instruction, - Vec<(Pubkey, AccountSharedData)>, + Vec<(Pubkey, Account)>, InstructionResult, ) { let (mollusk, instruction, accounts) = parse_fixture_context(&fixture.input); diff --git a/harness/src/lib.rs b/harness/src/lib.rs index a66e366e..5d016cf4 100644 --- a/harness/src/lib.rs +++ b/harness/src/lib.rs @@ -46,9 +46,9 @@ use { solana_compute_budget::compute_budget::ComputeBudget, solana_program_runtime::invoke_context::{EnvironmentConfig, InvokeContext}, solana_sdk::{ - account::AccountSharedData, bpf_loader_upgradeable, feature_set::FeatureSet, - fee::FeeStructure, hash::Hash, instruction::Instruction, precompiles::get_precompile, - pubkey::Pubkey, transaction_context::TransactionContext, + account::Account, bpf_loader_upgradeable, feature_set::FeatureSet, fee::FeeStructure, + hash::Hash, instruction::Instruction, precompiles::get_precompile, pubkey::Pubkey, + transaction_context::TransactionContext, }, solana_timings::ExecuteTimings, std::sync::Arc, @@ -151,7 +151,7 @@ impl Mollusk { pub fn process_instruction( &self, instruction: &Instruction, - accounts: &[(Pubkey, AccountSharedData)], + accounts: &[(Pubkey, Account)], ) -> InstructionResult { let mut compute_units_consumed = 0; let mut timings = ExecuteTimings::default(); @@ -219,19 +219,26 @@ impl Mollusk { let return_data = transaction_context.get_return_data().1.to_vec(); - let resulting_accounts: Vec<(Pubkey, AccountSharedData)> = accounts - .iter() - .map(|(pubkey, account)| { - transaction_context - .find_index_of_account(pubkey) - .map(|index| { - let resulting_account = - transaction_context.get_account_at_index(index).unwrap(); - (*pubkey, resulting_account.take()) - }) - .unwrap_or((*pubkey, account.clone())) - }) - .collect(); + let resulting_accounts: Vec<(Pubkey, Account)> = if invoke_result.is_ok() { + accounts + .iter() + .map(|(pubkey, account)| { + transaction_context + .find_index_of_account(pubkey) + .map(|index| { + let resulting_account = transaction_context + .get_account_at_index(index) + .unwrap() + .take() + .into(); + (*pubkey, resulting_account) + }) + .unwrap_or((*pubkey, account.clone())) + }) + .collect() + } else { + accounts.to_vec() + }; InstructionResult { compute_units_consumed, @@ -256,7 +263,7 @@ impl Mollusk { pub fn process_instruction_chain( &self, instructions: &[Instruction], - accounts: &[(Pubkey, AccountSharedData)], + accounts: &[(Pubkey, Account)], ) -> InstructionResult { let mut result = InstructionResult { resulting_accounts: accounts.to_vec(), @@ -305,7 +312,7 @@ impl Mollusk { pub fn process_and_validate_instruction( &self, instruction: &Instruction, - accounts: &[(Pubkey, AccountSharedData)], + accounts: &[(Pubkey, Account)], checks: &[Check], ) -> InstructionResult { let result = self.process_instruction(instruction, accounts); @@ -323,7 +330,7 @@ impl Mollusk { pub fn process_and_validate_instruction_chain( &self, instructions: &[Instruction], - accounts: &[(Pubkey, AccountSharedData)], + accounts: &[(Pubkey, Account)], checks: &[Check], ) -> InstructionResult { let result = self.process_instruction_chain(instructions, accounts); diff --git a/harness/src/program.rs b/harness/src/program.rs index cb31cd00..73b11a05 100644 --- a/harness/src/program.rs +++ b/harness/src/program.rs @@ -8,12 +8,8 @@ use { loaded_programs::{LoadProgramMetrics, ProgramCacheEntry, ProgramCacheForTxBatch}, }, solana_sdk::{ - account::{Account, AccountSharedData}, - bpf_loader_upgradeable::UpgradeableLoaderState, - feature_set::FeatureSet, - native_loader, - pubkey::Pubkey, - rent::Rent, + account::Account, bpf_loader_upgradeable::UpgradeableLoaderState, feature_set::FeatureSet, + native_loader, pubkey::Pubkey, rent::Rent, }, std::sync::{Arc, RwLock}, }; @@ -155,62 +151,62 @@ static BUILTINS: &[Builtin] = &[ pub fn create_keyed_account_for_builtin_program( program_id: &Pubkey, name: &str, -) -> (Pubkey, AccountSharedData) { +) -> (Pubkey, Account) { let data = name.as_bytes().to_vec(); let lamports = Rent::default().minimum_balance(data.len()); - let account = AccountSharedData::from(Account { + let account = Account { lamports, data, owner: native_loader::id(), executable: true, - rent_epoch: 0, - }); + ..Default::default() + }; (*program_id, account) } /// Get the key and account for the system program. -pub fn keyed_account_for_system_program() -> (Pubkey, AccountSharedData) { +pub fn keyed_account_for_system_program() -> (Pubkey, Account) { create_keyed_account_for_builtin_program(&BUILTINS[0].program_id, BUILTINS[0].name) } /// Get the key and account for the BPF Loader v2 program. -pub fn keyed_account_for_bpf_loader_v2_program() -> (Pubkey, AccountSharedData) { +pub fn keyed_account_for_bpf_loader_v2_program() -> (Pubkey, Account) { create_keyed_account_for_builtin_program(&BUILTINS[1].program_id, BUILTINS[1].name) } /// Get the key and account for the BPF Loader v3 (Upgradeable) program. -pub fn keyed_account_for_bpf_loader_v3_program() -> (Pubkey, AccountSharedData) { +pub fn keyed_account_for_bpf_loader_v3_program() -> (Pubkey, Account) { create_keyed_account_for_builtin_program(&BUILTINS[1].program_id, BUILTINS[1].name) } /* ... */ /// Create a BPF Loader 1 (deprecated) program account. -pub fn create_program_account_loader_v1(elf: &[u8]) -> AccountSharedData { +pub fn create_program_account_loader_v1(elf: &[u8]) -> Account { let lamports = Rent::default().minimum_balance(elf.len()); - AccountSharedData::from(Account { + Account { lamports, data: elf.to_vec(), owner: loader_keys::LOADER_V1, executable: true, - rent_epoch: 0, - }) + ..Default::default() + } } /// Create a BPF Loader 2 program account. -pub fn create_program_account_loader_v2(elf: &[u8]) -> AccountSharedData { +pub fn create_program_account_loader_v2(elf: &[u8]) -> Account { let lamports = Rent::default().minimum_balance(elf.len()); - AccountSharedData::from(Account { + Account { lamports, data: elf.to_vec(), owner: loader_keys::LOADER_V2, executable: true, - rent_epoch: 0, - }) + ..Default::default() + } } /// Create a BPF Loader v3 (Upgradeable) program account. -pub fn create_program_account_loader_v3(program_id: &Pubkey) -> AccountSharedData { +pub fn create_program_account_loader_v3(program_id: &Pubkey) -> Account { let programdata_address = Pubkey::find_program_address(&[program_id.as_ref()], &loader_keys::LOADER_V3).0; let data = bincode::serialize(&UpgradeableLoaderState::Program { @@ -218,17 +214,17 @@ pub fn create_program_account_loader_v3(program_id: &Pubkey) -> AccountSharedDat }) .unwrap(); let lamports = Rent::default().minimum_balance(data.len()); - AccountSharedData::from(Account { + Account { lamports, data, owner: loader_keys::LOADER_V3, executable: true, - rent_epoch: 0, - }) + ..Default::default() + } } /// Create a BPF Loader v3 (Upgradeable) program data account. -pub fn create_program_data_account_loader_v3(elf: &[u8]) -> AccountSharedData { +pub fn create_program_data_account_loader_v3(elf: &[u8]) -> Account { let data = { let elf_offset = UpgradeableLoaderState::size_of_programdata_metadata(); let data_len = elf_offset + elf.len(); @@ -245,13 +241,13 @@ pub fn create_program_data_account_loader_v3(elf: &[u8]) -> AccountSharedData { data }; let lamports = Rent::default().minimum_balance(data.len()); - AccountSharedData::from(Account { + Account { lamports, data, owner: loader_keys::LOADER_V3, executable: false, - rent_epoch: 0, - }) + ..Default::default() + } } /// Create a BPF Loader v3 (Upgradeable) program and program data account. @@ -261,7 +257,7 @@ pub fn create_program_data_account_loader_v3(elf: &[u8]) -> AccountSharedData { pub fn create_program_account_pair_loader_v3( program_id: &Pubkey, elf: &[u8], -) -> (AccountSharedData, AccountSharedData) { +) -> (Account, Account) { ( create_program_account_loader_v3(program_id), create_program_data_account_loader_v3(elf), diff --git a/harness/src/result.rs b/harness/src/result.rs index ea37dfdb..06d50a91 100644 --- a/harness/src/result.rs +++ b/harness/src/result.rs @@ -1,7 +1,7 @@ //! Results of Mollusk program execution. use solana_sdk::{ - account::{AccountSharedData, ReadableAccount}, + account::{Account, ReadableAccount}, instruction::InstructionError, program_error::ProgramError, pubkey::Pubkey, @@ -58,7 +58,7 @@ pub struct InstructionResult { /// This includes all accounts provided to the processor, in the order /// they were provided. Any accounts that were modified will maintain /// their original position in this list, but with updated state. - pub resulting_accounts: Vec<(Pubkey, AccountSharedData)>, + pub resulting_accounts: Vec<(Pubkey, Account)>, } impl Default for InstructionResult { @@ -76,7 +76,7 @@ impl Default for InstructionResult { impl InstructionResult { /// Get an account from the resulting accounts by its pubkey. - pub fn get_account(&self, pubkey: &Pubkey) -> Option<&AccountSharedData> { + pub fn get_account(&self, pubkey: &Pubkey) -> Option<&Account> { self.resulting_accounts .iter() .find(|(k, _)| k == pubkey) @@ -177,7 +177,7 @@ impl InstructionResult { match check_state { AccountStateCheck::Closed => { assert_eq!( - &AccountSharedData::default(), + &Account::default(), resulting_account, "CHECK: account closed: got false, expected true" ); diff --git a/harness/src/sysvar.rs b/harness/src/sysvar.rs index 9972a2b2..3f4dfd4b 100644 --- a/harness/src/sysvar.rs +++ b/harness/src/sysvar.rs @@ -3,7 +3,7 @@ use { solana_program_runtime::sysvar_cache::SysvarCache, solana_sdk::{ - account::{AccountSharedData, ReadableAccount}, + account::{Account, ReadableAccount}, clock::{Clock, Slot}, epoch_rewards::EpochRewards, epoch_schedule::EpochSchedule, @@ -59,47 +59,52 @@ impl Default for Sysvars { } impl Sysvars { - fn sysvar_account(&self, sysvar: &T) -> (Pubkey, AccountSharedData) { + fn sysvar_account(&self, sysvar: &T) -> (Pubkey, Account) { let data = bincode::serialize::(sysvar).unwrap(); let space = data.len(); let lamports = self.rent.minimum_balance(space); - let mut account = AccountSharedData::new(lamports, space, &sysvar::id()); - account.set_data_from_slice(&data); + let account = Account { + lamports, + data, + owner: sysvar::id(), + executable: false, + ..Default::default() + }; (T::id(), account) } /// Get the key and account for the clock sysvar. - pub fn keyed_account_for_clock_sysvar(&self) -> (Pubkey, AccountSharedData) { + pub fn keyed_account_for_clock_sysvar(&self) -> (Pubkey, Account) { self.sysvar_account(&self.clock) } /// Get the key and account for the epoch rewards sysvar. - pub fn keyed_account_for_epoch_rewards_sysvar(&self) -> (Pubkey, AccountSharedData) { + pub fn keyed_account_for_epoch_rewards_sysvar(&self) -> (Pubkey, Account) { self.sysvar_account(&self.epoch_rewards) } /// Get the key and account for the epoch schedule sysvar. - pub fn keyed_account_for_epoch_schedule_sysvar(&self) -> (Pubkey, AccountSharedData) { + pub fn keyed_account_for_epoch_schedule_sysvar(&self) -> (Pubkey, Account) { self.sysvar_account(&self.epoch_schedule) } /// Get the key and account for the last restart slot sysvar. - pub fn keyed_account_for_last_restart_slot_sysvar(&self) -> (Pubkey, AccountSharedData) { + pub fn keyed_account_for_last_restart_slot_sysvar(&self) -> (Pubkey, Account) { self.sysvar_account(&self.last_restart_slot) } /// Get the key and account for the rent sysvar. - pub fn keyed_account_for_rent_sysvar(&self) -> (Pubkey, AccountSharedData) { + pub fn keyed_account_for_rent_sysvar(&self) -> (Pubkey, Account) { self.sysvar_account(&self.rent) } /// Get the key and account for the slot hashes sysvar. - pub fn keyed_account_for_slot_hashes_sysvar(&self) -> (Pubkey, AccountSharedData) { + pub fn keyed_account_for_slot_hashes_sysvar(&self) -> (Pubkey, Account) { self.sysvar_account(&self.slot_hashes) } /// Get the key and account for the stake history sysvar. - pub fn keyed_account_for_stake_history_sysvar(&self) -> (Pubkey, AccountSharedData) { + pub fn keyed_account_for_stake_history_sysvar(&self) -> (Pubkey, Account) { self.sysvar_account(&self.stake_history) } @@ -143,10 +148,7 @@ impl Sysvars { } } - pub(crate) fn setup_sysvar_cache( - &self, - accounts: &[(Pubkey, AccountSharedData)], - ) -> SysvarCache { + pub(crate) fn setup_sysvar_cache(&self, accounts: &[(Pubkey, Account)]) -> SysvarCache { let mut sysvar_cache = SysvarCache::default(); // First fill any sysvar cache entries from the provided accounts. diff --git a/harness/tests/bpf_program.rs b/harness/tests/bpf_program.rs index bcc5b959..cee60ad6 100644 --- a/harness/tests/bpf_program.rs +++ b/harness/tests/bpf_program.rs @@ -5,7 +5,7 @@ use { Mollusk, }, solana_sdk::{ - account::AccountSharedData, + account::Account, incinerator, instruction::{AccountMeta, Instruction, InstructionError}, program_error::ProgramError, @@ -28,7 +28,7 @@ fn test_write_data() { let lamports = mollusk.sysvars.rent.minimum_balance(space); let key = Pubkey::new_unique(); - let account = AccountSharedData::new(lamports, space, &program_id); + let account = Account::new(lamports, space, &program_id); let instruction = { let mut instruction_data = vec![1]; @@ -91,11 +91,11 @@ fn test_transfer() { let payer = Pubkey::new_unique(); let payer_lamports = 100_000_000; - let payer_account = AccountSharedData::new(payer_lamports, 0, &system_program::id()); + let payer_account = Account::new(payer_lamports, 0, &system_program::id()); let recipient = Pubkey::new_unique(); let recipient_lamports = 0; - let recipient_account = AccountSharedData::new(recipient_lamports, 0, &system_program::id()); + let recipient_account = Account::new(recipient_lamports, 0, &system_program::id()); let transfer_amount = 2_000_000_u64; @@ -134,7 +134,7 @@ fn test_transfer() { mollusk.process_and_validate_instruction( &instruction, &[ - (payer, AccountSharedData::default()), + (payer, Account::default()), (recipient, recipient_account.clone()), keyed_account_for_system_program(), ], @@ -174,7 +174,7 @@ fn test_close_account() { let mollusk = Mollusk::new(&program_id, "test_program_primary"); let key = Pubkey::new_unique(); - let account = AccountSharedData::new(50_000_000, 50, &program_id); + let account = Account::new(50_000_000, 50, &program_id); let instruction = Instruction::new_with_bytes( program_id, @@ -195,7 +195,7 @@ fn test_close_account() { &account_not_signer_ix, &[ (key, account.clone()), - (incinerator::id(), AccountSharedData::default()), + (incinerator::id(), Account::default()), keyed_account_for_system_program(), ], &[Check::err(ProgramError::MissingRequiredSignature)], @@ -207,7 +207,7 @@ fn test_close_account() { &instruction, &[ (key, account.clone()), - (incinerator::id(), AccountSharedData::default()), + (incinerator::id(), Account::default()), keyed_account_for_system_program(), ], &[ @@ -238,7 +238,7 @@ fn test_cpi() { let lamports = mollusk.sysvars.rent.minimum_balance(space); let key = Pubkey::new_unique(); - let account = AccountSharedData::new(lamports, space, &cpi_target_program_id); + let account = Account::new(lamports, space, &cpi_target_program_id); let instruction = { let mut instruction_data = vec![4]; @@ -365,10 +365,7 @@ fn test_account_dedupe() { ); mollusk.process_and_validate_instruction( &instruction, - &[ - (key, AccountSharedData::default()), - (key, AccountSharedData::default()), - ], + &[(key, Account::default()), (key, Account::default())], &[Check::success()], ); } @@ -385,10 +382,7 @@ fn test_account_dedupe() { ); mollusk.process_and_validate_instruction( &instruction, - &[ - (key, AccountSharedData::default()), - (key, AccountSharedData::default()), - ], + &[(key, Account::default()), (key, Account::default())], &[Check::success()], ); } @@ -405,10 +399,7 @@ fn test_account_dedupe() { ); mollusk.process_and_validate_instruction( &instruction, - &[ - (key, AccountSharedData::default()), - (key, AccountSharedData::default()), - ], + &[(key, Account::default()), (key, Account::default())], &[Check::success()], ); } diff --git a/harness/tests/dump_fixture.rs b/harness/tests/dump_fixture.rs index 8b6eaffe..7315dec8 100644 --- a/harness/tests/dump_fixture.rs +++ b/harness/tests/dump_fixture.rs @@ -4,8 +4,8 @@ use { mollusk_svm::{result::Check, Mollusk}, serial_test::serial, solana_sdk::{ - account::AccountSharedData, feature_set::FeatureSet, instruction::Instruction, - pubkey::Pubkey, system_instruction, system_program, + account::Account, feature_set::FeatureSet, instruction::Instruction, pubkey::Pubkey, + system_instruction, system_program, }, std::path::Path, }; @@ -73,7 +73,7 @@ const TRANSFER_AMOUNT: u64 = 42_000; struct TestSetup<'a> { mollusk: Mollusk, instruction: Instruction, - accounts: Vec<(Pubkey, AccountSharedData)>, + accounts: Vec<(Pubkey, Account)>, checks: Vec>, } @@ -85,11 +85,11 @@ impl<'a> TestSetup<'a> { let accounts = vec![ ( *sender, - AccountSharedData::new(BASE_LAMPORTS, 0, &system_program::id()), + Account::new(BASE_LAMPORTS, 0, &system_program::id()), ), ( *recipient, - AccountSharedData::new(BASE_LAMPORTS, 0, &system_program::id()), + Account::new(BASE_LAMPORTS, 0, &system_program::id()), ), ]; let checks = vec![ diff --git a/harness/tests/fd_test_vectors.rs b/harness/tests/fd_test_vectors.rs index e4290c03..a702a151 100644 --- a/harness/tests/fd_test_vectors.rs +++ b/harness/tests/fd_test_vectors.rs @@ -5,7 +5,7 @@ use { mollusk_svm_fuzz_fixture_firedancer::{account::SeedAddress, Fixture}, rayon::prelude::*, solana_sdk::{ - account::AccountSharedData, feature_set::FeatureSet, pubkey::Pubkey, + account::Account, feature_set::FeatureSet, pubkey::Pubkey, transaction_context::InstructionAccount, }, std::{assert_eq, fs, path::Path, process::Command}, @@ -112,8 +112,8 @@ fn test_load_firedancer_fixtures() { } fn compare_accounts( - a: &[(Pubkey, AccountSharedData, Option)], - b: &[(Pubkey, AccountSharedData, Option)], + a: &[(Pubkey, Account, Option)], + b: &[(Pubkey, Account, Option)], ) -> bool { if a.len() != b.len() { return false; diff --git a/harness/tests/instruction_chain.rs b/harness/tests/instruction_chain.rs index 330b20a4..be03e3f1 100644 --- a/harness/tests/instruction_chain.rs +++ b/harness/tests/instruction_chain.rs @@ -1,7 +1,7 @@ use { mollusk_svm::{program::keyed_account_for_system_program, result::Check, Mollusk}, solana_sdk::{ - account::AccountSharedData, + account::Account, incinerator, instruction::{AccountMeta, Instruction}, pubkey::Pubkey, @@ -9,8 +9,8 @@ use { }, }; -fn system_account_with_lamports(lamports: u64) -> AccountSharedData { - AccountSharedData::new(lamports, 0, &system_program::id()) +fn system_account_with_lamports(lamports: u64) -> Account { + Account::new(lamports, 0, &system_program::id()) } #[test] @@ -129,9 +129,9 @@ fn test_mixed() { ], &[ (payer, system_account_with_lamports(lamports * 4)), - (target1, AccountSharedData::default()), - (target2, AccountSharedData::default()), - (incinerator::id(), AccountSharedData::default()), + (target1, Account::default()), + (target2, Account::default()), + (incinerator::id(), Account::default()), keyed_account_for_system_program(), ], &[ diff --git a/harness/tests/precompile.rs b/harness/tests/precompile.rs index 0df94e61..d21e1edd 100644 --- a/harness/tests/precompile.rs +++ b/harness/tests/precompile.rs @@ -2,7 +2,7 @@ use { mollusk_svm::{result::Check, Mollusk}, rand0_7::thread_rng, solana_sdk::{ - account::{AccountSharedData, WritableAccount}, + account::{Account, WritableAccount}, ed25519_instruction::new_ed25519_instruction, ed25519_program, native_loader, pubkey::Pubkey, @@ -11,8 +11,8 @@ use { }, }; -fn precompile_account() -> AccountSharedData { - let mut account = AccountSharedData::new(1, 0, &native_loader::id()); +fn precompile_account() -> Account { + let mut account = Account::new(1, 0, &native_loader::id()); account.set_executable(true); account } @@ -25,7 +25,7 @@ fn test_secp256k1() { mollusk.process_and_validate_instruction( &new_secp256k1_instruction(&secret_key, b"hello"), &[ - (Pubkey::new_unique(), AccountSharedData::default()), + (Pubkey::new_unique(), Account::default()), (secp256k1_program::id(), precompile_account()), ], &[Check::success()], @@ -40,7 +40,7 @@ fn test_ed25519() { mollusk.process_and_validate_instruction( &new_ed25519_instruction(&secret_key, b"hello"), &[ - (Pubkey::new_unique(), AccountSharedData::default()), + (Pubkey::new_unique(), Account::default()), (ed25519_program::id(), precompile_account()), ], &[Check::success()], diff --git a/harness/tests/process_fixture.rs b/harness/tests/process_fixture.rs index c617fec7..5cb7bb3c 100644 --- a/harness/tests/process_fixture.rs +++ b/harness/tests/process_fixture.rs @@ -2,7 +2,7 @@ use { mollusk_svm::Mollusk, - solana_sdk::{account::AccountSharedData, pubkey::Pubkey, system_instruction, system_program}, + solana_sdk::{account::Account, pubkey::Pubkey, system_instruction, system_program}, }; const BASE_LAMPORTS: u64 = 100_000_000; @@ -21,11 +21,11 @@ fn test_process_mollusk() { let accounts = vec![ ( sender, - AccountSharedData::new(BASE_LAMPORTS, 0, &system_program::id()), + Account::new(BASE_LAMPORTS, 0, &system_program::id()), ), ( recipient, - AccountSharedData::new(BASE_LAMPORTS, 0, &system_program::id()), + Account::new(BASE_LAMPORTS, 0, &system_program::id()), ), ]; @@ -72,11 +72,11 @@ fn test_process_firedancer() { let accounts = vec![ ( sender, - AccountSharedData::new(BASE_LAMPORTS, 0, &system_program::id()), + Account::new(BASE_LAMPORTS, 0, &system_program::id()), ), ( recipient, - AccountSharedData::new(BASE_LAMPORTS, 0, &system_program::id()), + Account::new(BASE_LAMPORTS, 0, &system_program::id()), ), ]; diff --git a/harness/tests/system_program.rs b/harness/tests/system_program.rs index bd6bdf17..f78c8759 100644 --- a/harness/tests/system_program.rs +++ b/harness/tests/system_program.rs @@ -1,8 +1,8 @@ use { mollusk_svm::{result::Check, Mollusk}, solana_sdk::{ - account::AccountSharedData, instruction::InstructionError, pubkey::Pubkey, - system_instruction, system_program, + account::Account, instruction::InstructionError, pubkey::Pubkey, system_instruction, + system_program, }, solana_system_program::system_processor::DEFAULT_COMPUTE_UNITS, }; @@ -19,11 +19,11 @@ fn test_transfer() { let accounts = [ ( sender, - AccountSharedData::new(base_lamports, 0, &system_program::id()), + Account::new(base_lamports, 0, &system_program::id()), ), ( recipient, - AccountSharedData::new(base_lamports, 0, &system_program::id()), + Account::new(base_lamports, 0, &system_program::id()), ), ]; let checks = vec![ @@ -54,11 +54,11 @@ fn test_transfer_account_ordering() { let accounts = [ ( recipient, - AccountSharedData::new(base_lamports, 0, &system_program::id()), + Account::new(base_lamports, 0, &system_program::id()), ), ( sender, - AccountSharedData::new(base_lamports, 0, &system_program::id()), + Account::new(base_lamports, 0, &system_program::id()), ), ]; let checks = vec![ @@ -87,11 +87,11 @@ fn test_transfer_bad_owner() { let accounts = [ ( sender, - AccountSharedData::new(base_lamports, 0, &Pubkey::new_unique()), // <-- Bad owner. + Account::new(base_lamports, 0, &Pubkey::new_unique()), // <-- Bad owner. ), ( recipient, - AccountSharedData::new(base_lamports, 0, &system_program::id()), + Account::new(base_lamports, 0, &system_program::id()), ), ]; let checks = vec![ diff --git a/keys/src/accounts.rs b/keys/src/accounts.rs index e827f9bb..b3e47ea4 100644 --- a/keys/src/accounts.rs +++ b/keys/src/accounts.rs @@ -4,7 +4,7 @@ use { crate::keys::KeyMap, mollusk_svm_error::error::{MolluskError, MolluskPanic}, solana_sdk::{ - account::AccountSharedData, + account::{Account, AccountSharedData}, instruction::Instruction, pubkey::Pubkey, transaction_context::{IndexOfAccount, InstructionAccount, TransactionAccount}, @@ -62,21 +62,21 @@ pub fn compile_instruction_accounts( pub fn compile_transaction_accounts_for_instruction( key_map: &KeyMap, instruction: &Instruction, - accounts: &[(Pubkey, AccountSharedData)], - stub_out_program_account: Option AccountSharedData>>, + accounts: &[(Pubkey, Account)], + stub_out_program_account: Option Account>>, ) -> Vec { key_map .keys() .map(|key| { if let Some(stub_out_program_account) = &stub_out_program_account { if instruction.program_id == *key { - return (*key, stub_out_program_account()); + return (*key, stub_out_program_account().into()); } } let account = accounts .iter() .find(|(k, _)| k == key) - .map(|(_, account)| account.clone()) + .map(|(_, account)| AccountSharedData::from(account.clone())) .or_panic_with(MolluskError::AccountMissing(key)); (*key, account) }) @@ -86,21 +86,21 @@ pub fn compile_transaction_accounts_for_instruction( pub fn compile_transaction_accounts( key_map: &KeyMap, instructions: &[Instruction], - accounts: &[(Pubkey, AccountSharedData)], - stub_out_program_account: Option AccountSharedData>>, + accounts: &[(Pubkey, Account)], + stub_out_program_account: Option Account>>, ) -> Vec { key_map .keys() .map(|key| { if let Some(stub_out_program_account) = &stub_out_program_account { if instructions.iter().any(|ix| ix.program_id == *key) { - return (*key, stub_out_program_account()); + return (*key, stub_out_program_account().into()); } } let account = accounts .iter() .find(|(k, _)| k == key) - .map(|(_, account)| account.clone()) + .map(|(_, account)| AccountSharedData::from(account.clone())) .or_panic_with(MolluskError::AccountMissing(key)); (*key, account) }) diff --git a/programs/memo/src/memo.rs b/programs/memo/src/memo.rs index b47ac53d..86143f5f 100644 --- a/programs/memo/src/memo.rs +++ b/programs/memo/src/memo.rs @@ -1,6 +1,6 @@ use { mollusk_svm::Mollusk, - solana_sdk::{account::AccountSharedData, pubkey::Pubkey}, + solana_sdk::{account::Account, pubkey::Pubkey}, }; pub const ID: Pubkey = solana_sdk::pubkey!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"); @@ -16,12 +16,12 @@ pub fn add_program(mollusk: &mut Mollusk) { ); } -pub fn account() -> AccountSharedData { +pub fn account() -> Account { // Loader v2 mollusk_svm::program::create_program_account_loader_v2(ELF) } /// Get the key and account for the SPL Memo program. -pub fn keyed_account() -> (Pubkey, AccountSharedData) { +pub fn keyed_account() -> (Pubkey, Account) { (ID, account()) } diff --git a/programs/memo/src/memo_v1.rs b/programs/memo/src/memo_v1.rs index 6f5bbf92..2c99dd9b 100644 --- a/programs/memo/src/memo_v1.rs +++ b/programs/memo/src/memo_v1.rs @@ -1,6 +1,6 @@ use { mollusk_svm::Mollusk, - solana_sdk::{account::AccountSharedData, pubkey::Pubkey}, + solana_sdk::{account::Account, pubkey::Pubkey}, }; pub const ID: Pubkey = solana_sdk::pubkey!("Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo"); @@ -16,12 +16,12 @@ pub fn add_program(mollusk: &mut Mollusk) { ); } -pub fn account() -> AccountSharedData { +pub fn account() -> Account { // Loader v1 mollusk_svm::program::create_program_account_loader_v1(ELF) } /// Get the key and account for the SPL Memo program V1. -pub fn keyed_account() -> (Pubkey, AccountSharedData) { +pub fn keyed_account() -> (Pubkey, Account) { (ID, account()) } diff --git a/programs/token/src/associated_token.rs b/programs/token/src/associated_token.rs index f396d234..95c7ecc5 100644 --- a/programs/token/src/associated_token.rs +++ b/programs/token/src/associated_token.rs @@ -1,6 +1,6 @@ use { mollusk_svm::Mollusk, - solana_sdk::{account::AccountSharedData, pubkey::Pubkey}, + solana_sdk::{account::Account, pubkey::Pubkey}, }; pub const ID: Pubkey = solana_sdk::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"); @@ -16,12 +16,12 @@ pub fn add_program(mollusk: &mut Mollusk) { ); } -pub fn account() -> AccountSharedData { +pub fn account() -> Account { // Loader v2 mollusk_svm::program::create_program_account_loader_v2(ELF) } /// Get the key and account for the SPL Associated Token program. -pub fn keyed_account() -> (Pubkey, AccountSharedData) { +pub fn keyed_account() -> (Pubkey, Account) { (ID, account()) } diff --git a/programs/token/src/token.rs b/programs/token/src/token.rs index f984e86f..5cde2e60 100644 --- a/programs/token/src/token.rs +++ b/programs/token/src/token.rs @@ -1,6 +1,6 @@ use { mollusk_svm::Mollusk, - solana_sdk::{account::AccountSharedData, pubkey::Pubkey}, + solana_sdk::{account::Account, pubkey::Pubkey}, }; pub const ID: Pubkey = solana_sdk::pubkey!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"); @@ -16,12 +16,12 @@ pub fn add_program(mollusk: &mut Mollusk) { ); } -pub fn account() -> AccountSharedData { +pub fn account() -> Account { // Loader v2 mollusk_svm::program::create_program_account_loader_v2(ELF) } /// Get the key and account for the SPL Token program. -pub fn keyed_account() -> (Pubkey, AccountSharedData) { +pub fn keyed_account() -> (Pubkey, Account) { (ID, account()) } diff --git a/programs/token/src/token2022.rs b/programs/token/src/token2022.rs index 9f505dc5..44e05a89 100644 --- a/programs/token/src/token2022.rs +++ b/programs/token/src/token2022.rs @@ -1,6 +1,6 @@ use { mollusk_svm::Mollusk, - solana_sdk::{account::AccountSharedData, pubkey::Pubkey}, + solana_sdk::{account::Account, pubkey::Pubkey}, }; pub const ID: Pubkey = solana_sdk::pubkey!("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"); @@ -16,12 +16,12 @@ pub fn add_program(mollusk: &mut Mollusk) { ); } -pub fn account() -> AccountSharedData { +pub fn account() -> Account { // Loader v3 mollusk_svm::program::create_program_account_loader_v3(&ID) } /// Get the key and account for the SPL Token-2022 program. -pub fn keyed_account() -> (Pubkey, AccountSharedData) { +pub fn keyed_account() -> (Pubkey, Account) { (ID, account()) }