@@ -9,7 +9,6 @@ mod checked {
99 use crate :: execution_mode:: { self , ExecutionMode } ;
1010 use crate :: execution_value:: SuiResolver ;
1111 use csv:: Writer ;
12- use lz4_flex:: frame:: FrameEncoder ;
1312 use move_binary_format:: CompiledModule ;
1413 use move_trace_format:: format:: MoveTraceBuilder ;
1514 use move_vm_runtime:: move_vm:: MoveVM ;
@@ -19,7 +18,6 @@ mod checked {
1918 use std:: fs:: File ;
2019 use std:: io:: BufWriter ;
2120 use std:: sync:: Mutex ;
22- use similar:: TextDiff ;
2321 use std:: { cell:: RefCell , collections:: HashSet , rc:: Rc , sync:: Arc } ;
2422 use sui_types:: accumulator_root:: { ACCUMULATOR_ROOT_CREATE_FUNC , ACCUMULATOR_ROOT_MODULE } ;
2523 use sui_types:: balance:: {
@@ -28,6 +26,7 @@ mod checked {
2826 } ;
2927 use sui_types:: execution_params:: ExecutionOrEarlyError ;
3028 use sui_types:: gas_coin:: GAS ;
29+ use sui_types:: gas_model:: tables:: GasDetails ;
3130 use sui_types:: messages_checkpoint:: CheckpointTimestamp ;
3231 use sui_types:: metrics:: LimitsMetrics ;
3332 use sui_types:: object:: OBJECT_START_VERSION ;
@@ -69,7 +68,6 @@ mod checked {
6968 use sui_types:: error:: { ExecutionError , ExecutionErrorKind } ;
7069 use sui_types:: execution:: { ExecutionTiming , ResultWithTimings } ;
7170 use sui_types:: execution_status:: { ExecutionFailureStatus , ExecutionStatus } ;
72- use sui_types:: gas:: GasCostSummary ;
7371 use sui_types:: gas:: SuiGasStatus ;
7472 use sui_types:: gas:: { GasCostSummary , GasUsageReport } ;
7573 use sui_types:: id:: UID ;
@@ -93,14 +91,13 @@ mod checked {
9391 sui_system_state:: { ADVANCE_EPOCH_FUNCTION_NAME , SUI_SYSTEM_MODULE_NAME } ,
9492 } ;
9593
96- static CSV_WRITER : Lazy < Mutex < csv:: Writer < FrameEncoder < std:: io:: BufWriter < std:: fs:: File > > > > > =
94+ static CSV_WRITER : Lazy < Mutex < csv:: Writer < std:: io:: BufWriter < std:: fs:: File > > > > =
9795 once_cell:: sync:: Lazy :: new ( || {
98- let file = File :: create ( "/opt/sui/gas.csv.lz4" ) . expect ( "failed to create file" ) ;
99- let enc = BufWriter :: new ( file) ;
100- let enc = FrameEncoder :: new ( enc) ;
101- let mut writer = Writer :: from_writer ( enc) ;
96+ let file = File :: create ( "/opt/sui/gas.csv" ) . expect ( "failed to create file" ) ;
97+ let buf = BufWriter :: new ( file) ;
98+ let mut writer = Writer :: from_writer ( buf) ;
10299 writer
103- . write_record ( & [
100+ . write_record ( [
104101 "tx_digest" ,
105102 "gas_budget" ,
106103 "new_computation_cost" ,
@@ -111,6 +108,13 @@ mod checked {
111108 "old_storage_rebate" ,
112109 "new_gas_used" ,
113110 "old_gas_used" ,
111+ "new_instructions" ,
112+ "old_instructions" ,
113+ "new_stack_height" ,
114+ "old_stack_hight" ,
115+ "new_memory_allocated" ,
116+ "old_memory_allocated" ,
117+ "translation" ,
114118 ] )
115119 . expect ( "failed to write gas header" ) ;
116120 Mutex :: new ( writer)
@@ -120,13 +124,15 @@ mod checked {
120124 transaction_digest : String ,
121125 new_gas : & GasUsageReport ,
122126 old_gas : & GasUsageReport ,
127+ new_details : & GasDetails ,
128+ old_details : & GasDetails ,
123129 ) {
124130 if new_gas. cost_summary == old_gas. cost_summary {
125131 return ;
126132 }
127133 let mut writer = CSV_WRITER . lock ( ) . unwrap ( ) ;
128134 writer
129- . write_record ( & [
135+ . write_record ( [
130136 & transaction_digest,
131137 & new_gas. gas_budget . to_string ( ) ,
132138 & new_gas. cost_summary . computation_cost . to_string ( ) ,
@@ -137,6 +143,13 @@ mod checked {
137143 & old_gas. cost_summary . storage_rebate . to_string ( ) ,
138144 & new_gas. gas_used . to_string ( ) ,
139145 & old_gas. gas_used . to_string ( ) ,
146+ & new_details. instructions_executed . to_string ( ) ,
147+ & old_details. instructions_executed . to_string ( ) ,
148+ & new_details. stack_height . to_string ( ) ,
149+ & old_details. stack_height . to_string ( ) ,
150+ & new_details. memory_allocated . to_string ( ) ,
151+ & old_details. memory_allocated . to_string ( ) ,
152+ & new_details. transl_gas_used . to_string ( ) ,
140153 ] )
141154 . expect ( "failed to write gas row" ) ;
142155 writer. flush ( ) . expect ( "failed to flush gas writer" ) ;
@@ -208,7 +221,8 @@ mod checked {
208221
209222 compare_effects :: < Mode > ( & normal_effects, & new_effects) ;
210223
211- normal_effects
224+ let ( temp_store, gas_status, effects, _gas_details, timing, res) = normal_effects;
225+ ( temp_store, gas_status, effects, timing, res)
212226 }
213227
214228 #[ instrument( name = "new_tx_execute_to_effects" , level = "debug" , skip_all) ]
@@ -232,6 +246,7 @@ mod checked {
232246 InnerTemporaryStore ,
233247 SuiGasStatus ,
234248 TransactionEffects ,
249+ GasDetails ,
235250 Vec < ExecutionTiming > ,
236251 Result < Mode :: ExecutionResults , ExecutionError > ,
237252 ) {
@@ -306,6 +321,8 @@ mod checked {
306321 trace_builder_opt,
307322 ) ;
308323
324+ let gas_details = gas_charger. move_gas_status ( ) . gas_details ( ) ;
325+
309326 let status = if let Err ( error) = & execution_result {
310327 // Elaborate errors in logs if they are unexpected or their status is terse.
311328 use ExecutionErrorKind as K ;
@@ -398,6 +415,7 @@ mod checked {
398415 inner,
399416 gas_charger. into_gas_status ( ) ,
400417 effects,
418+ gas_details,
401419 timings,
402420 execution_result,
403421 )
@@ -408,13 +426,15 @@ mod checked {
408426 InnerTemporaryStore ,
409427 SuiGasStatus ,
410428 TransactionEffects ,
429+ GasDetails ,
411430 Vec < ExecutionTiming > ,
412431 Result < Mode :: ExecutionResults , ExecutionError > ,
413432 ) ,
414433 new_effects : & (
415434 InnerTemporaryStore ,
416435 SuiGasStatus ,
417436 TransactionEffects ,
437+ GasDetails ,
418438 Vec < ExecutionTiming > ,
419439 Result < Mode :: ExecutionResults , ExecutionError > ,
420440 ) ,
@@ -453,6 +473,8 @@ mod checked {
453473 normal_effects. 2 . transaction_digest ( ) . to_string ( ) ,
454474 & new_effects. 1 . gas_usage_report ( ) ,
455475 & normal_effects. 1 . gas_usage_report ( ) ,
476+ & new_effects. 3 ,
477+ & normal_effects. 3 ,
456478 ) ;
457479
458480 if !ok {
0 commit comments