diff --git a/eth/tracers/directory/tracers.go b/eth/tracers/directory/tracers.go
index 766278974c..bd8e6e1c5e 100644
--- a/eth/tracers/directory/tracers.go
+++ b/eth/tracers/directory/tracers.go
@@ -14,9 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see .
-// Package directory provides functionality to lookup tracers by name.
-// It also includes utility functions that are imported by the other
-// tracing packages.
+// Package directory provides functionality to register and lookup tracers by name.
package directory
import (
diff --git a/eth/tracers/directory/util.go b/eth/tracers/internal/util.go
similarity index 96%
rename from eth/tracers/directory/util.go
rename to eth/tracers/internal/util.go
index f5a2cd80d3..18a372d192 100644
--- a/eth/tracers/directory/util.go
+++ b/eth/tracers/internal/util.go
@@ -13,7 +13,7 @@
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see .
-package directory
+package internal
import (
"errors"
@@ -62,6 +62,7 @@ func memoryCopy(m []byte, offset, size int64) (cpy []byte) {
return
}
+// MemoryPtr returns a pointer to a slice of memory.
func MemoryPtr(m []byte, offset, size int64) []byte {
if size == 0 {
return nil
diff --git a/eth/tracers/directory/util_test.go b/eth/tracers/internal/util_test.go
similarity index 99%
rename from eth/tracers/directory/util_test.go
rename to eth/tracers/internal/util_test.go
index 731eeb832f..6a467314cc 100644
--- a/eth/tracers/directory/util_test.go
+++ b/eth/tracers/internal/util_test.go
@@ -13,7 +13,7 @@
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see .
-package directory
+package internal
import (
"testing"
diff --git a/eth/tracers/js/goja.go b/eth/tracers/js/goja.go
index 5c52ba1f11..69b857b71a 100644
--- a/eth/tracers/js/goja.go
+++ b/eth/tracers/js/goja.go
@@ -26,6 +26,7 @@ import (
"github.com/ethereum/go-ethereum/core/tracing"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth/tracers/directory"
+ "github.com/ethereum/go-ethereum/eth/tracers/internal"
"github.com/holiman/uint256"
"github.com/ethereum/go-ethereum/common"
@@ -643,7 +644,7 @@ func (mo *memoryObj) slice(begin, end int64) ([]byte, error) {
if end < begin || begin < 0 {
return nil, fmt.Errorf("tracer accessed out of bound memory: offset %d, end %d", begin, end)
}
- slice, err := directory.GetMemoryCopyPadded(mo.memory, begin, end-begin)
+ slice, err := internal.GetMemoryCopyPadded(mo.memory, begin, end-begin)
if err != nil {
return nil, err
}
@@ -669,7 +670,7 @@ func (mo *memoryObj) getUint(addr int64) (*big.Int, error) {
if len(mo.memory) < int(addr)+32 || addr < 0 {
return nil, fmt.Errorf("tracer accessed out of bound memory: available %d, offset %d, size %d", len(mo.memory), addr, 32)
}
- return new(big.Int).SetBytes(directory.MemoryPtr(mo.memory, addr, 32)), nil
+ return new(big.Int).SetBytes(internal.MemoryPtr(mo.memory, addr, 32)), nil
}
func (mo *memoryObj) Length() int {
@@ -709,7 +710,7 @@ func (s *stackObj) peek(idx int) (*big.Int, error) {
if len(s.stack) <= idx || idx < 0 {
return nil, fmt.Errorf("tracer accessed out of bound stack: size %d, index %d", len(s.stack), idx)
}
- return directory.StackBack(s.stack, idx).ToBig(), nil
+ return internal.StackBack(s.stack, idx).ToBig(), nil
}
func (s *stackObj) Length() int {
diff --git a/eth/tracers/directory/noop.go b/eth/tracers/native/noop.go
similarity index 64%
rename from eth/tracers/directory/noop.go
rename to eth/tracers/native/noop.go
index d0edf12e21..66e52468cb 100644
--- a/eth/tracers/directory/noop.go
+++ b/eth/tracers/native/noop.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see .
-package directory
+package native
import (
"encoding/json"
@@ -23,20 +23,21 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/tracing"
"github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/eth/tracers/directory"
)
func init() {
- DefaultDirectory.Register("noopTracer", newNoopTracer, false)
+ directory.DefaultDirectory.Register("noopTracer", newNoopTracer, false)
}
-// NoopTracer is a go implementation of the Tracer interface which
+// noopTracer is a go implementation of the Tracer interface which
// performs no action. It's mostly useful for testing purposes.
-type NoopTracer struct{}
+type noopTracer struct{}
// newNoopTracer returns a new noop tracer.
-func newNoopTracer(ctx *Context, _ json.RawMessage) (*Tracer, error) {
- t := &NoopTracer{}
- return &Tracer{
+func newNoopTracer(ctx *directory.Context, _ json.RawMessage) (*directory.Tracer, error) {
+ t := &noopTracer{}
+ return &directory.Tracer{
Hooks: &tracing.Hooks{
OnTxStart: t.OnTxStart,
OnTxEnd: t.OnTxEnd,
@@ -56,42 +57,42 @@ func newNoopTracer(ctx *Context, _ json.RawMessage) (*Tracer, error) {
}, nil
}
-func (t *NoopTracer) OnOpcode(pc uint64, op byte, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
+func (t *noopTracer) OnOpcode(pc uint64, op byte, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
}
-func (t *NoopTracer) OnFault(pc uint64, op byte, gas, cost uint64, _ tracing.OpContext, depth int, err error) {
+func (t *noopTracer) OnFault(pc uint64, op byte, gas, cost uint64, _ tracing.OpContext, depth int, err error) {
}
-func (t *NoopTracer) OnGasChange(old, new uint64, reason tracing.GasChangeReason) {}
+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) {
+func (t *noopTracer) OnEnter(depth int, typ byte, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
}
-func (t *NoopTracer) OnExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
+func (t *noopTracer) OnExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
}
-func (*NoopTracer) OnTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
+func (*noopTracer) OnTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
}
-func (*NoopTracer) OnTxEnd(receipt *types.Receipt, err error) {}
+func (*noopTracer) OnTxEnd(receipt *types.Receipt, err error) {}
-func (*NoopTracer) OnBalanceChange(a common.Address, prev, new *big.Int, reason tracing.BalanceChangeReason) {
+func (*noopTracer) OnBalanceChange(a common.Address, prev, new *big.Int, reason tracing.BalanceChangeReason) {
}
-func (*NoopTracer) OnNonceChange(a common.Address, prev, new uint64) {}
+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) {
+func (*noopTracer) OnCodeChange(a common.Address, prevCodeHash common.Hash, prev []byte, codeHash common.Hash, code []byte) {
}
-func (*NoopTracer) OnStorageChange(a common.Address, k, prev, new common.Hash) {}
+func (*noopTracer) OnStorageChange(a common.Address, k, prev, new common.Hash) {}
-func (*NoopTracer) OnLog(log *types.Log) {}
+func (*noopTracer) OnLog(log *types.Log) {}
// GetResult returns an empty json object.
-func (t *NoopTracer) GetResult() (json.RawMessage, error) {
+func (t *noopTracer) GetResult() (json.RawMessage, error) {
return json.RawMessage(`{}`), nil
}
// Stop terminates execution of the tracer at the first opportune moment.
-func (t *NoopTracer) Stop(err error) {
+func (t *noopTracer) Stop(err error) {
}
diff --git a/eth/tracers/native/prestate.go b/eth/tracers/native/prestate.go
index e90a1729bb..8f7b028684 100644
--- a/eth/tracers/native/prestate.go
+++ b/eth/tracers/native/prestate.go
@@ -29,6 +29,7 @@ import (
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth/tracers/directory"
+ "github.com/ethereum/go-ethereum/eth/tracers/internal"
"github.com/ethereum/go-ethereum/log"
)
@@ -132,7 +133,7 @@ func (t *prestateTracer) OnOpcode(pc uint64, opcode byte, gas, cost uint64, scop
case stackLen >= 4 && op == vm.CREATE2:
offset := stackData[stackLen-2]
size := stackData[stackLen-3]
- init, err := directory.GetMemoryCopyPadded(scope.MemoryData(), int64(offset.Uint64()), int64(size.Uint64()))
+ init, err := internal.GetMemoryCopyPadded(scope.MemoryData(), int64(offset.Uint64()), int64(size.Uint64()))
if err != nil {
log.Warn("failed to copy CREATE2 input", "err", err, "tracer", "prestateTracer", "offset", offset, "size", size)
return