github.com/ethw3/go-ethereuma@v0.0.0-20221013053120-c14602a4c23c/eth/tracers/native/noop.go (about)

     1  // Copyright 2021 The go-ethereum Authors
     2  // This file is part of the go-ethereum library.
     3  //
     4  // The go-ethereum library is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Lesser General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // The go-ethereum library is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU Lesser General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Lesser General Public License
    15  // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package native
    18  
    19  import (
    20  	"encoding/json"
    21  	"math/big"
    22  	"time"
    23  
    24  	"github.com/ethw3/go-ethereuma/common"
    25  	"github.com/ethw3/go-ethereuma/core/vm"
    26  	"github.com/ethw3/go-ethereuma/eth/tracers"
    27  )
    28  
    29  func init() {
    30  	register("noopTracer", newNoopTracer)
    31  }
    32  
    33  // noopTracer is a go implementation of the Tracer interface which
    34  // performs no action. It's mostly useful for testing purposes.
    35  type noopTracer struct{}
    36  
    37  // newNoopTracer returns a new noop tracer.
    38  func newNoopTracer(ctx *tracers.Context, _ json.RawMessage) (tracers.Tracer, error) {
    39  	return &noopTracer{}, nil
    40  }
    41  
    42  // CaptureStart implements the EVMLogger interface to initialize the tracing operation.
    43  func (t *noopTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) {
    44  }
    45  
    46  // CaptureEnd is called after the call finishes to finalize the tracing.
    47  func (t *noopTracer) CaptureEnd(output []byte, gasUsed uint64, _ time.Duration, err error) {
    48  }
    49  
    50  // CaptureState implements the EVMLogger interface to trace a single step of VM execution.
    51  func (t *noopTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, rData []byte, depth int, err error) {
    52  }
    53  
    54  // CaptureFault implements the EVMLogger interface to trace an execution fault.
    55  func (t *noopTracer) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, _ *vm.ScopeContext, depth int, err error) {
    56  }
    57  
    58  // CaptureEnter is called when EVM enters a new scope (via call, create or selfdestruct).
    59  func (t *noopTracer) CaptureEnter(typ vm.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
    60  }
    61  
    62  // CaptureExit is called when EVM exits a scope, even if the scope didn't
    63  // execute any code.
    64  func (t *noopTracer) CaptureExit(output []byte, gasUsed uint64, err error) {
    65  }
    66  
    67  func (*noopTracer) CaptureTxStart(gasLimit uint64) {}
    68  
    69  func (*noopTracer) CaptureTxEnd(restGas uint64) {}
    70  
    71  // GetResult returns an empty json object.
    72  func (t *noopTracer) GetResult() (json.RawMessage, error) {
    73  	return json.RawMessage(`{}`), nil
    74  }
    75  
    76  // Stop terminates execution of the tracer at the first opportune moment.
    77  func (t *noopTracer) Stop(err error) {
    78  }