noop.go 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. package native
  17. import (
  18. "encoding/json"
  19. "math/big"
  20. "time"
  21. "github.com/ethereum/go-ethereum/common"
  22. "github.com/ethereum/go-ethereum/core/vm"
  23. "github.com/ethereum/go-ethereum/eth/tracers"
  24. )
  25. func init() {
  26. register("noopTracerNative", newNoopTracer)
  27. }
  28. // noopTracer is a go implementation of the Tracer interface which
  29. // performs no action. It's mostly useful for testing purposes.
  30. type noopTracer struct{}
  31. // newNoopTracer returns a new noop tracer.
  32. func newNoopTracer() tracers.Tracer {
  33. return &noopTracer{}
  34. }
  35. // CaptureStart implements the EVMLogger interface to initialize the tracing operation.
  36. func (t *noopTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) {
  37. }
  38. // CaptureEnd is called after the call finishes to finalize the tracing.
  39. func (t *noopTracer) CaptureEnd(output []byte, gasUsed uint64, _ time.Duration, err error) {
  40. }
  41. // CaptureState implements the EVMLogger interface to trace a single step of VM execution.
  42. func (t *noopTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, rData []byte, depth int, err error) {
  43. }
  44. // CaptureFault implements the EVMLogger interface to trace an execution fault.
  45. func (t *noopTracer) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, _ *vm.ScopeContext, depth int, err error) {
  46. }
  47. // CaptureEnter is called when EVM enters a new scope (via call, create or selfdestruct).
  48. func (t *noopTracer) CaptureEnter(typ vm.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
  49. }
  50. // CaptureExit is called when EVM exits a scope, even if the scope didn't
  51. // execute any code.
  52. func (t *noopTracer) CaptureExit(output []byte, gasUsed uint64, err error) {
  53. }
  54. // GetResult returns an empty json object.
  55. func (t *noopTracer) GetResult() (json.RawMessage, error) {
  56. return json.RawMessage(`{}`), nil
  57. }
  58. // Stop terminates execution of the tracer at the first opportune moment.
  59. func (t *noopTracer) Stop(err error) {
  60. }