@@ -3,42 +3,31 @@ use crate::forking::state::ForkStateReader;
33use  crate :: predeployment:: erc20:: eth:: eth_predeployed_contract; 
44use  crate :: predeployment:: erc20:: strk:: strk_predeployed_contract; 
55use  crate :: predeployment:: predeployed_contract:: PredeployedContract ; 
6- use  crate :: runtime_extensions:: call_to_blockifier_runtime_extension:: rpc:: CallResult ; 
7- use  crate :: runtime_extensions:: common:: sum_syscall_usage; 
86use  crate :: runtime_extensions:: forge_runtime_extension:: cheatcodes:: cheat_execution_info:: { 
97    ExecutionInfoMock ,  ResourceBounds , 
108} ; 
119use  crate :: runtime_extensions:: forge_runtime_extension:: cheatcodes:: spy_events:: Event ; 
1210use  crate :: runtime_extensions:: forge_runtime_extension:: cheatcodes:: spy_messages_to_l1:: MessageToL1 ; 
13- use  blockifier:: blockifier_versioned_constants:: VersionedConstants ; 
14- use  blockifier:: execution:: call_info:: { ExecutionSummary ,  OrderedEvent ,  OrderedL2ToL1Message } ; 
11+ use  crate :: trace_data:: { CallTrace ,  NotEmptyCallStack ,  TraceData } ; 
1512use  blockifier:: execution:: contract_class:: RunnableCompiledClass ; 
16- use  blockifier:: execution:: entry_point:: CallEntryPoint ; 
17- use  blockifier:: execution:: syscalls:: vm_syscall_utils:: SyscallUsageMap ; 
1813use  blockifier:: state:: errors:: StateError :: UndeclaredClassHash ; 
1914use  blockifier:: state:: state_api:: { StateReader ,  StateResult } ; 
20- use  cairo_annotations:: trace_data:: L1Resources ; 
2115use  cairo_vm:: Felt252 ; 
22- use  cairo_vm:: vm:: runners:: cairo_runner:: ExecutionResources ; 
23- use  cairo_vm:: vm:: trace:: trace_entry:: RelocatedTraceEntry ; 
2416use  conversions:: serde:: deserialize:: CairoDeserialize ; 
25- use  conversions:: serde:: serialize:: { BufferWriter ,  CairoSerialize } ; 
2617use  conversions:: string:: TryFromHexStr ; 
2718use  indexmap:: IndexMap ; 
2819use  runtime:: starknet:: constants:: TEST_CONTRACT_CLASS_HASH ; 
2920use  runtime:: starknet:: context:: SerializableBlockInfo ; 
3021use  runtime:: starknet:: state:: DictStateReader ; 
3122use  starknet_api:: block:: BlockInfo ; 
3223use  starknet_api:: core:: { ChainId ,  EntryPointSelector } ; 
33- use  starknet_api:: execution_resources:: GasVector ; 
3424use  starknet_api:: transaction:: fields:: ContractAddressSalt ; 
35- use  starknet_api:: transaction:: fields:: GasVectorComputationMode ; 
3625use  starknet_api:: { 
3726    core:: { ClassHash ,  CompiledClassHash ,  ContractAddress ,  Nonce } , 
3827    state:: StorageKey , 
3928} ; 
4029use  starknet_types_core:: felt:: Felt ; 
41- use  std:: cell:: { OnceCell ,   Ref ,   RefCell } ; 
30+ use  std:: cell:: RefCell ; 
4231use  std:: collections:: HashMap ; 
4332use  std:: num:: NonZeroUsize ; 
4433use  std:: rc:: Rc ; 
@@ -206,165 +195,6 @@ impl<T> CheatStatus<T> {
206195    } 
207196} 
208197
209- #[ derive( Clone ,  Debug ) ]  
210- pub  struct  GasReportData  { 
211-     execution_summary :  ExecutionSummary , 
212-     gas :  OnceCell < GasVector > , 
213- } 
214- 
215- impl  GasReportData  { 
216-     #[ must_use]  
217-     pub  fn  new ( execution_summary :  ExecutionSummary )  -> Self  { 
218-         Self  { 
219-             execution_summary, 
220-             gas :  OnceCell :: new ( ) , 
221-         } 
222-     } 
223- 
224-     pub  fn  get_gas ( & self )  -> & GasVector  { 
225-         self . gas . get_or_init ( || { 
226-             self . execution_summary . clone ( ) . to_partial_gas_vector ( 
227-                 VersionedConstants :: latest_constants ( ) , 
228-                 & GasVectorComputationMode :: All , 
229-             ) 
230-         } ) 
231-     } 
232- } 
233- 
234- /// Tree structure representing trace of a call. 
235- #[ derive( Debug ) ]  
236- pub  struct  CallTrace  { 
237-     // only these are serialized 
238-     pub  entry_point :  CallEntryPoint , 
239-     pub  nested_calls :  Vec < CallTraceNode > , 
240-     pub  result :  CallResult , 
241-     // serialize end 
242- 
243-     // These also include resources used by internal calls 
244-     pub  used_execution_resources :  ExecutionResources , 
245-     pub  used_l1_resources :  L1Resources , 
246-     pub  used_syscalls_vm_resources :  SyscallUsageMap , 
247-     pub  used_syscalls_sierra_gas :  SyscallUsageMap , 
248-     pub  vm_trace :  Option < Vec < RelocatedTraceEntry > > , 
249-     pub  gas_consumed :  u64 , 
250-     pub  events :  Vec < OrderedEvent > , 
251-     pub  signature :  Vec < Felt > , 
252- 
253-     // This is updated only once after the entire test execution. 
254-     pub  gas_report_data :  Option < GasReportData > , 
255- } 
256- 
257- impl  CairoSerialize  for  CallTrace  { 
258-     fn  serialize ( & self ,  output :  & mut  BufferWriter )  { 
259-         self . entry_point . serialize ( output) ; 
260- 
261-         let  visible_calls:  Vec < _ >  = self 
262-             . nested_calls 
263-             . iter ( ) 
264-             . filter_map ( CallTraceNode :: extract_entry_point_call) 
265-             . collect ( ) ; 
266- 
267-         visible_calls. serialize ( output) ; 
268- 
269-         self . result . serialize ( output) ; 
270-     } 
271- } 
272- 
273- impl  CallTrace  { 
274-     fn  default_successful_call ( )  -> Self  { 
275-         Self  { 
276-             entry_point :  CallEntryPoint :: default ( ) , 
277-             used_execution_resources :  ExecutionResources :: default ( ) , 
278-             used_l1_resources :  L1Resources :: default ( ) , 
279-             used_syscalls_vm_resources :  SyscallUsageMap :: default ( ) , 
280-             used_syscalls_sierra_gas :  SyscallUsageMap :: default ( ) , 
281-             nested_calls :  vec ! [ ] , 
282-             result :  CallResult :: Success  {  ret_data :  vec ! [ ]  } , 
283-             vm_trace :  None , 
284-             gas_consumed :  u64:: default ( ) , 
285-             events :  vec ! [ ] , 
286-             signature :  vec ! [ ] , 
287-             gas_report_data :  None , 
288-         } 
289-     } 
290- 
291-     #[ must_use]  
292-     pub  fn  get_total_used_syscalls ( & self )  -> SyscallUsageMap  { 
293-         sum_syscall_usage ( 
294-             self . used_syscalls_vm_resources . clone ( ) , 
295-             & self . used_syscalls_sierra_gas , 
296-         ) 
297-     } 
298- } 
299- 
300- /// Enum representing node of a trace of a call. 
301- #[ derive( Clone ,  Debug ) ]  
302- pub  enum  CallTraceNode  { 
303-     EntryPointCall ( Rc < RefCell < CallTrace > > ) , 
304-     DeployWithoutConstructor , 
305- } 
306- 
307- impl  CallTraceNode  { 
308-     #[ must_use]  
309-     pub  fn  extract_entry_point_call ( & self )  -> Option < & Rc < RefCell < CallTrace > > >  { 
310-         if  let  CallTraceNode :: EntryPointCall ( trace)  = self  { 
311-             Some ( trace) 
312-         }  else  { 
313-             None 
314-         } 
315-     } 
316- } 
317- 
318- #[ derive( Clone ,  Debug ) ]  
319- struct  CallStackElement  { 
320-     call_trace :  Rc < RefCell < CallTrace > > , 
321-     cheated_data :  CheatedData , 
322- } 
323- 
324- #[ derive( Debug ) ]  
325- pub  struct  NotEmptyCallStack ( Vec < CallStackElement > ) ; 
326- 
327- impl  NotEmptyCallStack  { 
328-     pub  fn  from ( elem :  Rc < RefCell < CallTrace > > )  -> Self  { 
329-         NotEmptyCallStack ( vec ! [ CallStackElement  { 
330-             call_trace:  elem, 
331-             cheated_data:  CheatedData :: default ( ) , 
332-         } ] ) 
333-     } 
334- 
335-     pub  fn  push ( & mut  self ,  elem :  Rc < RefCell < CallTrace > > ,  cheated_data :  CheatedData )  { 
336-         self . 0 . push ( CallStackElement  { 
337-             call_trace :  elem, 
338-             cheated_data, 
339-         } ) ; 
340-     } 
341- 
342-     pub  fn  top ( & mut  self )  -> Rc < RefCell < CallTrace > >  { 
343-         let  top_val = self . 0 . last ( ) . unwrap ( ) ; 
344-         top_val. call_trace . clone ( ) 
345-     } 
346- 
347-     pub  fn  top_cheated_data ( & mut  self )  -> CheatedData  { 
348-         let  top_val = self . 0 . last ( ) . unwrap ( ) ; 
349-         top_val. cheated_data . clone ( ) 
350-     } 
351- 
352-     fn  pop ( & mut  self )  -> CallStackElement  { 
353-         assert ! ( self . 0 . len( )  > 1 ,  "You cannot make NotEmptyCallStack empty" ) ; 
354-         self . 0 . pop ( ) . unwrap ( ) 
355-     } 
356- 
357-     #[ must_use]  
358-     pub  fn  size ( & self )  -> usize  { 
359-         self . 0 . len ( ) 
360-     } 
361- 
362-     #[ must_use]  
363-     pub  fn  borrow_full_trace ( & self )  -> Ref < ' _ ,  CallTrace >  { 
364-         self . 0 . first ( ) . unwrap ( ) . call_trace . borrow ( ) 
365-     } 
366- } 
367- 
368198#[ derive( Clone ,  Default ,  Debug ,  PartialEq ,  Eq ) ]  
369199pub  struct  CheatedTxInfo  { 
370200    pub  version :  Option < Felt > , 
@@ -399,12 +229,6 @@ pub struct CheatedData {
399229    pub  tx_info :  CheatedTxInfo , 
400230} 
401231
402- #[ derive( Debug ) ]  
403- pub  struct  TraceData  { 
404-     pub  current_call_stack :  NotEmptyCallStack , 
405-     pub  is_vm_trace_needed :  bool , 
406- } 
407- 
408232pub  struct  CheatnetState  { 
409233    pub  cheated_execution_info_contracts :  HashMap < ContractAddress ,  ExecutionInfoMock > , 
410234    pub  global_cheated_execution_info :  ExecutionInfoMock , 
@@ -577,88 +401,3 @@ impl CheatnetState {
577401        self . encountered_errors . shift_remove ( & class_hash) ; 
578402    } 
579403} 
580- 
581- impl  TraceData  { 
582-     pub  fn  enter_nested_call ( & mut  self ,  entry_point :  CallEntryPoint ,  cheated_data :  CheatedData )  { 
583-         let  new_call = Rc :: new ( RefCell :: new ( CallTrace  { 
584-             entry_point, 
585-             ..CallTrace :: default_successful_call ( ) 
586-         } ) ) ; 
587-         let  current_call = self . current_call_stack . top ( ) ; 
588- 
589-         current_call
590-             . borrow_mut ( ) 
591-             . nested_calls 
592-             . push ( CallTraceNode :: EntryPointCall ( new_call. clone ( ) ) ) ; 
593- 
594-         self . current_call_stack . push ( new_call,  cheated_data) ; 
595-     } 
596- 
597-     pub  fn  set_class_hash_for_current_call ( & mut  self ,  class_hash :  ClassHash )  { 
598-         let  current_call = self . current_call_stack . top ( ) ; 
599-         current_call. borrow_mut ( ) . entry_point . class_hash  = Some ( class_hash) ; 
600-     } 
601- 
602-     pub  fn  set_vm_trace_for_current_call ( & mut  self ,  vm_trace :  Vec < RelocatedTraceEntry > )  { 
603-         let  current_call = self . current_call_stack . top ( ) ; 
604-         current_call. borrow_mut ( ) . vm_trace  = Some ( vm_trace) ; 
605-     } 
606- 
607-     pub  fn  update_current_call_result ( & mut  self ,  result :  CallResult )  { 
608-         let  current_call = self . current_call_stack . top ( ) ; 
609-         current_call. borrow_mut ( ) . result  = result; 
610-     } 
611- 
612-     pub  fn  clear_current_call_events_and_messages ( & mut  self )  { 
613-         let  current_call = self . current_call_stack . top ( ) ; 
614-         current_call. borrow_mut ( ) . events . clear ( ) ; 
615-         current_call
616-             . borrow_mut ( ) 
617-             . used_l1_resources 
618-             . l2_l1_message_sizes 
619-             . clear ( ) ; 
620-     } 
621- 
622-     #[ expect( clippy:: too_many_arguments) ]  
623-     pub  fn  update_current_call ( 
624-         & mut  self , 
625-         execution_resources :  ExecutionResources , 
626-         gas_consumed :  u64 , 
627-         used_syscalls_vm_resources :  SyscallUsageMap , 
628-         used_syscalls_sierra_gas :  SyscallUsageMap , 
629-         result :  CallResult , 
630-         l2_to_l1_messages :  & [ OrderedL2ToL1Message ] , 
631-         signature :  Vec < Felt > , 
632-         events :  Vec < OrderedEvent > , 
633-     )  { 
634-         let  current_call = self . current_call_stack . top ( ) ; 
635-         let  mut  current_call = current_call. borrow_mut ( ) ; 
636- 
637-         current_call. used_execution_resources  = execution_resources; 
638-         current_call. gas_consumed  = gas_consumed; 
639-         current_call. used_syscalls_vm_resources  = used_syscalls_vm_resources; 
640-         current_call. used_syscalls_sierra_gas  = used_syscalls_sierra_gas; 
641- 
642-         current_call. used_l1_resources . l2_l1_message_sizes  = l2_to_l1_messages
643-             . iter ( ) 
644-             . map ( |ordered_message| ordered_message. message . payload . 0 . len ( ) ) 
645-             . collect ( ) ; 
646- 
647-         current_call. result  = result; 
648-         current_call. signature  = signature; 
649-         current_call. events  = events; 
650-     } 
651- 
652-     pub  fn  exit_nested_call ( & mut  self )  { 
653-         self . current_call_stack . pop ( ) ; 
654-     } 
655- 
656-     pub  fn  add_deploy_without_constructor_node ( & mut  self )  { 
657-         let  current_call = self . current_call_stack . top ( ) ; 
658- 
659-         current_call
660-             . borrow_mut ( ) 
661-             . nested_calls 
662-             . push ( CallTraceNode :: DeployWithoutConstructor ) ; 
663-     } 
664- } 
0 commit comments