@@ -398,6 +398,23 @@ fn fvm_machine_execute_message(
398398 } )
399399}
400400
401+ #[ ffi_export]
402+ fn fvm_machine_dump_cache (
403+ executor : & ' _ InnerFvmMachine ,
404+ blockstore_id : u64 ,
405+ ) -> repr_c:: Box < Result < ( ) > > {
406+ catch_panic_response ( "fvm_machine_dump_cache" , || {
407+ let blockstore = CgoBlockstore :: new ( blockstore_id) ;
408+ let mut executor = executor
409+ . machine
410+ . as_ref ( )
411+ . context ( "missing executor" ) ?
412+ . lock ( )
413+ . map_err ( |e| anyhow ! ( "executor lock poisoned: {e}" ) ) ?;
414+ executor. dump_cache ( blockstore)
415+ } )
416+ }
417+
401418#[ ffi_export]
402419fn fvm_machine_flush ( executor : & ' _ InnerFvmMachine ) -> repr_c:: Box < Result < c_slice:: Box < u8 > > > {
403420 catch_panic_response ( "fvm_machine_flush" , || {
@@ -422,6 +439,7 @@ destructor!(
422439) ;
423440
424441destructor ! ( destroy_fvm_machine_flush_response, Result <c_slice:: Box <u8 >>) ;
442+ destructor ! ( destroy_fvm_machine_dump_cache_response, Result <( ) >) ;
425443
426444#[ derive( Clone , Debug , PartialEq , Eq , Serialize_tuple , Deserialize_tuple ) ]
427445struct LotusGasCharge {
@@ -439,6 +457,7 @@ struct Trace {
439457 pub msg_invoked : Option < TraceActor > ,
440458 pub gas_charges : Vec < LotusGasCharge > ,
441459 pub subcalls : Vec < Trace > ,
460+ pub logs : Vec < String > ,
442461}
443462
444463#[ derive( Serialize_tuple , Deserialize_tuple , Debug , PartialEq , Eq , Clone ) ]
@@ -499,6 +518,7 @@ fn build_lotus_trace(
499518 } ,
500519 gas_charges : vec ! [ ] ,
501520 subcalls : vec ! [ ] ,
521+ logs : vec ! [ ] ,
502522 } ;
503523
504524 while let Some ( trace) = trace_iter. next ( ) {
@@ -568,6 +588,9 @@ fn build_lotus_trace(
568588 . unwrap_or ( u64:: MAX ) ,
569589 } ) ;
570590 }
591+ ExecutionEvent :: Log ( s) => {
592+ new_trace. logs . push ( s) ;
593+ }
571594 _ => ( ) , // ignore unknown events.
572595 } ;
573596 }
@@ -605,10 +628,12 @@ mod test {
605628 ExecutionEvent :: GasCharge ( initial_gas_charge. clone( ) ) ,
606629 call_event. clone( ) ,
607630 return_result. clone( ) ,
631+ ExecutionEvent :: Log ( "something happened" . to_string( ) ) ,
608632 call_event. clone( ) ,
609633 call_event,
610634 return_result. clone( ) ,
611635 return_result. clone( ) ,
636+ ExecutionEvent :: Log ( "something else happened" . to_string( ) ) ,
612637 return_result,
613638 ] ;
614639
@@ -648,5 +673,8 @@ mod test {
648673 assert_eq ! ( lotus_trace. subcalls[ 0 ] . subcalls. len( ) , 0 ) ;
649674 assert_eq ! ( lotus_trace. subcalls[ 1 ] . subcalls. len( ) , 1 ) ;
650675 assert_eq ! ( lotus_trace. subcalls[ 1 ] . subcalls[ 0 ] . subcalls. len( ) , 0 ) ;
676+ assert_eq ! ( lotus_trace. logs. len( ) , 2 ) ;
677+ assert_eq ! ( lotus_trace. logs[ 0 ] , "something happened" ) ;
678+ assert_eq ! ( lotus_trace. logs[ 1 ] , "something else happened" ) ;
651679 }
652680}
0 commit comments