diff --git a/eth/tracers/js/goja.go b/eth/tracers/js/goja.go
index 800f01e028b..f6b01fbda96 100644
--- a/eth/tracers/js/goja.go
+++ b/eth/tracers/js/goja.go
@@ -94,8 +94,6 @@ func fromBuf(vm *goja.Runtime, bufType goja.Value, buf goja.Value, allowString b
// jsTracer is an implementation of the Tracer interface which evaluates
// JS functions on the relevant EVM hooks. It uses Goja as its JS engine.
type jsTracer struct {
- tracers.NoopTracer
-
vm *goja.Runtime
env *tracing.VMContext
toBig toBigFn // Converts a hex string into a JS bigint
diff --git a/eth/tracers/native/4byte.go b/eth/tracers/native/4byte.go
index 54c5240f1bd..b14dd2956c1 100644
--- a/eth/tracers/native/4byte.go
+++ b/eth/tracers/native/4byte.go
@@ -50,7 +50,6 @@ func init() {
// 0xc281d19e-0: 1
// }
type fourByteTracer struct {
- tracers.NoopTracer
ids map[string]int // ids aggregates the 4byte ids found
interrupt uint32 // Atomic flag to signal execution interruption
reason error // Textual reason for the interruption
diff --git a/eth/tracers/native/call.go b/eth/tracers/native/call.go
index bf0dc0d5821..e6306a98e1f 100644
--- a/eth/tracers/native/call.go
+++ b/eth/tracers/native/call.go
@@ -106,7 +106,6 @@ type callFrameMarshaling struct {
}
type callTracer struct {
- tracers.NoopTracer
callstack []callFrame
config callTracerConfig
gasLimit uint64
diff --git a/eth/tracers/noop.go b/eth/tracers/native/noop.go
similarity index 95%
rename from eth/tracers/noop.go
rename to eth/tracers/native/noop.go
index 84fa3ba81cc..814a5a9b4f3 100644
--- a/eth/tracers/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 tracers
+package native
import (
"encoding/json"
@@ -25,6 +25,7 @@ import (
"github.com/ledgerwatch/erigon/core/tracing"
"github.com/ledgerwatch/erigon/core/types"
+ "github.com/ledgerwatch/erigon/eth/tracers"
)
func init() {
@@ -36,9 +37,9 @@ func init() {
type NoopTracer struct{}
// newNoopTracer returns a new noop tracer.
-func newNoopTracer(ctx *Context, _ json.RawMessage) (*Tracer, error) {
+func newNoopTracer(ctx *tracers.Context, _ json.RawMessage) (*tracers.Tracer, error) {
t := &NoopTracer{}
- return &Tracer{
+ return &tracers.Tracer{
Hooks: &tracing.Hooks{
OnTxStart: t.OnTxStart,
OnTxEnd: t.OnTxEnd,
diff --git a/eth/tracers/util_test.go b/eth/tracers/util_test.go
new file mode 100644
index 00000000000..965c135b742
--- /dev/null
+++ b/eth/tracers/util_test.go
@@ -0,0 +1,59 @@
+// Copyright 2023 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 .
+package tracers
+
+import (
+ "testing"
+
+ "github.com/ledgerwatch/erigon/core/vm"
+)
+
+func TestMemCopying(t *testing.T) {
+ for i, tc := range []struct {
+ memsize int64
+ offset int64
+ size int64
+ wantErr string
+ wantSize int
+ }{
+ {0, 0, 100, "", 100}, // Should pad up to 100
+ {0, 100, 0, "", 0}, // No need to pad (0 size)
+ {100, 50, 100, "", 100}, // Should pad 100-150
+ {100, 50, 5, "", 5}, // Wanted range fully within memory
+ {100, -50, 0, "offset or size must not be negative", 0}, // Error
+ {0, 1, 1024*1024 + 1, "reached limit for padding memory slice: 1048578", 0}, // Error
+ {10, 0, 1024*1024 + 100, "reached limit for padding memory slice: 1048666", 0}, // Error
+ } {
+ mem := vm.NewMemory()
+ mem.Resize(uint64(tc.memsize))
+ cpy, err := GetMemoryCopyPadded(mem.Data(), tc.offset, tc.size)
+ if want := tc.wantErr; want != "" {
+ if err == nil {
+ t.Fatalf("test %d: want '%v' have no error", i, want)
+ }
+ if have := err.Error(); want != have {
+ t.Fatalf("test %d: want '%v' have '%v'", i, want, have)
+ }
+ continue
+ }
+ if err != nil {
+ t.Fatalf("test %d: unexpected error: %v", i, err)
+ }
+ if want, have := tc.wantSize, len(cpy); have != want {
+ t.Fatalf("test %d: want %v have %v", i, want, have)
+ }
+ }
+}