441441
442442pub mod account_store;
443443mod compile_accounts;
444+ pub mod epoch_stake;
444445pub mod file;
445446#[ cfg( any( feature = "fuzz" , feature = "fuzz-fd" ) ) ]
446447pub mod fuzz;
@@ -453,8 +454,8 @@ pub use mollusk_svm_result as result;
453454use mollusk_svm_result:: Compare ;
454455use {
455456 crate :: {
456- account_store:: AccountStore , compile_accounts:: CompiledAccounts , program :: ProgramCache ,
457- sysvar:: Sysvars ,
457+ account_store:: AccountStore , compile_accounts:: CompiledAccounts , epoch_stake :: EpochStake ,
458+ program :: ProgramCache , sysvar:: Sysvars ,
458459 } ,
459460 agave_feature_set:: FeatureSet ,
460461 mollusk_svm_error:: error:: { MolluskError , MolluskPanic } ,
@@ -482,6 +483,7 @@ pub(crate) const DEFAULT_LOADER_KEY: Pubkey = solana_sdk_ids::bpf_loader_upgrade
482483pub struct Mollusk {
483484 pub config : Config ,
484485 pub compute_budget : ComputeBudget ,
486+ pub epoch_stake : EpochStake ,
485487 pub feature_set : FeatureSet ,
486488 pub logger : Option < Rc < RefCell < LogCollector > > > ,
487489 pub program_cache : ProgramCache ,
@@ -521,6 +523,7 @@ impl Default for Mollusk {
521523 Self {
522524 config : Config :: default ( ) ,
523525 compute_budget,
526+ epoch_stake : EpochStake :: default ( ) ,
524527 feature_set,
525528 logger : None ,
526529 program_cache,
@@ -539,9 +542,18 @@ impl CheckContext for Mollusk {
539542
540543struct MolluskInvokeContextCallback < ' a > {
541544 feature_set : & ' a FeatureSet ,
545+ epoch_stake : & ' a EpochStake ,
542546}
543547
544548impl InvokeContextCallback for MolluskInvokeContextCallback < ' _ > {
549+ fn get_epoch_stake ( & self ) -> u64 {
550+ self . epoch_stake . values ( ) . sum ( )
551+ }
552+
553+ fn get_epoch_stake_for_vote_account ( & self , vote_address : & Pubkey ) -> u64 {
554+ self . epoch_stake . get ( vote_address) . copied ( ) . unwrap_or ( 0 )
555+ }
556+
545557 fn is_precompile ( & self , program_id : & Pubkey ) -> bool {
546558 agave_precompiles:: is_precompile ( program_id, |feature_id| {
547559 self . feature_set . is_active ( feature_id)
@@ -647,6 +659,7 @@ impl Mollusk {
647659 let invoke_result = {
648660 let mut program_cache = self . program_cache . cache ( ) ;
649661 let callback = MolluskInvokeContextCallback {
662+ epoch_stake : & self . epoch_stake ,
650663 feature_set : & self . feature_set ,
651664 } ;
652665 let runtime_features = self . feature_set . runtime_features ( ) ;
0 commit comments