github.com/MetalBlockchain/subnet-evm@v0.4.9/eth/tracers/native/noop.go (about)

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