2021-11-09 14:09:35 +03:00
|
|
|
// Copyright 2021 The go-ethereum Authors
|
|
|
|
// This file is part of the go-ethereum library.
|
|
|
|
//
|
|
|
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2021-11-05 13:48:21 +03:00
|
|
|
package native
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"math/big"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
"github.com/ethereum/go-ethereum/core/vm"
|
|
|
|
"github.com/ethereum/go-ethereum/eth/tracers"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2022-02-01 12:44:44 +03:00
|
|
|
register("noopTracer", newNoopTracer)
|
2021-11-05 13:48:21 +03:00
|
|
|
}
|
|
|
|
|
2021-11-09 14:09:35 +03:00
|
|
|
// noopTracer is a go implementation of the Tracer interface which
|
|
|
|
// performs no action. It's mostly useful for testing purposes.
|
2021-11-05 13:48:21 +03:00
|
|
|
type noopTracer struct{}
|
|
|
|
|
2021-11-09 14:09:35 +03:00
|
|
|
// newNoopTracer returns a new noop tracer.
|
|
|
|
func newNoopTracer() tracers.Tracer {
|
2021-11-05 13:48:21 +03:00
|
|
|
return &noopTracer{}
|
|
|
|
}
|
|
|
|
|
2021-11-09 14:09:35 +03:00
|
|
|
// CaptureStart implements the EVMLogger interface to initialize the tracing operation.
|
2021-11-05 13:48:21 +03:00
|
|
|
func (t *noopTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) {
|
|
|
|
}
|
|
|
|
|
2021-11-09 14:09:35 +03:00
|
|
|
// CaptureEnd is called after the call finishes to finalize the tracing.
|
2021-11-05 13:48:21 +03:00
|
|
|
func (t *noopTracer) CaptureEnd(output []byte, gasUsed uint64, _ time.Duration, err error) {
|
|
|
|
}
|
|
|
|
|
2021-11-09 14:09:35 +03:00
|
|
|
// CaptureState implements the EVMLogger interface to trace a single step of VM execution.
|
|
|
|
func (t *noopTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, rData []byte, depth int, err error) {
|
2021-11-05 13:48:21 +03:00
|
|
|
}
|
|
|
|
|
2021-11-09 14:09:35 +03:00
|
|
|
// CaptureFault implements the EVMLogger interface to trace an execution fault.
|
|
|
|
func (t *noopTracer) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, _ *vm.ScopeContext, depth int, err error) {
|
2021-11-05 13:48:21 +03:00
|
|
|
}
|
|
|
|
|
2021-11-09 14:09:35 +03:00
|
|
|
// CaptureEnter is called when EVM enters a new scope (via call, create or selfdestruct).
|
2021-11-05 13:48:21 +03:00
|
|
|
func (t *noopTracer) CaptureEnter(typ vm.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
|
|
|
|
}
|
|
|
|
|
2021-11-09 14:09:35 +03:00
|
|
|
// CaptureExit is called when EVM exits a scope, even if the scope didn't
|
|
|
|
// execute any code.
|
2021-11-05 13:48:21 +03:00
|
|
|
func (t *noopTracer) CaptureExit(output []byte, gasUsed uint64, err error) {
|
|
|
|
}
|
|
|
|
|
2021-11-09 14:09:35 +03:00
|
|
|
// GetResult returns an empty json object.
|
2021-11-05 13:48:21 +03:00
|
|
|
func (t *noopTracer) GetResult() (json.RawMessage, error) {
|
|
|
|
return json.RawMessage(`{}`), nil
|
|
|
|
}
|
|
|
|
|
2021-11-09 14:09:35 +03:00
|
|
|
// Stop terminates execution of the tracer at the first opportune moment.
|
2021-11-05 13:48:21 +03:00
|
|
|
func (t *noopTracer) Stop(err error) {
|
|
|
|
}
|