3737 let gas_scale = parameters:: get_gas_scale ( & state) ?;
3838
3939 // Wrapper dry run to allow estimating the gas cost of a transaction
40- let ( wrapper_hash, extended_tx_result, tx_gas_meter) =
40+ let ( wrapper_hash, extended_tx_result, tx_gas_meter, gas_used ) =
4141 match tx. header ( ) . tx_type {
4242 TxType :: Wrapper ( wrapper) => {
4343 let gas_limit = wrapper
@@ -64,10 +64,12 @@ where
6464
6565 state. write_log_mut ( ) . commit_tx_to_batch ( ) ;
6666 let available_gas = tx_gas_meter. borrow ( ) . get_available_gas ( ) ;
67+ let consumed_gas = tx_gas_meter. borrow ( ) . get_tx_consumed_gas ( ) ;
6768 (
6869 Some ( tx. header_hash ( ) ) ,
6970 tx_result,
7071 TxGasMeter :: new ( available_gas) ,
72+ consumed_gas,
7173 )
7274 }
7375 _ => {
8183 None ,
8284 TxResult :: default ( ) . to_extended_result ( None ) ,
8385 TxGasMeter :: new ( gas_limit) ,
86+ 0 . into ( ) ,
8487 )
8588 }
8689 } ;
@@ -119,9 +122,9 @@ where
119122 ) ;
120123 }
121124 // Account gas for both batch and wrapper
122- let gas_used = tx_gas_meter
123- . borrow ( )
124- . get_tx_consumed_gas ( )
125+ let gas_used = gas_used
126+ . checked_add ( tx_gas_meter . borrow ( ) . get_tx_consumed_gas ( ) )
127+ . unwrap_or ( u64 :: MAX . into ( ) )
125128 . get_whole_gas_units ( gas_scale) ;
126129 let tx_result_string = tx_result. to_result_string ( ) ;
127130 let dry_run_result = DryRunResult ( tx_result_string, gas_used) ;
0 commit comments