@@ -157,38 +157,33 @@ void DebugTracer::on_instruction_start(uint32_t pc, const intx::uint256* stack_t
157157
158158 if (!logs_.empty ()) {
159159 auto & log = logs_[logs_.size () - 1 ];
160- const auto depth = log.depth ;
161- if (depth == execution_state.msg ->depth + 1 ) {
162- if (gas_on_precompiled_) {
163- log.gas_cost = log.gas - gas_on_precompiled_;
164- gas_on_precompiled_ = 0 ;
165- } else {
166- log.gas_cost = log.gas - gas;
167- }
168- } else if (depth == execution_state.msg ->depth ) {
169- log.gas_cost = log.gas - gas;
170- }
171- if (call_fixes_) {
160+ if (call_fixes_) { // previuos opcodw was a CALL*
172161 if (execution_state.msg ->depth == call_fixes_->depth ) {
173162 if (call_fixes_->gas_cost ) {
174163 log.gas_cost = call_fixes_->gas_cost ;
175164 } else {
176- log.gas_cost = log.gas_cost + call_fixes_->stipend ;
165+ log.gas_cost = log.gas - gas + call_fixes_->stipend ;
177166 }
178167 } else {
179168 log.gas_cost = gas + call_fixes_->stipend + call_fixes_->code_cost ;
180169 }
181170
182171 call_fixes_.reset ();
172+ } else {
173+ const auto depth = log.depth ;
174+ if (depth == execution_state.msg ->depth + 1 || depth == execution_state.msg ->depth ) {
175+ log.gas_cost = log.gas - gas;
176+ }
183177 }
184178 }
179+
185180 if (logs_.size () > 1 ) {
186181 auto & log = logs_.front ();
187182 write_log (log);
188183 logs_.erase (logs_.begin ());
189184 }
190185
191- if (opcode == OP_CALL || opcode == OP_CALLCODE || opcode == OP_DELEGATECALL || opcode == OP_CREATE || opcode == OP_CREATE2) {
186+ if (opcode == OP_CALL || opcode == OP_CALLCODE || opcode == OP_STATICCALL || opcode == OP_DELEGATECALL || opcode == OP_CREATE || opcode == OP_CREATE2) {
192187 call_fixes_ = std::make_unique<CallFixes>(CallFixes{execution_state.msg ->depth , 0 , metrics_[opcode].gas_cost });
193188 if (opcode == OP_CALL && stack_height >= 7 && stack_top[-2 ] != 0 ) {
194189 call_fixes_->stipend = 2300 ; // for CALLs with value, include stipend
@@ -226,7 +221,6 @@ void DebugTracer::on_precompiled_run(const evmc_result& result, int64_t gas, con
226221 << " status: " << result.status_code
227222 << " , gas: " << std::dec << gas;
228223
229- gas_on_precompiled_ = gas;
230224 if (call_fixes_) {
231225 call_fixes_->gas_cost = gas + call_fixes_->code_cost ;
232226 }
0 commit comments