@@ -1015,10 +1015,21 @@ where
1015
1015
fn run ( & mut self , executable : E , input_data : Vec < u8 > ) -> Result < ( ) , ExecError > {
1016
1016
let frame = self . top_frame ( ) ;
1017
1017
let entry_point = frame. entry_point ;
1018
- let is_delegate_call = frame. delegate . is_some ( ) ;
1019
1018
let delegated_code_hash =
1020
1019
if frame. delegate . is_some ( ) { Some ( * executable. code_hash ( ) ) } else { None } ;
1021
1020
1021
+ if_tracing ( |tracer| {
1022
+ tracer. enter_child_span (
1023
+ self . caller ( ) . account_id ( ) . map ( T :: AddressMapper :: to_address) . unwrap_or_default ( ) ,
1024
+ T :: AddressMapper :: to_address ( & frame. account_id ) ,
1025
+ frame. delegate . is_some ( ) ,
1026
+ frame. read_only ,
1027
+ frame. value_transferred ,
1028
+ & input_data,
1029
+ frame. nested_gas . gas_left ( ) ,
1030
+ ) ;
1031
+ } ) ;
1032
+
1022
1033
// The output of the caller frame will be replaced by the output of this run.
1023
1034
// It is also not accessible from nested frames.
1024
1035
// Hence we drop it early to save the memory.
@@ -1036,8 +1047,6 @@ where
1036
1047
let do_transaction = || -> ExecResult {
1037
1048
let caller = self . caller ( ) ;
1038
1049
let frame = top_frame_mut ! ( self ) ;
1039
- let read_only = frame. read_only ;
1040
- let value_transferred = frame. value_transferred ;
1041
1050
let account_id = & frame. account_id . clone ( ) ;
1042
1051
1043
1052
// We need to make sure that the contract's account exists before calling its
@@ -1081,35 +1090,10 @@ where
1081
1090
) ?;
1082
1091
}
1083
1092
1084
- let contract_address = T :: AddressMapper :: to_address ( account_id) ;
1085
- let maybe_caller_address = caller. account_id ( ) . map ( T :: AddressMapper :: to_address) ;
1086
1093
let code_deposit = executable. code_info ( ) . deposit ( ) ;
1087
-
1088
- if_tracing ( |tracer| {
1089
- tracer. enter_child_span (
1090
- maybe_caller_address. unwrap_or_default ( ) ,
1091
- contract_address,
1092
- is_delegate_call,
1093
- read_only,
1094
- value_transferred,
1095
- & input_data,
1096
- frame. nested_gas . gas_left ( ) ,
1097
- ) ;
1098
- } ) ;
1099
-
1100
- let output = executable. execute ( self , entry_point, input_data) . map_err ( |e| {
1101
- if_tracing ( |tracer| {
1102
- tracer. exit_child_span_with_error (
1103
- e. error ,
1104
- top_frame_mut ! ( self ) . nested_gas . gas_consumed ( ) ,
1105
- ) ;
1106
- } ) ;
1107
- ExecError { error : e. error , origin : ErrorOrigin :: Callee }
1108
- } ) ?;
1109
-
1110
- if_tracing ( |tracer| {
1111
- tracer. exit_child_span ( & output, top_frame_mut ! ( self ) . nested_gas . gas_consumed ( ) ) ;
1112
- } ) ;
1094
+ let output = executable
1095
+ . execute ( self , entry_point, input_data)
1096
+ . map_err ( |e| ExecError { error : e. error , origin : ErrorOrigin :: Callee } ) ?;
1113
1097
1114
1098
// Avoid useless work that would be reverted anyways.
1115
1099
if output. did_revert ( ) {
@@ -1157,10 +1141,27 @@ where
1157
1141
1158
1142
let ( success, output) = match transaction_outcome {
1159
1143
// `with_transactional` executed successfully, and we have the expected output.
1160
- Ok ( ( success, output) ) => ( success, output) ,
1144
+ Ok ( ( success, output) ) => {
1145
+ if_tracing ( |tracer| {
1146
+ let gas_consumed = top_frame ! ( self ) . nested_gas . gas_consumed ( ) ;
1147
+ match & output {
1148
+ Ok ( output) => tracer. exit_child_span ( & output, gas_consumed) ,
1149
+ Err ( e) => tracer. exit_child_span_with_error ( e. error . into ( ) , gas_consumed) ,
1150
+ }
1151
+ } ) ;
1152
+
1153
+ ( success, output)
1154
+ } ,
1161
1155
// `with_transactional` returned an error, and we propagate that error and note no state
1162
1156
// has changed.
1163
- Err ( error) => ( false , Err ( error. into ( ) ) ) ,
1157
+ Err ( error) => {
1158
+ if_tracing ( |tracer| {
1159
+ let gas_consumed = top_frame ! ( self ) . nested_gas . gas_consumed ( ) ;
1160
+ tracer. exit_child_span_with_error ( error. into ( ) , gas_consumed) ;
1161
+ } ) ;
1162
+
1163
+ ( false , Err ( error. into ( ) ) )
1164
+ } ,
1164
1165
} ;
1165
1166
1166
1167
if success {
0 commit comments