2021-11-09 05:09:35 -06: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 05:48:21 -05:00
|
|
|
package native
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"math/big"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
2024-03-22 12:53:53 -05:00
|
|
|
"github.com/ethereum/go-ethereum/core/tracing"
|
|
|
|
"github.com/ethereum/go-ethereum/core/types"
|
2021-11-05 05:48:21 -05:00
|
|
|
"github.com/ethereum/go-ethereum/eth/tracers"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2023-01-10 08:11:53 -06:00
|
|
|
tracers.DefaultDirectory.Register("noopTracer", newNoopTracer, false)
|
2021-11-05 05:48:21 -05:00
|
|
|
}
|
|
|
|
|
2021-11-09 05:09:35 -06:00
|
|
|
// noopTracer is a go implementation of the Tracer interface which
|
|
|
|
// performs no action. It's mostly useful for testing purposes.
|
2021-11-05 05:48:21 -05:00
|
|
|
type noopTracer struct{}
|
|
|
|
|
2021-11-09 05:09:35 -06:00
|
|
|
// newNoopTracer returns a new noop tracer.
|
2024-03-22 12:53:53 -05:00
|
|
|
func newNoopTracer(ctx *tracers.Context, _ json.RawMessage) (*tracers.Tracer, error) {
|
|
|
|
t := &noopTracer{}
|
|
|
|
return &tracers.Tracer{
|
|
|
|
Hooks: &tracing.Hooks{
|
|
|
|
OnTxStart: t.OnTxStart,
|
|
|
|
OnTxEnd: t.OnTxEnd,
|
|
|
|
OnEnter: t.OnEnter,
|
|
|
|
OnExit: t.OnExit,
|
|
|
|
OnOpcode: t.OnOpcode,
|
|
|
|
OnFault: t.OnFault,
|
|
|
|
OnGasChange: t.OnGasChange,
|
|
|
|
OnBalanceChange: t.OnBalanceChange,
|
|
|
|
OnNonceChange: t.OnNonceChange,
|
|
|
|
OnCodeChange: t.OnCodeChange,
|
|
|
|
OnStorageChange: t.OnStorageChange,
|
|
|
|
OnLog: t.OnLog,
|
|
|
|
},
|
|
|
|
GetResult: t.GetResult,
|
|
|
|
Stop: t.Stop,
|
|
|
|
}, nil
|
2021-11-05 05:48:21 -05:00
|
|
|
}
|
|
|
|
|
2024-03-22 12:53:53 -05:00
|
|
|
func (t *noopTracer) OnOpcode(pc uint64, op byte, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
|
2021-11-05 05:48:21 -05:00
|
|
|
}
|
|
|
|
|
2024-03-22 12:53:53 -05:00
|
|
|
func (t *noopTracer) OnFault(pc uint64, op byte, gas, cost uint64, _ tracing.OpContext, depth int, err error) {
|
2021-11-05 05:48:21 -05:00
|
|
|
}
|
|
|
|
|
2024-03-22 12:53:53 -05:00
|
|
|
func (t *noopTracer) OnGasChange(old, new uint64, reason tracing.GasChangeReason) {}
|
|
|
|
|
|
|
|
func (t *noopTracer) OnEnter(depth int, typ byte, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
|
2021-11-05 05:48:21 -05:00
|
|
|
}
|
|
|
|
|
2024-03-22 12:53:53 -05:00
|
|
|
func (t *noopTracer) OnExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
|
2021-11-05 05:48:21 -05:00
|
|
|
}
|
|
|
|
|
2024-03-22 12:53:53 -05:00
|
|
|
func (*noopTracer) OnTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
2021-11-05 05:48:21 -05:00
|
|
|
}
|
|
|
|
|
2024-03-22 12:53:53 -05:00
|
|
|
func (*noopTracer) OnTxEnd(receipt *types.Receipt, err error) {}
|
|
|
|
|
|
|
|
func (*noopTracer) OnBalanceChange(a common.Address, prev, new *big.Int, reason tracing.BalanceChangeReason) {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*noopTracer) OnNonceChange(a common.Address, prev, new uint64) {}
|
|
|
|
|
|
|
|
func (*noopTracer) OnCodeChange(a common.Address, prevCodeHash common.Hash, prev []byte, codeHash common.Hash, code []byte) {
|
2021-11-05 05:48:21 -05:00
|
|
|
}
|
|
|
|
|
2024-03-22 12:53:53 -05:00
|
|
|
func (*noopTracer) OnStorageChange(a common.Address, k, prev, new common.Hash) {}
|
2022-03-31 04:51:44 -05:00
|
|
|
|
2024-03-22 12:53:53 -05:00
|
|
|
func (*noopTracer) OnLog(log *types.Log) {}
|
2022-03-31 04:51:44 -05:00
|
|
|
|
2021-11-09 05:09:35 -06:00
|
|
|
// GetResult returns an empty json object.
|
2021-11-05 05:48:21 -05:00
|
|
|
func (t *noopTracer) GetResult() (json.RawMessage, error) {
|
|
|
|
return json.RawMessage(`{}`), nil
|
|
|
|
}
|
|
|
|
|
2021-11-09 05:09:35 -06:00
|
|
|
// Stop terminates execution of the tracer at the first opportune moment.
|
2021-11-05 05:48:21 -05:00
|
|
|
func (t *noopTracer) Stop(err error) {
|
|
|
|
}
|