@@ -30,7 +30,7 @@ use sui_types::{
3030use crate :: {
3131 db:: { ObjectStoreCachedStore , ObjectStoreInfo } ,
3232 exec:: SuiExecutor ,
33- tracer:: NopTracer ,
33+ tracer:: { NopTracer , tree :: TreeTracer } ,
3434} ;
3535
3636pub struct SuiTestingEnv < T > {
@@ -135,6 +135,7 @@ impl<
135135 epoch : u64 ,
136136 epoch_ms : u64 ,
137137 gas : ObjectID ,
138+ trace_movy_init : bool ,
138139 ) -> Result < ( MoveAddress , MovePackageAbi , MovePackageAbi , Vec < String > ) , MovyError > {
139140 tracing:: info!( "Compiling {} with non-test mode..." , path. display( ) ) ;
140141 let abi_result = SuiCompiledPackage :: build_all_unpublished_from_folder ( path, false ) ?;
@@ -174,17 +175,34 @@ impl<
174175 ) ;
175176 let ptb = builder. finish ( ) ;
176177 tracing:: info!( "Detected a {} at: {}" , MOVY_INIT , md. module_id) ;
177- let results = executor. run_ptb_with_gas :: < NopTracer > (
178+ let tracer = if trace_movy_init {
179+ Some ( TreeTracer :: new ( ) )
180+ } else {
181+ None
182+ } ;
183+ let mut results = executor. run_ptb_with_gas (
178184 ptb,
179185 epoch,
180186 epoch_ms,
181187 deployer. into ( ) ,
182188 gas,
183- None ,
189+ tracer ,
184190 ) ?;
191+ let trace = if let Some ( tracer) = std:: mem:: take ( & mut results. tracer ) {
192+ Some ( tracer. take_inner ( ) . pprint ( ) )
193+ } else {
194+ None
195+ } ;
185196 if !results. effects . status ( ) . is_ok ( ) {
197+ if let Some ( trace) = trace {
198+ tracing:: error!( "movy_init reverts with:\n {}" , trace) ;
199+ }
186200 return Err ( eyre ! ( "movy_init reverts!" ) . into ( ) ) ;
187201 }
202+ tracing:: trace!(
203+ "movy_init trace:\n {}" ,
204+ trace. unwrap_or_else( || "-" . to_string( ) )
205+ ) ;
188206 tracing:: info!( "Commiting movy_init effects..." ) ;
189207 tracing:: debug!(
190208 "Status: {:?} Changed Objects: {}, Removed Objects: {}" ,
@@ -238,8 +256,8 @@ impl<
238256 let objects = rpc
239257 . filter_objects ( ckpt, Some ( OwnerKind :: Shared ) , None , Some ( tag) )
240258 . await ?;
241- for object in objects. iter ( ) {
242- self . db . load_object ( object. id ( ) . into ( ) ) . await ?;
259+ for object in objects. into_iter ( ) {
260+ self . db . commit_single_object ( object) ?;
243261 }
244262 }
245263 }
0 commit comments