@@ -521,13 +521,14 @@ where
521521 #[ instrument( skip( self , rand) ) ]
522522 fn call_raw (
523523 self : & Arc < Self > ,
524+ state_cid : Option < Cid > ,
524525 msg : & Message ,
525526 rand : ChainRand < DB > ,
526527 tipset : & Arc < Tipset > ,
527528 ) -> Result < ApiInvocResult , Error > {
528529 let mut msg = msg. clone ( ) ;
529530
530- let state_cid = tipset. parent_state ( ) ;
531+ let state_cid = state_cid . unwrap_or ( * tipset. parent_state ( ) ) ;
531532
532533 let tipset_messages = self
533534 . chain_store ( )
@@ -545,14 +546,14 @@ where
545546 let mut vm = VM :: new (
546547 ExecutionContext {
547548 heaviest_tipset : Arc :: clone ( tipset) ,
548- state_tree_root : * state_cid,
549+ state_tree_root : state_cid,
549550 epoch : height,
550551 rand : Box :: new ( rand) ,
551552 base_fee : tipset. block_headers ( ) . first ( ) . parent_base_fee . clone ( ) ,
552553 circ_supply : genesis_info. get_vm_circulating_supply (
553554 height,
554555 & self . blockstore_owned ( ) ,
555- state_cid,
556+ & state_cid,
556557 ) ?,
557558 chain_config : self . chain_config ( ) . clone ( ) ,
558559 chain_index : self . chain_index ( ) . clone ( ) ,
@@ -603,7 +604,20 @@ where
603604 ) -> Result < ApiInvocResult , Error > {
604605 let ts = tipset. unwrap_or_else ( || self . cs . heaviest_tipset ( ) ) ;
605606 let chain_rand = self . chain_rand ( Arc :: clone ( & ts) ) ;
606- self . call_raw ( message, chain_rand, & ts)
607+ self . call_raw ( None , message, chain_rand, & ts)
608+ }
609+
610+ /// Same as [StateManager::call] but runs the message on the given state and not
611+ /// on the parent state of the tipset.
612+ pub fn call_on_state (
613+ self : & Arc < Self > ,
614+ state_cid : Cid ,
615+ message : & Message ,
616+ tipset : Option < Arc < Tipset > > ,
617+ ) -> Result < ApiInvocResult , Error > {
618+ let ts = tipset. unwrap_or_else ( || self . cs . heaviest_tipset ( ) ) ;
619+ let chain_rand = self . chain_rand ( Arc :: clone ( & ts) ) ;
620+ self . call_raw ( Some ( state_cid) , message, chain_rand, & ts)
607621 }
608622
609623 pub async fn apply_on_state_with_gas (
0 commit comments