github.com/ethereum/go-ethereum@v1.16.1/eth/tracers/live/noop.go (about)

     1  // Copyright 2024 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 live
    18  
    19  import (
    20  	"encoding/json"
    21  	"math/big"
    22  
    23  	"github.com/ethereum/go-ethereum/common"
    24  	"github.com/ethereum/go-ethereum/core/tracing"
    25  	"github.com/ethereum/go-ethereum/core/types"
    26  	"github.com/ethereum/go-ethereum/eth/tracers"
    27  	"github.com/ethereum/go-ethereum/params"
    28  )
    29  
    30  func init() {
    31  	tracers.LiveDirectory.Register("noop", newNoopTracer)
    32  }
    33  
    34  // noop is a no-op live tracer. It's there to
    35  // catch changes in the tracing interface, as well as
    36  // for testing live tracing performance. Can be removed
    37  // as soon as we have a real live tracer.
    38  type noop struct{}
    39  
    40  func newNoopTracer(_ json.RawMessage) (*tracing.Hooks, error) {
    41  	t := &noop{}
    42  	return &tracing.Hooks{
    43  		OnTxStart:        t.OnTxStart,
    44  		OnTxEnd:          t.OnTxEnd,
    45  		OnEnter:          t.OnEnter,
    46  		OnExit:           t.OnExit,
    47  		OnOpcode:         t.OnOpcode,
    48  		OnFault:          t.OnFault,
    49  		OnGasChange:      t.OnGasChange,
    50  		OnBlockchainInit: t.OnBlockchainInit,
    51  		OnBlockStart:     t.OnBlockStart,
    52  		OnBlockEnd:       t.OnBlockEnd,
    53  		OnSkippedBlock:   t.OnSkippedBlock,
    54  		OnGenesisBlock:   t.OnGenesisBlock,
    55  		OnBalanceChange:  t.OnBalanceChange,
    56  		OnNonceChange:    t.OnNonceChange,
    57  		OnCodeChange:     t.OnCodeChange,
    58  		OnStorageChange:  t.OnStorageChange,
    59  		OnLog:            t.OnLog,
    60  		OnBlockHashRead:  t.OnBlockHashRead,
    61  	}, nil
    62  }
    63  
    64  func (t *noop) OnOpcode(pc uint64, op byte, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
    65  }
    66  
    67  func (t *noop) OnFault(pc uint64, op byte, gas, cost uint64, _ tracing.OpContext, depth int, err error) {
    68  }
    69  
    70  func (t *noop) OnEnter(depth int, typ byte, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
    71  }
    72  
    73  func (t *noop) OnExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
    74  }
    75  
    76  func (t *noop) OnTxStart(vm *tracing.VMContext, tx *types.Transaction, from common.Address) {
    77  }
    78  
    79  func (t *noop) OnTxEnd(receipt *types.Receipt, err error) {
    80  }
    81  
    82  func (t *noop) OnBlockStart(ev tracing.BlockEvent) {
    83  }
    84  
    85  func (t *noop) OnBlockEnd(err error) {
    86  }
    87  
    88  func (t *noop) OnSkippedBlock(ev tracing.BlockEvent) {}
    89  
    90  func (t *noop) OnBlockchainInit(chainConfig *params.ChainConfig) {
    91  }
    92  
    93  func (t *noop) OnGenesisBlock(b *types.Block, alloc types.GenesisAlloc) {
    94  }
    95  
    96  func (t *noop) OnBalanceChange(a common.Address, prev, new *big.Int, reason tracing.BalanceChangeReason) {
    97  }
    98  
    99  func (t *noop) OnNonceChange(a common.Address, prev, new uint64) {
   100  }
   101  
   102  func (t *noop) OnCodeChange(a common.Address, prevCodeHash common.Hash, prev []byte, codeHash common.Hash, code []byte) {
   103  }
   104  
   105  func (t *noop) OnStorageChange(a common.Address, k, prev, new common.Hash) {
   106  }
   107  
   108  func (t *noop) OnLog(l *types.Log) {
   109  
   110  }
   111  
   112  func (t *noop) OnBlockHashRead(number uint64, hash common.Hash) {}
   113  
   114  func (t *noop) OnGasChange(old, new uint64, reason tracing.GasChangeReason) {
   115  }