From fd03ab918efcae6988c41807d2226bbd5f5827da Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Tue, 2 Apr 2024 13:46:41 +0000 Subject: [PATCH] Plumb through tests --- core/src/banking_stage/consumer.rs | 2 + .../banking_stage/read_write_account_set.rs | 1 + .../unprocessed_packet_batches.rs | 7 +++ cost-model/src/cost_tracker.rs | 2 + cost-model/src/transaction_cost.rs | 3 ++ entry/benches/entry_sigverify.rs | 3 ++ entry/src/entry.rs | 2 + programs/sbf/tests/programs.rs | 19 +++++-- rpc/src/rpc.rs | 16 ++++-- rpc/src/transaction_status_service.rs | 7 ++- .../src/runtime_transaction.rs | 2 + sdk/benches/serialize_instructions.rs | 25 ++++----- sdk/program/src/message/sanitized.rs | 49 +++++++++++------ sdk/program/src/message/versions/v0/loaded.rs | 6 +++ sdk/program/src/sysvar/instructions.rs | 3 +- sdk/src/nonce_info.rs | 7 ++- sdk/src/transaction/sanitized.rs | 9 +++- svm/src/account_loader.rs | 53 ++++++++++--------- svm/src/message_processor.rs | 4 +- svm/src/transaction_account_state_info.rs | 13 +++-- svm/src/transaction_processor.rs | 20 ++++--- svm/tests/transaction_builder.rs | 7 ++- transaction-status/src/parse_accounts.rs | 2 + 23 files changed, 183 insertions(+), 79 deletions(-) diff --git a/core/src/banking_stage/consumer.rs b/core/src/banking_stage/consumer.rs index 80363989c6c809..e916674c7c5de2 100644 --- a/core/src/banking_stage/consumer.rs +++ b/core/src/banking_stage/consumer.rs @@ -868,6 +868,7 @@ mod tests { nonce_account::verify_nonce_account, poh_config::PohConfig, pubkey::Pubkey, + reserved_account_keys::ReservedAccountKeys, signature::Keypair, signer::Signer, system_instruction, system_program, system_transaction, @@ -2026,6 +2027,7 @@ mod tests { MessageHash::Compute, Some(false), bank.as_ref(), + &ReservedAccountKeys::empty_key_set(), ) .unwrap(); diff --git a/core/src/banking_stage/read_write_account_set.rs b/core/src/banking_stage/read_write_account_set.rs index dad1256f6e6f22..6d6b908249f168 100644 --- a/core/src/banking_stage/read_write_account_set.rs +++ b/core/src/banking_stage/read_write_account_set.rs @@ -138,6 +138,7 @@ mod tests { MessageHash::Compute, Some(false), bank, + bank.get_reserved_account_keys(), ) .unwrap() } diff --git a/core/src/banking_stage/unprocessed_packet_batches.rs b/core/src/banking_stage/unprocessed_packet_batches.rs index b87cfef291b991..ebb91773c49923 100644 --- a/core/src/banking_stage/unprocessed_packet_batches.rs +++ b/core/src/banking_stage/unprocessed_packet_batches.rs @@ -310,6 +310,7 @@ mod tests { solana_sdk::{ compute_budget::ComputeBudgetInstruction, message::Message, + reserved_account_keys::ReservedAccountKeys, signature::{Keypair, Signer}, system_instruction, system_transaction, transaction::{SimpleAddressLoader, Transaction}, @@ -490,6 +491,7 @@ mod tests { &Arc::new(FeatureSet::default()), votes_only, SimpleAddressLoader::Disabled, + &ReservedAccountKeys::empty_key_set(), ) }); assert_eq!(2, txs.count()); @@ -500,6 +502,7 @@ mod tests { &Arc::new(FeatureSet::default()), votes_only, SimpleAddressLoader::Disabled, + &ReservedAccountKeys::empty_key_set(), ) }); assert_eq!(0, txs.count()); @@ -519,6 +522,7 @@ mod tests { &Arc::new(FeatureSet::default()), votes_only, SimpleAddressLoader::Disabled, + &ReservedAccountKeys::empty_key_set(), ) }); assert_eq!(3, txs.count()); @@ -529,6 +533,7 @@ mod tests { &Arc::new(FeatureSet::default()), votes_only, SimpleAddressLoader::Disabled, + &ReservedAccountKeys::empty_key_set(), ) }); assert_eq!(2, txs.count()); @@ -548,6 +553,7 @@ mod tests { &Arc::new(FeatureSet::default()), votes_only, SimpleAddressLoader::Disabled, + &ReservedAccountKeys::empty_key_set(), ) }); assert_eq!(3, txs.count()); @@ -558,6 +564,7 @@ mod tests { &Arc::new(FeatureSet::default()), votes_only, SimpleAddressLoader::Disabled, + &ReservedAccountKeys::empty_key_set(), ) }); assert_eq!(3, txs.count()); diff --git a/cost-model/src/cost_tracker.rs b/cost-model/src/cost_tracker.rs index 64185edb6c77ca..a68e6c9d7dbde3 100644 --- a/cost-model/src/cost_tracker.rs +++ b/cost-model/src/cost_tracker.rs @@ -339,6 +339,7 @@ mod tests { crate::transaction_cost::*, solana_sdk::{ hash::Hash, + reserved_account_keys::ReservedAccountKeys, signature::{Keypair, Signer}, system_transaction, transaction::{ @@ -401,6 +402,7 @@ mod tests { MessageHash::Compute, Some(true), SimpleAddressLoader::Disabled, + &ReservedAccountKeys::empty_key_set(), ) .unwrap(); diff --git a/cost-model/src/transaction_cost.rs b/cost-model/src/transaction_cost.rs index c92639676958ae..ee280c873312f9 100644 --- a/cost-model/src/transaction_cost.rs +++ b/cost-model/src/transaction_cost.rs @@ -203,6 +203,7 @@ mod tests { feature_set::FeatureSet, hash::Hash, message::SimpleAddressLoader, + reserved_account_keys::ReservedAccountKeys, signer::keypair::Keypair, transaction::{MessageHash, SanitizedTransaction, VersionedTransaction}, }, @@ -231,6 +232,7 @@ mod tests { MessageHash::Compute, Some(true), SimpleAddressLoader::Disabled, + &ReservedAccountKeys::empty_key_set(), ) .unwrap(); @@ -240,6 +242,7 @@ mod tests { MessageHash::Compute, Some(false), SimpleAddressLoader::Disabled, + &ReservedAccountKeys::empty_key_set(), ) .unwrap(); diff --git a/entry/benches/entry_sigverify.rs b/entry/benches/entry_sigverify.rs index 09adeb6cfd831a..d9b97b2dbfd91e 100644 --- a/entry/benches/entry_sigverify.rs +++ b/entry/benches/entry_sigverify.rs @@ -5,6 +5,7 @@ use { solana_perf::test_tx::test_tx, solana_sdk::{ hash::Hash, + reserved_account_keys::ReservedAccountKeys, transaction::{ Result, SanitizedTransaction, SimpleAddressLoader, TransactionVerificationMode, VersionedTransaction, @@ -41,6 +42,7 @@ fn bench_gpusigverify(bencher: &mut Bencher) { message_hash, None, SimpleAddressLoader::Disabled, + &ReservedAccountKeys::empty_key_set(), ) }?; @@ -84,6 +86,7 @@ fn bench_cpusigverify(bencher: &mut Bencher) { message_hash, None, SimpleAddressLoader::Disabled, + &ReservedAccountKeys::empty_key_set(), ) }?; diff --git a/entry/src/entry.rs b/entry/src/entry.rs index 7497f96d65980f..da4fda5914a363 100644 --- a/entry/src/entry.rs +++ b/entry/src/entry.rs @@ -982,6 +982,7 @@ mod tests { solana_sdk::{ hash::{hash, Hash}, pubkey::Pubkey, + reserved_account_keys::ReservedAccountKeys, signature::{Keypair, Signer}, system_transaction, transaction::{ @@ -1084,6 +1085,7 @@ mod tests { message_hash, None, SimpleAddressLoader::Disabled, + &ReservedAccountKeys::empty_key_set(), ) }?; diff --git a/programs/sbf/tests/programs.rs b/programs/sbf/tests/programs.rs index fa67dd11340f3f..0f45329c581905 100644 --- a/programs/sbf/tests/programs.rs +++ b/programs/sbf/tests/programs.rs @@ -81,6 +81,7 @@ use { message::Message, pubkey::Pubkey, rent::Rent, + reserved_account_keys::ReservedAccountKeys, signature::{Keypair, Signer}, system_program, transaction::{SanitizedTransaction, Transaction, TransactionError}, @@ -201,7 +202,11 @@ fn execute_transactions( } .expect("lamports_per_signature must be available"); let fee = bank.get_fee_for_message_with_lamports_per_signature( - &SanitizedMessage::try_from_legacy_message(tx.message().clone()).unwrap(), + &SanitizedMessage::try_from_legacy_message( + tx.message().clone(), + &ReservedAccountKeys::empty_key_set(), + ) + .unwrap(), lamports_per_signature, ); @@ -3706,7 +3711,11 @@ fn test_program_fees() { Some(&mint_keypair.pubkey()), ); - let sanitized_message = SanitizedMessage::try_from_legacy_message(message.clone()).unwrap(); + let sanitized_message = SanitizedMessage::try_from_legacy_message( + message.clone(), + &ReservedAccountKeys::empty_key_set(), + ) + .unwrap(); let expected_normal_fee = fee_structure.calculate_fee( &sanitized_message, congestion_multiplier, @@ -3730,7 +3739,11 @@ fn test_program_fees() { ], Some(&mint_keypair.pubkey()), ); - let sanitized_message = SanitizedMessage::try_from_legacy_message(message.clone()).unwrap(); + let sanitized_message = SanitizedMessage::try_from_legacy_message( + message.clone(), + &ReservedAccountKeys::empty_key_set(), + ) + .unwrap(); let expected_prioritized_fee = fee_structure.calculate_fee( &sanitized_message, congestion_multiplier, diff --git a/rpc/src/rpc.rs b/rpc/src/rpc.rs index 81ffd50a56df2d..6c41fb59d88cd8 100644 --- a/rpc/src/rpc.rs +++ b/rpc/src/rpc.rs @@ -4785,6 +4785,7 @@ pub mod tests { Message, MessageHeader, VersionedMessage, }, nonce::{self, state::DurableNonce}, + reserved_account_keys::ReservedAccountKeys, rpc_port, signature::{Keypair, Signer}, slot_hashes::SlotHashes, @@ -9063,8 +9064,12 @@ pub mod tests { .to_string(), ); assert_eq!( - sanitize_transaction(unsanitary_versioned_tx, SimpleAddressLoader::Disabled) - .unwrap_err(), + sanitize_transaction( + unsanitary_versioned_tx, + SimpleAddressLoader::Disabled, + &ReservedAccountKeys::empty_key_set() + ) + .unwrap_err(), expect58 ); } @@ -9084,7 +9089,12 @@ pub mod tests { }; assert_eq!( - sanitize_transaction(versioned_tx, SimpleAddressLoader::Disabled).unwrap_err(), + sanitize_transaction( + versioned_tx, + SimpleAddressLoader::Disabled, + &ReservedAccountKeys::empty_key_set() + ) + .unwrap_err(), Error::invalid_params( "invalid transaction: Transaction version is unsupported".to_string(), ) diff --git a/rpc/src/transaction_status_service.rs b/rpc/src/transaction_status_service.rs index 8730fb2ed0f3d8..f76c72102e3057 100644 --- a/rpc/src/transaction_status_service.rs +++ b/rpc/src/transaction_status_service.rs @@ -225,6 +225,7 @@ pub(crate) mod tests { nonce_info::{NonceFull, NoncePartial}, pubkey::Pubkey, rent_debits::RentDebits, + reserved_account_keys::ReservedAccountKeys, signature::{Keypair, Signature, Signer}, system_transaction, transaction::{ @@ -335,6 +336,7 @@ pub(crate) mod tests { MessageHash::Compute, None, SimpleAddressLoader::Disabled, + &ReservedAccountKeys::empty_key_set(), ) .unwrap(); @@ -364,7 +366,10 @@ pub(crate) mod tests { durable_nonce_fee: Some(DurableNonceFee::from( &NonceFull::from_partial( &rollback_partial, - &SanitizedMessage::Legacy(LegacyMessage::new(message)), + &SanitizedMessage::Legacy(LegacyMessage::new( + message, + &ReservedAccountKeys::empty_key_set(), + )), &[(pubkey, nonce_account)], &rent_debits, ) diff --git a/runtime-transaction/src/runtime_transaction.rs b/runtime-transaction/src/runtime_transaction.rs index bd4d4554f6e9b3..d7fa7da0fbb3f9 100644 --- a/runtime-transaction/src/runtime_transaction.rs +++ b/runtime-transaction/src/runtime_transaction.rs @@ -136,6 +136,7 @@ mod tests { compute_budget::ComputeBudgetInstruction, instruction::Instruction, message::Message, + reserved_account_keys::ReservedAccountKeys, signer::{keypair::Keypair, Signer}, transaction::{SimpleAddressLoader, Transaction, VersionedTransaction}, }, @@ -260,6 +261,7 @@ mod tests { let dynamically_loaded_transaction = RuntimeTransaction::::try_from( statically_loaded_transaction, SimpleAddressLoader::Disabled, + &ReservedAccountKeys::empty_key_set(), ); let dynamically_loaded_transaction = dynamically_loaded_transaction.expect("created from statically loaded tx"); diff --git a/sdk/benches/serialize_instructions.rs b/sdk/benches/serialize_instructions.rs index adf36497ec67d4..d5ab20cad92fe1 100644 --- a/sdk/benches/serialize_instructions.rs +++ b/sdk/benches/serialize_instructions.rs @@ -7,6 +7,7 @@ use { instruction::{AccountMeta, Instruction}, message::{Message, SanitizedMessage}, pubkey::{self, Pubkey}, + reserved_account_keys::ReservedAccountKeys, sysvar::instructions::{self, construct_instructions_data}, }, test::Bencher, @@ -29,10 +30,10 @@ fn bench_bincode_instruction_serialize(b: &mut Bencher) { #[bench] fn bench_construct_instructions_data(b: &mut Bencher) { let instructions = make_instructions(); - let message = SanitizedMessage::try_from_legacy_message(Message::new( - &instructions, - Some(&Pubkey::new_unique()), - )) + let message = SanitizedMessage::try_from_legacy_message( + Message::new(&instructions, Some(&Pubkey::new_unique())), + &ReservedAccountKeys::empty_key_set(), + ) .unwrap(); b.iter(|| { let instructions = message.decompile_instructions(); @@ -52,10 +53,10 @@ fn bench_bincode_instruction_deserialize(b: &mut Bencher) { #[bench] fn bench_manual_instruction_deserialize(b: &mut Bencher) { let instructions = make_instructions(); - let message = SanitizedMessage::try_from_legacy_message(Message::new( - &instructions, - Some(&Pubkey::new_unique()), - )) + let message = SanitizedMessage::try_from_legacy_message( + Message::new(&instructions, Some(&Pubkey::new_unique())), + &ReservedAccountKeys::empty_key_set(), + ) .unwrap(); let serialized = construct_instructions_data(&message.decompile_instructions()); b.iter(|| { @@ -69,10 +70,10 @@ fn bench_manual_instruction_deserialize(b: &mut Bencher) { #[bench] fn bench_manual_instruction_deserialize_single(b: &mut Bencher) { let instructions = make_instructions(); - let message = SanitizedMessage::try_from_legacy_message(Message::new( - &instructions, - Some(&Pubkey::new_unique()), - )) + let message = SanitizedMessage::try_from_legacy_message( + Message::new(&instructions, Some(&Pubkey::new_unique())), + &ReservedAccountKeys::empty_key_set(), + ) .unwrap(); let serialized = construct_instructions_data(&message.decompile_instructions()); b.iter(|| { diff --git a/sdk/program/src/message/sanitized.rs b/sdk/program/src/message/sanitized.rs index 9217d02ecb22b5..3f7b49662546f5 100644 --- a/sdk/program/src/message/sanitized.rs +++ b/sdk/program/src/message/sanitized.rs @@ -446,7 +446,11 @@ mod tests { }; assert_eq!( - SanitizedMessage::try_from_legacy_message(legacy_message_with_no_signers).err(), + SanitizedMessage::try_from_legacy_message( + legacy_message_with_no_signers, + &HashSet::default(), + ) + .err(), Some(SanitizeMessageError::IndexOutOfBounds), ); } @@ -470,6 +474,7 @@ mod tests { Hash::default(), instructions, ), + &HashSet::default(), ) .unwrap(); @@ -487,15 +492,18 @@ mod tests { let key4 = Pubkey::new_unique(); let key5 = Pubkey::new_unique(); - let legacy_message = SanitizedMessage::try_from_legacy_message(legacy::Message { - header: MessageHeader { - num_required_signatures: 2, - num_readonly_signed_accounts: 1, - num_readonly_unsigned_accounts: 1, + let legacy_message = SanitizedMessage::try_from_legacy_message( + legacy::Message { + header: MessageHeader { + num_required_signatures: 2, + num_readonly_signed_accounts: 1, + num_readonly_unsigned_accounts: 1, + }, + account_keys: vec![key0, key1, key2, key3], + ..legacy::Message::default() }, - account_keys: vec![key0, key1, key2, key3], - ..legacy::Message::default() - }) + &HashSet::default(), + ) .unwrap(); assert_eq!(legacy_message.num_readonly_accounts(), 2); @@ -514,6 +522,7 @@ mod tests { writable: vec![key4], readonly: vec![key5], }, + &HashSet::default(), )); assert_eq!(v0_message.num_readonly_accounts(), 3); @@ -540,6 +549,7 @@ mod tests { Hash::default(), instructions, ), + &HashSet::default(), ) .unwrap(); @@ -571,15 +581,18 @@ mod tests { let key4 = Pubkey::new_unique(); let key5 = Pubkey::new_unique(); - let legacy_message = SanitizedMessage::try_from_legacy_message(legacy::Message { - header: MessageHeader { - num_required_signatures: 2, - num_readonly_signed_accounts: 1, - num_readonly_unsigned_accounts: 1, + let legacy_message = SanitizedMessage::try_from_legacy_message( + legacy::Message { + header: MessageHeader { + num_required_signatures: 2, + num_readonly_signed_accounts: 1, + num_readonly_unsigned_accounts: 1, + }, + account_keys: vec![key0, key1, key2, key3], + ..legacy::Message::default() }, - account_keys: vec![key0, key1, key2, key3], - ..legacy::Message::default() - }) + &HashSet::default(), + ) .unwrap(); match legacy_message { SanitizedMessage::Legacy(message) => { @@ -611,6 +624,7 @@ mod tests { writable: vec![key4], readonly: vec![key5], }, + &HashSet::default(), )); match v0_message { SanitizedMessage::V0(message) => { @@ -661,6 +675,7 @@ mod tests { mock_secp256k1_instr, ], ), + &HashSet::new(), ) .unwrap(); diff --git a/sdk/program/src/message/versions/v0/loaded.rs b/sdk/program/src/message/versions/v0/loaded.rs index dc9175c17978e1..1825c5e748e3f4 100644 --- a/sdk/program/src/message/versions/v0/loaded.rs +++ b/sdk/program/src/message/versions/v0/loaded.rs @@ -213,6 +213,7 @@ mod tests { writable: vec![key4], readonly: vec![key5], }, + &HashSet::default(), ); (message, [key0, key1, key2, key3, key4, key5]) @@ -237,6 +238,7 @@ mod tests { writable: keys.split_off(2), readonly: keys, }, + &HashSet::default(), ) }; @@ -269,6 +271,8 @@ mod tests { #[test] fn test_is_writable() { solana_logger::setup(); + + let reserved_account_keys = HashSet::from_iter([sysvar::clock::id(), system_program::id()]); let create_message_with_keys = |keys: Vec| { LoadedMessage::new( v0::Message { @@ -284,6 +288,7 @@ mod tests { writable: keys[2..=2].to_vec(), readonly: keys[3..].to_vec(), }, + &reserved_account_keys, ) }; @@ -333,6 +338,7 @@ mod tests { writable: vec![key1, key2], readonly: vec![], }, + &HashSet::default(), ); assert!(message.is_writable_index(2)); diff --git a/sdk/program/src/sysvar/instructions.rs b/sdk/program/src/sysvar/instructions.rs index 28d5674177b838..249b11b5f9452f 100644 --- a/sdk/program/src/sysvar/instructions.rs +++ b/sdk/program/src/sysvar/instructions.rs @@ -302,10 +302,11 @@ mod tests { message::{Message as LegacyMessage, SanitizedMessage}, pubkey::Pubkey, }, + std::collections::HashSet, }; fn new_sanitized_message(message: LegacyMessage) -> SanitizedMessage { - SanitizedMessage::try_from_legacy_message(message).unwrap() + SanitizedMessage::try_from_legacy_message(message, &HashSet::default()).unwrap() } #[test] diff --git a/sdk/src/nonce_info.rs b/sdk/src/nonce_info.rs index c29d3db6bdb944..2672174209f70e 100644 --- a/sdk/src/nonce_info.rs +++ b/sdk/src/nonce_info.rs @@ -124,6 +124,7 @@ mod tests { instruction::Instruction, message::Message, nonce::{self, state::DurableNonce}, + reserved_account_keys::ReservedAccountKeys, signature::{keypair_from_seed, Signer}, system_instruction, system_program, }, @@ -133,7 +134,11 @@ mod tests { instructions: &[Instruction], payer: Option<&Pubkey>, ) -> SanitizedMessage { - SanitizedMessage::try_from_legacy_message(Message::new(instructions, payer)).unwrap() + SanitizedMessage::try_from_legacy_message( + Message::new(instructions, payer), + &ReservedAccountKeys::empty_key_set(), + ) + .unwrap() } #[test] diff --git a/sdk/src/transaction/sanitized.rs b/sdk/src/transaction/sanitized.rs index bbaae62bfde9b9..fe951c7ff57147 100644 --- a/sdk/src/transaction/sanitized.rs +++ b/sdk/src/transaction/sanitized.rs @@ -308,7 +308,10 @@ impl SanitizedTransaction { mod tests { use { super::*, - crate::signer::{keypair::Keypair, Signer}, + crate::{ + reserved_account_keys::ReservedAccountKeys, + signer::{keypair::Keypair, Signer}, + }, solana_program::vote::{self, state::Vote}, }; @@ -333,6 +336,7 @@ mod tests { MessageHash::Compute, None, SimpleAddressLoader::Disabled, + &ReservedAccountKeys::empty_key_set(), ) .unwrap(); assert!(vote_transaction.is_simple_vote_transaction()); @@ -345,6 +349,7 @@ mod tests { MessageHash::Compute, Some(false), SimpleAddressLoader::Disabled, + &ReservedAccountKeys::empty_key_set(), ) .unwrap(); assert!(!vote_transaction.is_simple_vote_transaction()); @@ -359,6 +364,7 @@ mod tests { MessageHash::Compute, None, SimpleAddressLoader::Disabled, + &ReservedAccountKeys::empty_key_set(), ) .unwrap(); assert!(!vote_transaction.is_simple_vote_transaction()); @@ -371,6 +377,7 @@ mod tests { MessageHash::Compute, Some(true), SimpleAddressLoader::Disabled, + &ReservedAccountKeys::empty_key_set(), ) .unwrap(); assert!(vote_transaction.is_simple_vote_transaction()); diff --git a/svm/src/account_loader.rs b/svm/src/account_loader.rs index 8911f28822fbae..f35252e896a5f6 100644 --- a/svm/src/account_loader.rs +++ b/svm/src/account_loader.rs @@ -491,6 +491,7 @@ mod tests { rent::Rent, rent_collector::{RentCollector, RENT_EXEMPT_RENT_EPOCH}, rent_debits::RentDebits, + reserved_account_keys::ReservedAccountKeys, signature::{Keypair, Signature, Signer}, system_program, system_transaction, sysvar, transaction::{Result, SanitizedTransaction, Transaction, TransactionError}, @@ -570,6 +571,18 @@ mod tests { features } + fn new_sanitized_message(message: Message) -> SanitizedMessage { + SanitizedMessage::try_from_legacy_message(message, &ReservedAccountKeys::empty_key_set()) + .unwrap() + } + + fn new_unchecked_sanitized_message(message: Message) -> SanitizedMessage { + SanitizedMessage::Legacy(LegacyMessage::new( + message, + &ReservedAccountKeys::empty_key_set(), + )) + } + fn load_accounts_with_fee( tx: Transaction, ka: &[TransactionAccount], @@ -689,7 +702,7 @@ mod tests { instructions, ); - let message = SanitizedMessage::try_from_legacy_message(tx.message().clone()).unwrap(); + let message = new_sanitized_message(tx.message().clone()); let fee = FeeStructure::default().calculate_fee( &message, lamports_per_signature, @@ -1217,7 +1230,7 @@ mod tests { Hash::default(), ); - let message = SanitizedMessage::try_from_legacy_message(tx.message().clone()).unwrap(); + let message = new_sanitized_message(tx.message().clone()); let fee = FeeStructure::default().calculate_fee( &message, lamports_per_signature, @@ -1441,8 +1454,7 @@ mod tests { recent_blockhash: Hash::default(), }; - let legacy = LegacyMessage::new(message); - let sanitized_message = SanitizedMessage::Legacy(legacy); + let sanitized_message = new_unchecked_sanitized_message(message); let mock_bank = TestCallbacks::default(); let mut error_counter = TransactionErrorMetrics::default(); let loaded_programs = LoadedProgramsForTxBatch::default(); @@ -1479,8 +1491,7 @@ mod tests { recent_blockhash: Hash::default(), }; - let legacy = LegacyMessage::new(message); - let sanitized_message = SanitizedMessage::Legacy(legacy); + let sanitized_message = new_unchecked_sanitized_message(message); let mut mock_bank = TestCallbacks::default(); mock_bank .accounts_map @@ -1548,8 +1559,7 @@ mod tests { recent_blockhash: Hash::default(), }; - let legacy = LegacyMessage::new(message); - let sanitized_message = SanitizedMessage::Legacy(legacy); + let sanitized_message = new_unchecked_sanitized_message(message); let mut mock_bank = TestCallbacks::default(); let mut account_data = AccountSharedData::default(); account_data.set_lamports(200); @@ -1593,8 +1603,7 @@ mod tests { recent_blockhash: Hash::default(), }; - let legacy = LegacyMessage::new(message); - let sanitized_message = SanitizedMessage::Legacy(legacy); + let sanitized_message = new_unchecked_sanitized_message(message); let mut mock_bank = TestCallbacks::default(); let mut account_data = AccountSharedData::default(); account_data.set_lamports(200); @@ -1637,8 +1646,7 @@ mod tests { recent_blockhash: Hash::default(), }; - let legacy = LegacyMessage::new(message); - let sanitized_message = SanitizedMessage::Legacy(legacy); + let sanitized_message = new_unchecked_sanitized_message(message); let mut mock_bank = TestCallbacks::default(); let mut account_data = AccountSharedData::default(); account_data.set_lamports(200); @@ -1684,8 +1692,7 @@ mod tests { recent_blockhash: Hash::default(), }; - let legacy = LegacyMessage::new(message); - let sanitized_message = SanitizedMessage::Legacy(legacy); + let sanitized_message = new_unchecked_sanitized_message(message); let mut mock_bank = TestCallbacks::default(); let mut account_data = AccountSharedData::default(); account_data.set_owner(native_loader::id()); @@ -1754,8 +1761,7 @@ mod tests { recent_blockhash: Hash::default(), }; - let legacy = LegacyMessage::new(message); - let sanitized_message = SanitizedMessage::Legacy(legacy); + let sanitized_message = new_unchecked_sanitized_message(message); let mut mock_bank = TestCallbacks::default(); let mut account_data = AccountSharedData::default(); account_data.set_executable(true); @@ -1807,8 +1813,7 @@ mod tests { recent_blockhash: Hash::default(), }; - let legacy = LegacyMessage::new(message); - let sanitized_message = SanitizedMessage::Legacy(legacy); + let sanitized_message = new_unchecked_sanitized_message(message); let mut mock_bank = TestCallbacks::default(); let mut account_data = AccountSharedData::default(); account_data.set_executable(true); @@ -1868,8 +1873,7 @@ mod tests { recent_blockhash: Hash::default(), }; - let legacy = LegacyMessage::new(message); - let sanitized_message = SanitizedMessage::Legacy(legacy); + let sanitized_message = new_unchecked_sanitized_message(message); let mut mock_bank = TestCallbacks::default(); let mut account_data = AccountSharedData::default(); account_data.set_executable(true); @@ -1957,8 +1961,7 @@ mod tests { recent_blockhash: Hash::default(), }; - let legacy = LegacyMessage::new(message); - let sanitized_message = SanitizedMessage::Legacy(legacy); + let sanitized_message = new_unchecked_sanitized_message(message); let mut mock_bank = TestCallbacks::default(); let mut account_data = AccountSharedData::default(); account_data.set_executable(true); @@ -2110,8 +2113,7 @@ mod tests { recent_blockhash: Hash::default(), }; - let legacy = LegacyMessage::new(message); - let sanitized_message = SanitizedMessage::Legacy(legacy); + let sanitized_message = new_unchecked_sanitized_message(message); let mut mock_bank = TestCallbacks::default(); let mut account_data = AccountSharedData::default(); account_data.set_executable(true); @@ -2202,8 +2204,7 @@ mod tests { recent_blockhash: Hash::default(), }; - let legacy = LegacyMessage::new(message); - let sanitized_message = SanitizedMessage::Legacy(legacy); + let sanitized_message = new_unchecked_sanitized_message(message); let sanitized_transaction = SanitizedTransaction::new_for_tests( sanitized_message, vec![Signature::new_unique()], diff --git a/svm/src/message_processor.rs b/svm/src/message_processor.rs index 6e788b9c0f86e0..f6595b4450bce7 100644 --- a/svm/src/message_processor.rs +++ b/svm/src/message_processor.rs @@ -160,6 +160,7 @@ mod tests { native_loader::{self, create_loadable_account_for_test}, pubkey::Pubkey, rent::Rent, + reserved_account_keys::ReservedAccountKeys, secp256k1_instruction::new_secp256k1_instruction, secp256k1_program, system_program, transaction_context::TransactionContext, @@ -177,7 +178,8 @@ mod tests { } fn new_sanitized_message(message: Message) -> SanitizedMessage { - SanitizedMessage::try_from_legacy_message(message).unwrap() + SanitizedMessage::try_from_legacy_message(message, &ReservedAccountKeys::empty_key_set()) + .unwrap() } #[test] diff --git a/svm/src/transaction_account_state_info.rs b/svm/src/transaction_account_state_info.rs index 0631050fe0e765..74d898b81adc10 100644 --- a/svm/src/transaction_account_state_info.rs +++ b/svm/src/transaction_account_state_info.rs @@ -82,6 +82,7 @@ mod test { instruction::CompiledInstruction, message::{LegacyMessage, Message, MessageHeader, SanitizedMessage}, rent::Rent, + reserved_account_keys::ReservedAccountKeys, signature::{Keypair, Signer}, transaction::TransactionError, transaction_context::TransactionContext, @@ -114,8 +115,10 @@ mod test { recent_blockhash: Hash::default(), }; - let legacy = LegacyMessage::new(message); - let sanitized_message = SanitizedMessage::Legacy(legacy); + let sanitized_message = SanitizedMessage::Legacy(LegacyMessage::new( + message, + &ReservedAccountKeys::empty_key_set(), + )); let transaction_accounts = vec![ (key1.pubkey(), AccountSharedData::default()), @@ -166,8 +169,10 @@ mod test { recent_blockhash: Hash::default(), }; - let legacy = LegacyMessage::new(message); - let sanitized_message = SanitizedMessage::Legacy(legacy); + let sanitized_message = SanitizedMessage::Legacy(LegacyMessage::new( + message, + &ReservedAccountKeys::empty_key_set(), + )); let transaction_accounts = vec![ (key1.pubkey(), AccountSharedData::default()), diff --git a/svm/src/transaction_processor.rs b/svm/src/transaction_processor.rs index d809336e5bddd1..80a4f0710a60ee 100644 --- a/svm/src/transaction_processor.rs +++ b/svm/src/transaction_processor.rs @@ -996,6 +996,7 @@ mod tests { fee_calculator::FeeCalculator, message::{LegacyMessage, Message, MessageHeader}, rent_debits::RentDebits, + reserved_account_keys::ReservedAccountKeys, signature::{Keypair, Signature}, sysvar::{self, rent::Rent}, transaction::{SanitizedTransaction, Transaction, TransactionError}, @@ -1008,6 +1009,13 @@ mod tests { }, }; + fn new_unchecked_sanitized_message(message: Message) -> SanitizedMessage { + SanitizedMessage::Legacy(LegacyMessage::new( + message, + &ReservedAccountKeys::empty_key_set(), + )) + } + struct TestForkGraph {} impl ForkGraph for TestForkGraph { @@ -1712,8 +1720,7 @@ mod tests { recent_blockhash: Hash::default(), }; - let legacy = LegacyMessage::new(message); - let sanitized_message = SanitizedMessage::Legacy(legacy); + let sanitized_message = new_unchecked_sanitized_message(message); let loaded_programs = LoadedProgramsForTxBatch::default(); let mock_bank = MockBankCallback::default(); let batch_processor = TransactionBatchProcessor::::default(); @@ -1837,8 +1844,7 @@ mod tests { recent_blockhash: Hash::default(), }; - let legacy = LegacyMessage::new(message); - let sanitized_message = SanitizedMessage::Legacy(legacy); + let sanitized_message = new_unchecked_sanitized_message(message); let loaded_programs = LoadedProgramsForTxBatch::default(); let mock_bank = MockBankCallback::default(); let batch_processor = TransactionBatchProcessor::::default(); @@ -1955,8 +1961,7 @@ mod tests { recent_blockhash: Hash::default(), }; - let legacy = LegacyMessage::new(message); - let sanitized_message = SanitizedMessage::Legacy(legacy); + let sanitized_message = new_unchecked_sanitized_message(message); let sanitized_transaction_1 = SanitizedTransaction::new_for_tests( sanitized_message, @@ -1986,8 +1991,7 @@ mod tests { recent_blockhash: Hash::default(), }; - let legacy = LegacyMessage::new(message); - let sanitized_message = SanitizedMessage::Legacy(legacy); + let sanitized_message = new_unchecked_sanitized_message(message); let sanitized_transaction_2 = SanitizedTransaction::new_for_tests( sanitized_message, diff --git a/svm/tests/transaction_builder.rs b/svm/tests/transaction_builder.rs index ca8ef79a9b73c9..7d880aa168e5f1 100644 --- a/svm/tests/transaction_builder.rs +++ b/svm/tests/transaction_builder.rs @@ -4,6 +4,7 @@ use { instruction::{AccountMeta, CompiledInstruction}, message::{Message, MessageHeader}, pubkey::Pubkey, + reserved_account_keys::ReservedAccountKeys, signature::Signature, transaction::{SanitizedTransaction, Transaction}, }, @@ -126,7 +127,11 @@ impl SanitizedTransactionBuilder { message, }; - SanitizedTransaction::try_from_legacy_transaction(transaction).unwrap() + SanitizedTransaction::try_from_legacy_transaction( + transaction, + &ReservedAccountKeys::new_all_activated().active, + ) + .unwrap() } } diff --git a/transaction-status/src/parse_accounts.rs b/transaction-status/src/parse_accounts.rs index 5388c15ecf858b..097cb50d716cc9 100644 --- a/transaction-status/src/parse_accounts.rs +++ b/transaction-status/src/parse_accounts.rs @@ -54,6 +54,7 @@ mod test { solana_sdk::{ message::{v0, v0::LoadedAddresses, MessageHeader}, pubkey::Pubkey, + reserved_account_keys::ReservedAccountKeys, }, }; @@ -126,6 +127,7 @@ mod test { writable: vec![pubkey4], readonly: vec![pubkey5], }, + &ReservedAccountKeys::empty_key_set(), ); assert_eq!(