@@ -455,16 +455,14 @@ pub use mollusk_svm_result as result;
455455use mollusk_svm_result:: Compare ;
456456#[ cfg( feature = "precompiles" ) ]
457457use solana_precompile_error:: PrecompileError ;
458- #[ cfg( feature = "invocation-inspect-callback" ) ]
459- use solana_transaction_context:: InstructionAccount ;
460458use {
461459 crate :: {
462460 account_store:: AccountStore ,
463461 compile_accounts:: CompiledAccounts ,
464462 epoch_stake:: EpochStake ,
465463 program:: ProgramCache ,
466464 sysvar:: Sysvars ,
467- vm:: { agave:: AgaveVM , SolanaVM } ,
465+ vm:: { agave:: AgaveVM , SolanaVM , SolanaVMContext , SolanaVMInstruction , SolanaVMTrace } ,
468466 } ,
469467 agave_feature_set:: FeatureSet ,
470468 mollusk_svm_error:: error:: { MolluskError , MolluskPanic } ,
@@ -473,14 +471,19 @@ use {
473471 solana_compute_budget:: compute_budget:: ComputeBudget ,
474472 solana_hash:: Hash ,
475473 solana_instruction:: { AccountMeta , Instruction } ,
476- solana_program_runtime:: invoke_context:: { EnvironmentConfig , InvokeContext } ,
474+ solana_program_runtime:: invoke_context:: EnvironmentConfig ,
477475 solana_pubkey:: Pubkey ,
478476 solana_svm_callback:: InvokeContextCallback ,
479477 solana_svm_log_collector:: LogCollector ,
480478 solana_svm_timings:: ExecuteTimings ,
481479 solana_transaction_context:: TransactionContext ,
482480 std:: { cell:: RefCell , collections:: HashSet , iter:: once, marker:: PhantomData , rc:: Rc } ,
483481} ;
482+ #[ cfg( feature = "invocation-inspect-callback" ) ]
483+ use {
484+ solana_program_runtime:: invoke_context:: InvokeContext ,
485+ solana_transaction_context:: InstructionAccount ,
486+ } ;
484487
485488pub ( crate ) const DEFAULT_LOADER_KEY : Pubkey = solana_sdk_ids:: bpf_loader_upgradeable:: id ( ) ;
486489
@@ -797,54 +800,39 @@ impl<VM: SolanaVM> Mollusk<VM> {
797800 } ;
798801 let runtime_features = self . feature_set . runtime_features ( ) ;
799802 let sysvar_cache = self . sysvars . setup_sysvar_cache ( accounts) ;
800- let mut invoke_context = InvokeContext :: new (
801- & mut transaction_context,
802- & mut program_cache,
803- EnvironmentConfig :: new (
803+
804+ let context = SolanaVMContext {
805+ transaction_context : & mut transaction_context,
806+ program_cache : & mut program_cache,
807+ compute_budget : self . compute_budget ,
808+ environment_config : EnvironmentConfig :: new (
804809 Hash :: default ( ) ,
805810 /* blockhash_lamports_per_signature */ 5000 , // The default value
806811 & callback,
807812 & runtime_features,
808813 & sysvar_cache,
809814 ) ,
810- self . logger . clone ( ) ,
811- self . compute_budget . to_budget ( ) ,
812- self . compute_budget . to_cost ( ) ,
813- ) ;
814-
815- // Configure the next instruction frame for this invocation.
816- invoke_context
817- . transaction_context
818- . configure_next_instruction_for_tests (
819- program_id_index,
820- instruction_accounts. clone ( ) ,
821- & instruction. data ,
822- )
823- . expect ( "failed to configure next instruction" ) ;
824-
825- #[ cfg( feature = "invocation-inspect-callback" ) ]
826- self . invocation_inspect_callback . before_invocation (
827- & instruction. program_id ,
828- & instruction. data ,
829- & instruction_accounts,
830- & invoke_context,
831- ) ;
815+ } ;
832816
833- let result = if invoke_context. is_precompile ( & instruction. program_id ) {
834- invoke_context. process_precompile (
835- & instruction. program_id ,
836- & instruction. data ,
837- std:: iter:: once ( instruction. data . as_ref ( ) ) ,
838- )
839- } else {
840- invoke_context. process_instruction ( & mut compute_units_consumed, & mut timings)
817+ let instruction = SolanaVMInstruction {
818+ program_id_index,
819+ accounts : instruction_accounts,
820+ data : & instruction. data ,
841821 } ;
842822
843- #[ cfg( feature = "invocation-inspect-callback" ) ]
844- self . invocation_inspect_callback
845- . after_invocation ( & invoke_context) ;
823+ let trace = SolanaVMTrace {
824+ compute_units_consumed : & mut compute_units_consumed,
825+ execute_timings : & mut timings,
826+ log_collector : self . logger . clone ( ) ,
827+ } ;
846828
847- result
829+ VM :: process_instruction (
830+ context,
831+ instruction,
832+ trace,
833+ #[ cfg( feature = "invocation-inspect-callback" ) ]
834+ self . invocation_inspect_callback . as_ref ( ) ,
835+ )
848836 } ;
849837
850838 let return_data = transaction_context. get_return_data ( ) . 1 . to_vec ( ) ;
0 commit comments